2009 Unidata NetCDF Workshop for Developers and Data Providers > NetCDF APIs
10.12 Some Common Errors to Avoid
Here is a list of some common errors to avoid in using netCDF APIs,
based on support questions and experience assisting users.
- Remember to explicitly flush or close a netCDF dataset you are writing to
make sure all the data gets written to disk.
- The caller is responsible for making sure there is enough memory
space into which data will be read. Because many APIs
do not include a parameter for how much space the caller is
providing, this cannot be checked by compilers.
- The simplest call to write netCDF data writes all the values of
a variable at once from an array. If you try to write all the
values of a record variable into a netCDF file that has no record
data yet (hence has 0 records), nothing will be written.
- Similarly, if you try to write or read all of a record variable, but
there are more records in the file than you assume, this may result in a
segmentation violation.
- If reading character data using the C API, note that
the caller is responsible for making the character array into a
string by explicitly adding null termination, even for attribute values.
2009 Unidata NetCDF Workshop for Developers and Data Providers > NetCDF APIs