 
  
   
    2012 Unidata NetCDF Workshop  > Using netCDF in programs
 
2012 Unidata NetCDF Workshop  > Using netCDF in programs  
 
11.4 Some Common Errors to Avoid
Some common errors in using C and Fortran netCDF APIs
  - Not checking the return from each netCDF function
  call: a non-zero return means an error occurred, and indicates the
  cause.  A function is available to turn error codes into
  meaningful error messages.
  
- When writing data, not explicitly calling a netCDF close
  function before exit, to make sure all the data gets written to disk
  
- 
  When reading data, not providing a big enough array into which data
  will be read: because C and Fortran APIs
  don't include a parameter for how much space the caller is
  providing, this cannot be checked by compilers.
  
- When writing data to a variable that uses the unlimited (record)
  dimension: you usually need to specify how many records to write.
  
- When reading data from a record variable, specify how many
  records to read to avoid overflowing a buffer, in case the file has
  more records than you expect.
  
- 
  If reading character data using the C API, make the character array into a
  string by explicitly adding null termination, even for attribute values.
  
 
 
 
  
   
    2012 Unidata NetCDF Workshop  > Using netCDF in programs
  
2012 Unidata NetCDF Workshop  > Using netCDF in programs