The function nc_inq_dimid returns (as an argument) the ID of a netCDF dimension, given the name of the dimension. If ndims is the number of dimensions defined for a netCDF dataset, each dimension has an ID between 0 and ndims-1.
int nc_inq_dimid (int ncid, const char *name, int *dimidp);
ncid
name
dimidp
nc_inq_dimid returns the value NC_NOERR if no errors occurred. Otherwise, the returned status indicates an error. Possible causes of errors include:
The name that was specified is not the name of a dimension in the netCDF dataset. The specified netCDF ID does not refer to an open netCDF dataset.
Here is an example using nc_inq_dimid to determine the dimension ID of a dimension named lat, assumed to have been defined previously in an existing netCDF dataset named foo.nc:
#include <netcdf.h> ... int status, ncid, latid; ... status = nc_open("foo.nc", NC_NOWRITE, &ncid); /* open for reading */ if (status != NC_NOERR) handle_error(status); ... status = nc_inq_dimid(ncid, "lat", &latid); if (status != NC_NOERR) handle_error(status);