34using std::ostringstream;
42int FONcDim::DimNameNum = 0;
43int FONcDim::StructDimNameNum = 0;
51 _name(name), _size(size)
65 if (!_ref)
delete this;
68void FONcDim::struct_decref()
71 if (!_struct_ref)
delete this;
89 ostringstream dimname_strm;
90 dimname_strm <<
"dim" << FONcDim::DimNameNum + 1;
91 FONcDim::DimNameNum++;
92 _name = dimname_strm.str();
98 BESDEBUG(
"fonc",
"FONcDim:: dimension size is "<<_size <<endl);
99 BESDEBUG(
"fonc",
"FONcDim:: dimension name is "<<_name <<endl);
100 int stax = nc_def_dim(ncid, _name.c_str(), _size, &_dimid);
101 if (stax != NC_NOERR) {
102 string err = (string)
"fileout.netcdf - " +
"Failed to add dimension " + _name;
109void FONcDim::define_struct(
int ncid)
113 FONcDim::StructDimNameNum++;
114 _name =
"sdim" + to_string(FONcDim::StructDimNameNum);
120 BESDEBUG(
"fonc",
"FONcDim:: dimension size is "<<_size <<endl);
121 BESDEBUG(
"fonc",
"FONcDim:: dimension name is "<<_name <<endl);
122 int stax = nc_def_dim(ncid, _name.c_str(), _size, &_dimid);
123 if (stax != NC_NOERR) {
124 string err = (string)
"fileout.netcdf - " +
"Failed to add dimension " + _name;
139 strm << BESIndent::LMarg <<
"FONcDim::dump - (" << (
void *)
this <<
")" << endl;
141 strm << BESIndent::LMarg <<
"name = " << _name << endl;
142 strm << BESIndent::LMarg <<
"size = " << _size << endl;
143 strm << BESIndent::LMarg <<
"dimid = " << _dimid << endl;
144 strm << BESIndent::LMarg <<
"already defined? ";
150 BESIndent::UnIndent();
virtual void dump(std::ostream &strm) const
dumps information about this object for debugging purposes
FONcDim(const std::string &name, int64_t size)
Constructor for FOncDim that defines the dimension of an array.
virtual void define(int ncid)
define the DAP dimension in the netcdf file
virtual void decref()
Decrement the reference count for this dimension.
static void handle_error(int stax, const string &err, const string &file, int line)
handle any netcdf errors
static string id2netcdf(string in)
convert the provided string to a netcdf allowed identifier.