Next: nc_inq_var, Previous: nc_def_var, Up: Variables
The function nc_inq_varid returns the ID of a netCDF variable, given its name.
int nc_inq_varid (int ncid, const char *name, int *varidp);
ncid
name
varidp
nc_inq_varid 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 nc_inq_varid to find out the ID of a variable named rh in an existing netCDF dataset named foo.nc:
#include <netcdf.h> ... int status, ncid, rh_id; ... status = nc_open("foo.nc", NC_NOWRITE, &ncid); if (status != NC_NOERR) handle_error(status); ... status = nc_inq_varid (ncid, "rh", &rh_id); if (status != NC_NOERR) handle_error(status);