Deciphering NC_ERROR Codes
When working with NetCDF files in IDL, one can receive error messages that include error codes returned from the NetCDF library. This article discusses how to find information about what those error codes mean.
NetCDF library error codes can show up in IDL error messages using the syntax: NC_ERROR=xx
. . . where xx is the number of the NetCDF library error. For example:
% NCDF_OPEN: Unable to open the file "fakename.net0090". (NC_ERROR=-51)
It is possible to find some information about what type of problem the given error number indicates by looking in the netcdf.inc ASCII file, which is part of the NetCDF library.
There are two places in this file which can be helpful. First, starting at the line that reads "parameter (nf_noerr = 0)") is a list of parameter codes, in which you can look up the numerical value for NC_ERROR provided in the IDL message. For example, NC_ERROR=-51 corresponds to nf_enotnc. It takes a bit of imagination, but that code can be understood as "not a NetCDF file". You can confirm that interpretation by noticing that the string "nf_enotnc" appears again in a later line. The line just above that line is the interpretation for the code, and it reads "not a netcdf file".
To summarize, a good way to use ' netcdf.inc' in debugging is
- Do a text search in it for the NC_ERROR value that IDL output. That will give you the cross-reference to the NetCDF error name associated with the error number.
- Now do a text search for the error name to see if 'netcdf.inc' has an explanatory comment about that error.
- Even if there is no explanatory comment, the substring that follows "nf_e" in the error name will probably give you a good clue as to what the error means.
Reviewed 10/15/14 by PS