#include <netcdfcpp.h>
Inheritance diagram for NcFile:


Public Types | |
| enum | FileMode { ReadOnly, Write, Replace, New } |
| enum | FileFormat { Classic, Offset64Bits, Netcdf4, Netcdf4Classic, BadFormat } |
| enum | FillMode { Fill = NC_FILL, NoFill = NC_NOFILL, Bad } |
Public Member Functions | |
| virtual | ~NcFile (void) |
| NcFile (const char *path, FileMode=ReadOnly, size_t *chunksizeptr=NULL, size_t initialsize=0, FileFormat=Classic) | |
| NcBool | is_valid (void) const |
| int | num_dims (void) const |
| int | num_vars (void) const |
| int | num_atts (void) const |
| NcDim * | get_dim (NcToken) const |
| NcVar * | get_var (NcToken) const |
| NcAtt * | get_att (NcToken) const |
| NcDim * | get_dim (int) const |
| NcVar * | get_var (int) const |
| NcAtt * | get_att (int) const |
| NcDim * | rec_dim (void) const |
| NcDim * | add_dim (NcToken dimname, long dimsize) |
| NcDim * | add_dim (NcToken dimname) |
| NcVar * | add_var (NcToken varname, NcType type, const NcDim *dim0=0, const NcDim *dim1=0, const NcDim *dim2=0, const NcDim *dim3=0, const NcDim *dim4=0) |
| NcVar * | add_var (NcToken varname, NcType type, int ndims, const NcDim **dims) |
| NcBool | add_att (NcToken attname, char) |
| NcBool | add_att (NcToken attname, ncbyte) |
| NcBool | add_att (NcToken attname, short) |
| NcBool | add_att (NcToken attname, long) |
| NcBool | add_att (NcToken attname, int) |
| NcBool | add_att (NcToken attname, float) |
| NcBool | add_att (NcToken attname, double) |
| NcBool | add_att (NcToken attname, const char *) |
| NcBool | add_att (NcToken attname, int, const char *) |
| NcBool | add_att (NcToken attname, int, const ncbyte *) |
| NcBool | add_att (NcToken attname, int, const short *) |
| NcBool | add_att (NcToken attname, int, const long *) |
| NcBool | add_att (NcToken attname, int, const int *) |
| NcBool | add_att (NcToken attname, int, const float *) |
| NcBool | add_att (NcToken attname, int, const double *) |
| NcBool | set_fill (FillMode=Fill) |
| FillMode | get_fill (void) const |
| FileFormat | get_format (void) const |
| NcBool | sync (void) |
| NcBool | close (void) |
| NcBool | abort (void) |
| NcBool | define_mode (void) |
| NcBool | data_mode (void) |
| int | id (void) const |
Protected Attributes | |
| int | the_id |
| int | in_define_mode |
| FillMode | the_fill_mode |
| NcDim ** | dimensions |
| NcVar ** | variables |
| NcVar * | globalv |
Definition at line 31 of file netcdfcpp.h.
|
|
Definition at line 44 of file netcdfcpp.h. 00044 { 00045 Classic, // netCDF classic format (i.e. version 1 format) 00046 Offset64Bits, // netCDF 64-bit offset format 00047 Netcdf4, // netCDF-4 using HDF5 format 00048 Netcdf4Classic, // netCDF-4 using HDF5 format using only netCDF-3 calls 00049 BadFormat 00050 };
|
|
|
Definition at line 37 of file netcdfcpp.h. 00037 { 00038 ReadOnly, // file exists, open read-only 00039 Write, // file exists, open for writing 00040 Replace, // create new file, even if already exists 00041 New // create new file, fail if already exists 00042 };
|
|
|
Definition at line 102 of file netcdfcpp.h. 00102 { 00103 Fill = NC_FILL, // prefill (default) 00104 NoFill = NC_NOFILL, // don't prefill 00105 Bad 00106 };
|
|
|
Definition at line 24 of file netcdf.cpp. References close(). 00025 { 00026 (void) close(); 00027 }
|
|
||||||||||||||||||||||||
|
Definition at line 316 of file netcdf.cpp. References dimensions, err, Fill, globalv, in_define_mode, is_valid(), MAX_NC_DIMS, MAX_NC_VARS, NC_64BIT_OFFSET, nc__create, nc__open, nc_advise(), NC_CLASSIC_MODEL, NC_NETCDF4, NC_NOCLOBBER, NC_NOERR, NC_NOWRITE, NC_WRITE, ncBad, ncGlobal, Netcdf4, Netcdf4Classic, New, num_dims(), num_vars(), Offset64Bits, ReadOnly, Replace, NcError::silent_nonfatal, the_fill_mode, the_id, variables, and Write. 00318 { 00319 NcError err(NcError::silent_nonfatal); // constructor must not fail 00320 00321 int mode = NC_NOWRITE; 00322 the_fill_mode = Fill; 00323 int status; 00324 00325 // If the user wants a 64-bit offset format, set that flag. 00326 if (fformat == Offset64Bits) 00327 mode |= NC_64BIT_OFFSET; 00328 #ifdef USE_NETCDF4 00329 else if (fformat == Netcdf4) 00330 mode |= NC_NETCDF4; 00331 else if (fformat == Netcdf4Classic) 00332 mode |= NC_NETCDF4|NC_CLASSIC_MODEL; 00333 #endif 00334 00335 switch (fmode) { 00336 case Write: 00337 mode = NC_WRITE; 00338 /*FALLTHRU*/ 00339 case ReadOnly: 00340 // use netcdf-3 interface to permit specifying tuning parameter 00341 status = nc__open(path, mode, chunksizeptr, &the_id); 00342 if(status != NC_NOERR) 00343 { 00344 nc_advise("ncopen", status, "filename \"%s\"", path); 00345 the_id = -1; 00346 } 00347 in_define_mode = 0; 00348 break; 00349 case New: 00350 mode = NC_NOCLOBBER; 00351 /*FALLTHRU*/ 00352 case Replace: 00353 // use netcdf-3 interface to permit specifying tuning parameters 00354 status = nc__create(path, mode, initialsize, 00355 chunksizeptr, &the_id); 00356 if(status != NC_NOERR) 00357 { 00358 nc_advise("nccreate", status, "filename \"%s\"", path); 00359 the_id = -1; 00360 } 00361 in_define_mode = 1; 00362 break; 00363 default: 00364 the_id = ncBad; 00365 in_define_mode = 0; 00366 break; 00367 } 00368 if (is_valid()) { 00369 dimensions = new NcDim*[MAX_NC_DIMS]; 00370 variables = new NcVar*[MAX_NC_VARS]; 00371 int i; 00372 for (i = 0; i < num_dims(); i++) 00373 dimensions[i] = new NcDim(this, i); 00374 for (i = 0; i < num_vars(); i++) 00375 variables[i] = new NcVar(this, i); 00376 globalv = new NcVar(this, ncGlobal); 00377 } else { 00378 dimensions = 0; 00379 variables = 0; 00380 globalv = 0; 00381 } 00382 }
|
|
|
Definition at line 282 of file netcdf.cpp. References ncabort(), ncBad, and the_id.
|
|
||||||||||||||||
|
|
|
||||||||||||||||
|
|
|
||||||||||||||||
|
|
|
||||||||||||||||
|
|
|
||||||||||||||||
|
|
|
||||||||||||||||
|
|
|
||||||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
Referenced by gen(). |
|
|
Definition at line 115 of file netcdf.cpp. References add_dim(), and NC_UNLIMITED. 00116 { 00117 return add_dim(name, NC_UNLIMITED); 00118 }
|
|
||||||||||||
|
Definition at line 105 of file netcdf.cpp. References define_mode(), dimensions, is_valid(), and num_dims(). Referenced by add_dim(), and gen(). 00106 { 00107 if (!is_valid() || !define_mode()) 00108 return 0; 00109 int n = num_dims(); 00110 NcDim* dimp = new NcDim(this, name, size); 00111 dimensions[n] = dimp; // for garbage collection on close() 00112 return dimp; 00113 }
|
|
||||||||||||||||||||
|
Definition at line 164 of file netcdf.cpp. References define_mode(), NcDim::id(), is_valid(), ncvardef(), num_vars(), the_id, and variables. 00165 { 00166 if (!is_valid() || !define_mode()) 00167 return 0; 00168 int* dimids = new int[ndims]; 00169 for (int i=0; i < ndims; i++) 00170 dimids[i] = dims[i]->id(); 00171 int n = num_vars(); 00172 NcVar* varp = 00173 new NcVar(this, ncvardef(the_id, name, (nc_type) type, ndims, dimids)); 00174 variables[n] = varp; 00175 delete [] dimids; 00176 return varp; 00177 }
|
|
||||||||||||||||||||||||||||||||
|
Definition at line 123 of file netcdf.cpp. References define_mode(), NcDim::id(), is_valid(), ncvardef(), ndims, num_vars(), the_id, and variables. Referenced by gen(). 00129 { 00130 if (!is_valid() || !define_mode()) 00131 return 0; 00132 int dims[5]; 00133 int ndims = 0; 00134 if (dim0) { 00135 ndims++; 00136 dims[0] = dim0->id(); 00137 if (dim1) { 00138 ndims++; 00139 dims[1] = dim1->id(); 00140 if (dim2) { 00141 ndims++; 00142 dims[2] = dim2->id(); 00143 if (dim3) { 00144 ndims++; 00145 dims[3] = dim3->id(); 00146 if (dim4) { 00147 ndims++; 00148 dims[4] = dim4->id(); 00149 } 00150 } 00151 } 00152 } 00153 } 00154 int n = num_vars(); 00155 NcVar* varp = 00156 new NcVar(this, ncvardef(the_id, name, (nc_type) type, ndims, dims)); 00157 variables[n] = varp; 00158 return varp; 00159 }
|
|
|
Definition at line 264 of file netcdf.cpp. References dimensions, globalv, ncBad, ncclose(), num_dims(), num_vars(), the_id, and variables. Referenced by ~NcFile(). 00265 { 00266 int i; 00267 00268 if (the_id == ncBad) 00269 return 0; 00270 for (i = 0; i < num_dims(); i++) 00271 delete dimensions[i]; 00272 for (i = 0; i < num_vars(); i++) 00273 delete variables[i]; 00274 delete [] dimensions; 00275 delete [] variables; 00276 delete globalv; 00277 int old_id = the_id; 00278 the_id = ncBad; 00279 return ncclose(old_id) != ncBad; 00280 }
|
|
|
Definition at line 299 of file netcdf.cpp. References FALSE, in_define_mode, is_valid(), ncBad, ncendef(), the_id, and TRUE. Referenced by sync(). 00300 { 00301 if (! is_valid()) 00302 return FALSE; 00303 if (! in_define_mode) 00304 return TRUE; 00305 if (ncendef(the_id) == ncBad) 00306 return FALSE; 00307 in_define_mode = 0; 00308 return TRUE; 00309 }
|
|
|
Definition at line 287 of file netcdf.cpp. References FALSE, in_define_mode, is_valid(), ncBad, ncredef(), the_id, and TRUE. Referenced by NcVar::add_att(), add_dim(), add_var(), NcAtt::remove(), NcAtt::rename(), and NcDim::rename(). 00288 { 00289 if (! is_valid()) 00290 return FALSE; 00291 if (in_define_mode) 00292 return TRUE; 00293 if (ncredef(the_id) == ncBad) 00294 return FALSE; 00295 in_define_mode = 1; 00296 return TRUE; 00297 }
|
|
|
Definition at line 89 of file netcdf.cpp. References NcVar::get_att(), globalv, and is_valid().
|
|
|
Definition at line 70 of file netcdf.cpp. References NcVar::get_att(), globalv, and is_valid(). Referenced by DumpableNcFile::dumpgatts().
|
|
|
Definition at line 75 of file netcdf.cpp. References dimensions, is_valid(), and num_dims(). 00076 { 00077 if (! is_valid() || i < 0 || i >= num_dims()) 00078 return 0; 00079 return dimensions[i]; 00080 }
|
|
|
Definition at line 58 of file netcdf.cpp. References ncdimid(), and the_id. Referenced by DumpableNcFile::dumpdims(), NcVar::get_dim(), and rec_dim().
|
|
|
Definition at line 217 of file netcdf.cpp. References the_fill_mode. 00218 { 00219 return the_fill_mode; 00220 }
|
|
|
Definition at line 222 of file netcdf.cpp. References BadFormat, Classic, NC_FORMAT_64BIT, NC_FORMAT_CLASSIC, NC_FORMAT_NETCDF4, NC_FORMAT_NETCDF4_CLASSIC, nc_inq_format, Netcdf4, Netcdf4Classic, Offset64Bits, and the_id. 00223 { 00224 int the_format; 00225 nc_inq_format(the_id, &the_format); 00226 switch (the_format) { 00227 case NC_FORMAT_CLASSIC: 00228 return Classic; 00229 case NC_FORMAT_64BIT: 00230 return Offset64Bits; 00231 case NC_FORMAT_NETCDF4: 00232 return Netcdf4; 00233 case NC_FORMAT_NETCDF4_CLASSIC: 00234 return Netcdf4Classic; 00235 default: 00236 return BadFormat; 00237 } 00238 }
|
|
|
Definition at line 82 of file netcdf.cpp. References is_valid(), num_vars(), and variables. 00083 { 00084 if (! is_valid() || i < 0 || i >= num_vars()) 00085 return 0; 00086 return variables[i]; 00087 }
|
|
|
Definition at line 64 of file netcdf.cpp. References ncvarid(), and the_id. Referenced by DumpableNcFile::dumpdata(), and DumpableNcFile::dumpvars().
|
|
|
Definition at line 311 of file netcdf.cpp. References the_id. Referenced by NcVar::add_att(), NcVar::attnum(), NcVar::get_dim(), NcVar::get_rec(), NcDim::is_unlimited(), NcAtt::is_valid(), NcDim::NcDim(), NcVar::NcVar(), NcVar::num_atts(), NcVar::num_dims(), NcAtt::num_vals(), NcAtt::remove(), NcAtt::rename(), NcDim::rename(), NcDim::size(), NcVar::sync(), NcDim::sync(), NcAtt::type(), NcVar::type(), NcAtt::values(), and NcVar::values(). 00312 { 00313 return the_id; 00314 }
|
|
|
Definition at line 29 of file netcdf.cpp. Referenced by add_dim(), add_var(), data_mode(), define_mode(), gen(), get_att(), get_dim(), get_var(), NcAtt::is_valid(), NcVar::is_valid(), NcDim::is_valid(), NcFile(), NcVar::num_atts(), num_atts(), num_dims(), num_vars(), rec_dim(), and sync().
|
|
|
Definition at line 50 of file netcdf.cpp. References is_valid(), ncinquire(), and the_id. Referenced by dump(), and NcVar::num_atts(). 00051 { 00052 int num = 0; 00053 if (is_valid()) 00054 ncinquire(the_id, 0, 0, &num, 0); 00055 return num; 00056 }
|
|
|
Definition at line 34 of file netcdf.cpp. References is_valid(), ncinquire(), and the_id. Referenced by add_dim(), close(), DumpableNcFile::dumpdims(), DumpableNcFile::dumpvars(), get_dim(), NcFile(), and sync(). 00035 { 00036 int num = 0; 00037 if (is_valid()) 00038 ncinquire(the_id, &num, 0, 0, 0); 00039 return num; 00040 }
|
|
|
Definition at line 42 of file netcdf.cpp. References is_valid(), ncinquire(), and the_id. Referenced by add_var(), close(), get_var(), NcFile(), and sync(). 00043 { 00044 int num = 0; 00045 if (is_valid()) 00046 ncinquire(the_id, 0, &num, 0, 0); 00047 return num; 00048 }
|
|
|
Definition at line 94 of file netcdf.cpp. References get_dim(), is_valid(), ncinquire(), and the_id. 00095 { 00096 if (! is_valid()) 00097 return 0; 00098 int recdim; 00099 ncinquire(the_id, 0, 0, 0, &recdim); 00100 if (recdim == -1) 00101 return 0; 00102 return get_dim(recdim); 00103 }
|
|
|
|
|
|
Definition at line 240 of file netcdf.cpp. References data_mode(), dimensions, is_valid(), ncBad, ncsync(), num_dims(), num_vars(), NcVar::sync(), NcDim::sync(), the_id, and variables. 00241 { 00242 if (!data_mode()) 00243 return 0; 00244 if (ncsync(the_id) == ncBad) 00245 return 0; 00246 int i; 00247 for (i = 0; i < num_dims(); i++) { 00248 if (dimensions[i]->is_valid()) { 00249 dimensions[i]->sync(); 00250 } else { // someone else added a new dimension 00251 dimensions[i] = new NcDim(this,i); 00252 } 00253 } 00254 for (i = 0; i < num_vars(); i++) { 00255 if (variables[i]->is_valid()) { 00256 variables[i]->sync(); 00257 } else { // someone else added a new variable 00258 variables[i] = new NcVar(this,i); 00259 } 00260 } 00261 return 1; 00262 }
|
|
|
Definition at line 125 of file netcdfcpp.h. Referenced by add_dim(), close(), get_dim(), NcFile(), and sync(). |
|
|
Definition at line 127 of file netcdfcpp.h. |
|
|
Definition at line 123 of file netcdfcpp.h. Referenced by data_mode(), define_mode(), and NcFile(). |
|
|
Definition at line 124 of file netcdfcpp.h. Referenced by get_fill(), and NcFile(). |
|
|
Definition at line 122 of file netcdfcpp.h. Referenced by abort(), add_var(), close(), data_mode(), define_mode(), get_dim(), get_format(), get_var(), id(), is_valid(), NcFile(), num_atts(), num_dims(), num_vars(), rec_dim(), and sync(). |
|
|
Definition at line 126 of file netcdfcpp.h. Referenced by add_var(), close(), get_var(), NcFile(), and sync(). |
1.4.4