2012 Unidata NetCDF Workshop > Formats and Performance
14.4 NetCDF Classic Performance Tips
Recommendations for using netCDF classic efficiently
Avoid premature optimization: worry about
performance only after you determine where the bottlenecks
are. The netCDF classic file format is mature and implementation is efficient for
many uses.
If netCDF access time is a bottleneck, these techniques may help:
- If data will be written once but ready many times, change
dimension order for variables, to favor most common access patterns
(see ncpdq). Avoid
reading one value per disk access!
- For lots of record variables, use record-at-a-time
processing rather than variable-at-a-time
- To avoid copying data when the file schema changes:
- Create all needed dimensions, variables, and attributes
before writing data, or
- Reserve extra space in the file header for later additions
nc__enddef()
in C
NF__ENDDEF()
or NF90__ENDDEF()
for
Fortran
- setExtraHeaderBytes() method of NetcdfFileWritable for
Java
- With netCDF-3 or -4, all file metadata is read into memory
when file is opened, so functions that get metadata ("_inq_" functions) are very
fast. However, try to avoid the need for opening many files to get
a little data out of each, with can be slow if each file has lots of
complex metadata.
- Use an HDF5-based netCDF-4 format to avoid overhead of schema additions
2012 Unidata NetCDF Workshop > Formats and Performance