Go to the previous, next section.
The function ncvarid (or NCVID for FORTRAN) returns the ID
of a netCDF variable, given its name.
In case of an error, ncvarid returns -1; NCVID returns a
nonzero value in rcode. Possible causes of errors include:
int ncvarid(int ncid, const char* name);
ncid
ncopen or nccreate.
name
Here is an example using ncvarid to find out the ID of a variable
named rh in an existing netCDF file named `foo.nc':
#include "netcdf.h"
...
int ncid; /* netCDF ID */
int rh_id; /* variable ID */
...
ncid = ncopen("foo.nc", NC_NOWRITE);
...
rh_id = ncvarid (ncid, "rh");
INTEGER FUNCTION NCVID(INTEGER NCID,
+ CHARACTER*(*) VARNAM,
+ INTEGER RCODE)
NCID
NCOPN or NCCRE.
VARNAM
RCODE
Here is an example using NCVID to find out the ID of a variable
named rh in an existing netCDF file named `foo.nc':
INCLUDE 'netcdf.inc'
...
INTEGER NCID, RCODE
INTEGER RHID ! variable ID
...
NCID = NCOPN ('foo.nc', NCNOWRIT, RCODE)
...
RHID = NCVID (NCID, 'rh', RCODE)
Go to the previous, next section.