FV3 Bundle
|
Implementation of IodaIO for netcdf. More...
#include <NetcdfIO.h>
Public Member Functions | |
NetcdfIO (const std::string &FileName, const std::string &FileMode, const std::size_t &Nlocs, const std::size_t &Nobs, const std::size_t &Nrecs, const std::size_t &Nvars) | |
~NetcdfIO () | |
void | ReadVar (const std::string &VarName, int *VarData) |
Read data from netcdf file to memory. More... | |
void | ReadVar (const std::string &VarName, float *VarData) |
void | ReadVar (const std::string &VarName, double *VarData) |
void | WriteVar (const std::string &VarName, int *VarData) |
Write data from memory to netcdf file. More... | |
void | WriteVar (const std::string &VarName, float *VarData) |
void | WriteVar (const std::string &VarName, double *VarData) |
void | ReadDateTime (int *VarDate, int *VarTime) |
Read and format the date, time values. More... | |
Public Member Functions inherited from ioda::IodaIO | |
virtual | ~IodaIO ()=0 |
std::string | fname () const |
std::string | fmode () const |
std::size_t | nlocs () |
std::size_t | nobs () |
std::size_t | nrecs () |
std::size_t | nvars () |
Static Public Member Functions | |
static const std::string | classname () |
classname method for object counter More... | |
Private Member Functions | |
void | print (std::ostream &os) const |
print method for stream output More... | |
void | CheckNcCall (int, std::string &) |
check results of netcdf call More... | |
Private Attributes | |
int | ncid_ |
netcdf file id More... | |
int | nlocs_id_ |
This data member holds the netcdf id of the "nlocs" dimension in the opened netcdf file. More... | |
int | nvars_id_ |
This data member holds the netcdf id of the "nvars" dimension in the opened netcdf file. More... | |
int | nobs_id_ |
This data member holds the netcdf id of the "nobs" dimension in the opened netcdf file. More... | |
int | nrecs_id_ |
This data member holds the netcdf id of the "nrecs" dimension in the opened netcdf file. More... | |
int | nchans_id_ |
This data member holds the netcdf id of the "nchans" dimension in the opened netcdf file. More... | |
int | nc_varid_ |
This data member holds the netcdf id of the current dataset (variable) in the opened netcdf file. More... | |
bool | have_nlocs_ |
This data member is a flag that indicates the existence of the "nlocs" dimension in the opened netcdf file. More... | |
bool | have_nvars_ |
This data member is a flag that indicates the existence of the "nvars" dimension in the opened netcdf file. More... | |
bool | have_nobs_ |
This data member is a flag that indicates the existence of the "nobs" dimension in the opened netcdf file. More... | |
bool | have_nrecs_ |
This data member is a flag that indicates the existence of the "nrecs" dimension in the opened netcdf file. More... | |
bool | have_nchans_ |
This data member is a flag that indicates the existence of the "nchans" dimension in the opened netcdf file. More... | |
int | nc_attid_ |
This data member holds the netcdf id of the current attribute in the opened netcdf file. More... | |
Additional Inherited Members | |
Protected Attributes inherited from ioda::IodaIO | |
std::string | fname_ |
file name More... | |
std::string | fmode_ |
file mode ("r" -> read, "w" -> overwrite, "W" -> create and write) More... | |
std::size_t | nlocs_ |
number of unique locations More... | |
std::size_t | nobs_ |
number of unique observations More... | |
std::size_t | nrecs_ |
number of unique records More... | |
std::size_t | nvars_ |
number of unique variables More... | |
Implementation of IodaIO for netcdf.
The NetcdfIO class defines the constructor and methods for the abstract class IodaIO.
Definition at line 36 of file NetcdfIO.h.
ioda::NetcdfIO::NetcdfIO | ( | const std::string & | FileName, |
const std::string & | FileMode, | ||
const std::size_t & | Nlocs, | ||
const std::size_t & | Nobs, | ||
const std::size_t & | Nrecs, | ||
const std::size_t & | Nvars | ||
) |
This constructor will open the netcdf file. If opening in read mode, the parameters nlocs, nobs, nrecs and nvars will be set by querying the size of dimensions of the same names in the input file. If opening in write mode, the parameters will be set from the same named arguements to this constructor.
[in] | FileName | Path to the netcdf file |
[in] | FileMode | "r" for read, "w" for overwrite to an existing file and "W" for create and write to a new file. |
[in] | Nlocs | Number of unique locations in the obs data. |
[in] | Nobs | Number of unique observations in the obs data. |
[in] | Nrecs | Number of unique records in the obs data. Records are atomic units that will remain intact when obs are distributed across muliple process elements. A single radiosonde sounding would be an example. |
[in] | Nvars | Number of unique varibles in the obs data. |
Definition at line 47 of file NetcdfIO.cc.
ioda::NetcdfIO::~NetcdfIO | ( | ) |
Definition at line 149 of file NetcdfIO.cc.
|
private |
check results of netcdf call
This method will check the return code from a netcdf API call. Successful completion of the call is indicated by the return code being equal to NC_NOERR. If the call was not successful, then the error message is written to the OOPS log, and is also sent to the OOPS ABORT call (execution is aborted).
[in] | RetCode | Return code from netcdf call |
[in] | ErrorMsg | Message for the OOPS error logger |
Definition at line 378 of file NetcdfIO.cc.
|
inlinestatic |
classname method for object counter
This method is supplied for the ObjectCounter base class. It defines a name to identify an object of this class for reporting by OOPS.
Definition at line 46 of file NetcdfIO.h.
|
private |
print method for stream output
This method is supplied for the Printable base class. It defines how to print an object of this class in an output stream.
Definition at line 360 of file NetcdfIO.cc.
|
virtual |
Read and format the date, time values.
This method will read in the date and time information (timestamp) from the netcdf file, and convert them into a convenient format for usage by the JEDI system. Currently, the netcdf files contain an attribute called "date_time" that holds the analysis time for the obs data in the format yyyymmddhh. For example April 15, 2018 at 00Z is recorded as 2018041500. The netcdf file also contains a time variable (float) which is the offset from the date_time value in hours. This method will convert the date time information to two integer vectors. The first is the date (yyyymmdd) and the second is the time (hhmmss). With the above date_time example combined with a time value of -3.5 (hours), the resulting date and time entries in the output vectors will be date = 20180414 and time = 233000.
Eventually, the yyyymmdd and hhmmss values can be recorded in the netcdf file as thier own datasets and this method could be removed.
[out] | VarDate | Date portion of the timestamp values (yyyymmdd) |
[out] | VarTime | Time portion of the timestamp values (hhmmss) |
Implements ioda::IodaIO.
Definition at line 296 of file NetcdfIO.cc.
|
virtual |
Read data from netcdf file to memory.
The three ReadVar methods are the same with the exception of the datatype that is being read (integer, float, double). It is the caller's responsibility to allocate memory to hold the data being read. The caller then passes a pointer to that memory for the VarData argument.
[in] | VarName | Name of dataset in the netcdf file |
[out] | VarData | Pointer to memory that will receive the file data |
Implements ioda::IodaIO.
Definition at line 169 of file NetcdfIO.cc.
|
virtual |
Implements ioda::IodaIO.
Definition at line 183 of file NetcdfIO.cc.
|
virtual |
Implements ioda::IodaIO.
Definition at line 197 of file NetcdfIO.cc.
|
virtual |
Write data from memory to netcdf file.
The three WriteVar methods are the same with the exception of the datatype that is being written (integer, float, double). It is the caller's responsibility to allocate and assign memory to the data that are to be written. The caller then passes a pointer to that memory for the VarData argument.
[in] | VarName | Name of dataset in the netcdf file |
[in] | VarData | Pointer to memory that will be written into the file |
Implements ioda::IodaIO.
Definition at line 223 of file NetcdfIO.cc.
|
virtual |
Implements ioda::IodaIO.
Definition at line 240 of file NetcdfIO.cc.
|
virtual |
Implements ioda::IodaIO.
Definition at line 257 of file NetcdfIO.cc.
|
private |
This data member is a flag that indicates the existence of the "nchans" dimension in the opened netcdf file.
Definition at line 143 of file NetcdfIO.h.
|
private |
This data member is a flag that indicates the existence of the "nlocs" dimension in the opened netcdf file.
Definition at line 119 of file NetcdfIO.h.
|
private |
This data member is a flag that indicates the existence of the "nobs" dimension in the opened netcdf file.
Definition at line 131 of file NetcdfIO.h.
|
private |
This data member is a flag that indicates the existence of the "nrecs" dimension in the opened netcdf file.
Definition at line 137 of file NetcdfIO.h.
|
private |
This data member is a flag that indicates the existence of the "nvars" dimension in the opened netcdf file.
Definition at line 125 of file NetcdfIO.h.
|
private |
This data member holds the netcdf id of the current attribute in the opened netcdf file.
Definition at line 149 of file NetcdfIO.h.
|
private |
This data member holds the netcdf id of the current dataset (variable) in the opened netcdf file.
Definition at line 113 of file NetcdfIO.h.
|
private |
This data member holds the netcdf id of the "nchans" dimension in the opened netcdf file.
Definition at line 107 of file NetcdfIO.h.
|
private |
netcdf file id
This data member holds the file id of the open netcdf file. It gives access to the dimensions, attributes and variables in the netcdf file.
Definition at line 77 of file NetcdfIO.h.
|
private |
This data member holds the netcdf id of the "nlocs" dimension in the opened netcdf file.
Definition at line 83 of file NetcdfIO.h.
|
private |
This data member holds the netcdf id of the "nobs" dimension in the opened netcdf file.
Definition at line 95 of file NetcdfIO.h.
|
private |
This data member holds the netcdf id of the "nrecs" dimension in the opened netcdf file.
Definition at line 101 of file NetcdfIO.h.
|
private |
This data member holds the netcdf id of the "nvars" dimension in the opened netcdf file.
Definition at line 89 of file NetcdfIO.h.