Go to the previous, next section.
The function ncvarrename (or NCVREN for FORTRAN) changes
the name of a netCDF variable in an open netCDF. If the new name is
longer than the old name, the netCDF must be in define mode. You cannot
rename a variable to have the name of any existing variable.
In case of an error, ncvarrename returns -1; NCVREN returns a
nonzero value in rcode. Possible causes of errors include:
int ncvarrename(int ncid, int varid, const char* name);
ncid
ncopen or nccreate.
varid
ncvardef or
ncvarid.
name
Here is an example using ncvarrename to rename the variable
rh to rel_hum 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_WRITE);
...
ncredef(ncid); /* put in define mode to rename variable */
rh_id = ncvarid (ncid, "rh");
ncvarrename (ncid, rh_id, "rel_hum");
ncendef(ncid); /* leave define mode */
SUBROUTINE NCVREN (INTEGER NCID, INTEGER VARID,
+ CHARACTER*(*) NEWNAM, INTEGER RCODE)
NCID
NCOPN or NCCRE.
VARID
NCVDEF or
NCVID.
NEWNAM
Here is an example using NCVREN to rename the variable rh
to rel_hum in an existing netCDF file named `foo.nc':
INCLUDE 'netcdf.inc'
...
INTEGER NCID, RCODE
INTEGER RHID ! variable ID
...
NCID = NCOPN ('foo.nc', NCWRITE, RCODE)
...
CALL NCREDF (CDFFID, RCODE) ! enter definition mode
RHID = NCVID (NCID, 'rh', RCODE) ! get ID
CALL NCVREN (NCID, RHID, 'rel_hum', RCODE)
CALL NCENDF (CDFFID, RCODE) ! leave definition mode
Go to the previous, next section.