2009 Unidata NetCDF Workshop for Developers and Data Providers > Formats and Performance
13.2 Classic File Format
Understanding the netCDF classic format can make clear why
modifying the schema of an existing netCDF file may be expensive.
By default, the header has almost no extra space; it is just large
enough to contain the dimensions, attributes
(including all attribute values), and variable metadata,
rounded up to a whole number of disk blocks.
- Advantage: netCDF files are compact, with little overhead
- Disadvantage: schema changes may require moving all the
data:
- defining new dimensions, variables, or attributes in an
existing file
- renaming existing dimensions, variables, or attributes with
longer names
- redefining an attribute to have values of a larger type or
more values, such as a longer string value
To avoid copying data when the file schema changes, either
- create all necessary dimensions, variables, and attributes
before writing data, or
- reserve extra space in the file header for later additions
(using
nc__enddef()
in C, NF__ENDDEF()
or
NF90__ENDDEF()
for Fortran, setExtraHeaderBytes() method
of NetcdfFileWritable for Java)
2009 Unidata NetCDF Workshop for Developers and Data Providers > Formats and Performance