3#include "ncException.h"
26 cerr << e.what() << endl;
33 ncCheck(nc_close(myId),__FILE__,__LINE__);
48 open(filePath, fMode);
54 open(filePath, ncFileFlags);
63void NcFile::open(
const string& filePath,
int ncFileFlags) {
67 ncCheck(nc_open(filePath.c_str(), ncFileFlags, &myId),__FILE__,__LINE__);
75void NcFile::open(
const string& filePath,
const FileMode fMode)
85 ncCheck(nc_open(filePath.c_str(), NC_WRITE, &myId),__FILE__,__LINE__);
88 ncCheck(nc_open(filePath.c_str(), NC_NOWRITE, &myId),__FILE__,__LINE__);
91 ncCheck(nc_create(filePath.c_str(), NC_NETCDF4 | NC_NOCLOBBER, &myId),__FILE__,__LINE__);
94 ncCheck(nc_create(filePath.c_str(), NC_NETCDF4 | NC_CLOBBER, &myId),__FILE__,__LINE__);
104NcFile::NcFile(
const string& filePath,
const FileMode fMode,
const FileFormat fFormat )
106 open(filePath, fMode, fFormat);
118 ncCheck(nc_create(filePath.c_str(),ncFileFlags,&myId),__FILE__,__LINE__);
125void NcFile::open(
const string& filePath,
const FileMode fMode,
const FileFormat fFormat )
137 format = NC_64BIT_OFFSET;
143 format = NC_NETCDF4 | NC_CLASSIC_MODEL;
149 ncCheck(nc_open(filePath.c_str(), format | NC_WRITE, &myId),__FILE__,__LINE__);
152 ncCheck(nc_open(filePath.c_str(), format | NC_NOWRITE, &myId),__FILE__,__LINE__);
155 ncCheck(nc_create(filePath.c_str(), format | NC_NOCLOBBER, &myId),__FILE__,__LINE__);
158 ncCheck(nc_create(filePath.c_str(), format | NC_CLOBBER, &myId),__FILE__,__LINE__);
168 ncCheck(nc_sync(myId),__FILE__,__LINE__);
172 ncCheck(nc_set_fill(myId, fillmode, old_modep),__FILE__,__LINE__);
178 ncCheck(nc_redef(myId),__FILE__,__LINE__);
183 ncCheck(nc_enddef(myId),__FILE__,__LINE__);
NcFile()
Constructor generates a null object.
void sync()
Synchronize an open netcdf dataset to disk.
void enddef()
Leave define mode, used for classic model.
void set_Fill(int fillmode, int *old_modep)
Elect a fill parameter different that the one currently being used.
@ newFile
Create new file, fail if already exists.
@ read
File exists, open read-only.
@ write
File exists, open for writing.
@ replace
Create new file, even if already exists.
void open(const std::string &filePath, int ncFileFlags)
Opens a netCDF file.
void close()
Close a file before destructor call.
void create(const std::string &filePath, int ncFileFlags)
Create a netCDF file.
void redef()
Redefine variable.
@ classic
Classic format, classic data model.
@ classic64
64-bit offset format, classic data model
@ nc4
(default) netCDF-4/HDF5 format, enhanced data model
@ nc4classic
netCDF-4/HDF5 format, classic data model
Class represents a netCDF group.
bool nullObject
assignment operator
Base object is thrown if a netCDF exception is encountered.
void ncCheck(int retCode, const char *file, int line)
Function checks error code and if necessary throws an exception.