2010 Unidata NetCDF Workshop > Formats and Performance
12.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 little extra space; it is just large
enough for metadata: dimensions, attributes, and variable metadata,
rounded up to next disk block.
- Advantage: netCDF files are compact, with little overhead
- Disadvantage: schema additions 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 needed 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)
2010 Unidata NetCDF Workshop > Formats and Performance