It is possible to write generic software that does such things as processing every netCDF variable, without needing to know in advance the names or shapes of these variables. Similarly, the names and numbers of dimensions and attributes may be unknown.
Names and other information about netCDF objects may be obtained by calling inquire functions. These return information about a whole netCDF dataset, a dimension, a variable, or an attribute. The following template illustrates how they are used:
nc_open /* open existing netCDF dataset */ ... nc_inq /* find out what is in it */ ... nc_inq_dim /* get dimension names, lengths */ ... nc_inq_var /* get variable names, types, shapes */ ... nc_inq_attname /* get attribute names */ ... nc_inq_att /* get attribute types and lengths */ ... nc_get_att /* get attribute values */ ... nc_get_var /* get values of variables */ ... nc_close /* close netCDF dataset */
In netCDF-3, inquire functions are inexpensive to use and require no I/O, since the information they provide is stored in memory when a netCDF dataset is first opened.