[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netCDF #OBB-868168]: creating netCDF4 datasets



> Let me ask you one more thing-- Can you go in and out
> of define and data modes?
> So for example define a var, add its attributes, set compression,
> then put your data and then repeat this scheme for various
> datasets. So you would go in and out of the define mode
> and data mode for each dataset of variable.
> I am used to using the C++ interface so not explicitly calling the enddef.
>
> Or is it still a better practice to define all vars and add all
> of their attributes and THEN go into data mode.
>
> Thanks,
> Sue
>
>
>

Howdy Sue!

I think Russ is off to lunch so I will just chime in with the answer for you.

With both classic and netCDF-4/HDF5 files, you can go into or out of define
mode as often as you want.

But you should NOT do that with classic files without careful consideration, as
all data in the file has to be copied if you want to add some metadata. With
classic netCDF files, all the metadata is stored at the front of the file. To
add to it, all data have to be moved.

With netCDF-4/HDF5 files, there is no penalty for going into and out of define
mode. The metadata are written in a distributed way in the file, so when you
add a new variable (for example) nothing in the file has to be moved, the new
variable is just added to the file and away you go! ;-)

You can use nc_redef and nc_enddef to switch back and forth between data and
define mode. Or you could just ignore them and just count on the netCDF-4
library to switch you back and forth as needed. (But then any code you write
will break dramatically if you ever try and use it on a classic netCDF file.)

Good luck, and please let us know if you have any problems with the library!

Thanks,

Ed

Ticket Details
===================
Ticket ID: OBB-868168
Department: Support netCDF
Priority: Normal
Status: Closed