/** * Create a variable of data type float */ void store(Property<float> *v) { int retval; int varid; std::string sname = composeName(v->getName()); /** * Create a new variable with only one dimension i.e. the unlimited time dimension */ retval = nc_def_var(ncid, sname.c_str(), NC_FLOAT, DIMENSION_VAR, &dimsid, &varid); if ( retval ) log(Error) << "Could not create variable " << sname << ", error " << retval <<endlog(); else log(Info) << "Variable "<< sname << " successfully created" <<endlog(); }
/** * Write double data to corresponding variable name */ void store(Property<double> *v) { int retval; int varid; double value = v->get(); std::string sname = composeName(v->getName()); /** * Get netcdf variable ID from name */ retval = nc_inq_varid(ncid, sname.c_str(), &varid); if (retval) log(Error) << "Could not get variable id of " << sname << ", error " << retval <<endlog(); /** * Write a single data value */ retval = nc_put_var1_double(ncid, varid, &index, &value); if(retval) log(Error) << "Could not write variable " << sname << ", error " << retval <<endlog(); }