Next: ncmpi_inq_dim Family, Previous: ncmpi_def_dim, Up: Dimensions [Index]
The function ncmpi_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 file, each dimension has an ID between 0 and ndims-1.
This API is an independent subroutine and can be called while the file is in either define or data mode (collective or independent).
int ncmpi_inq_dimid(int ncid, const char *name, int *dimidp);
ncid
NetCDF ID, an input argument obtained from a previous call to ncmpi_open or ncmpi_create.
name
Dimension name, an input argument, a character string beginning with a letter and followed by any sequence of letters, digits, or underscore (’_’) characters. Case is significant in dimension names.
dimidp
Pointer to location for the returned dimension ID (output).
ncmpi_inq_dimid returns the value NC_NOERR if no errors occurred. Otherwise, the returned status indicates an error. Possible causes of errors include:
Here is an example using ncmpi_inq_dimid to determine the dimension ID of a dimension named lat, assumed to have been defined previously in an existing netCDF file named foo.nc:
#include <pnetcdf.h> ... int status, ncid, latid; ... status = ncmpi_open(MPI_COMM_WORLD, "foo.nc", NC_NOWRITE, MPI_INFO_NULL, &ncid); /* open for reading */ if (status != NC_NOERR) handle_error(status); ... status = ncmpi_inq_dimid(ncid, "lat", &latid); if (status != NC_NOERR) handle_error(status);
Next: ncmpi_inq_dim Family, Previous: ncmpi_def_dim, Up: Dimensions [Index]