Go to the previous, next section.
The function ncattrename
(or NCAREN
for FORTRAN) changes the
name of an attribute. If the new name is longer than the original name,
the netCDF must be in define mode. You cannot rename an attribute to
have the same name as another attribute of the same variable.
In case of an error, ncattrename
returns -1; NCAREN
returns a
nonzero value in rcode
. Possible causes of errors include:
int ncattrename (int ncid, int varid, const char* name, const char* newname);
ncid
ncopen
or nccreate
varid
NC_GLOBAL
for a
global attribute
name
newname
Here is an example using ncattrename
to rename the variable
attribute units
to Units
for a variable 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"); ... /* rename attribute */ ncattrename(ncid, rh_id, "units", "Units");
SUBROUTINE NCAREN (INTEGER NCID, INTEGER VARID, + CHARACTER*(*) ATTNAM, + CHARACTER*(*) NEWNAM, INTEGER RCODE)
NCID
NCOPN
or NCCRE
VARID
NCGLOBAL
for a
global attribute
ATTNAM
NEWNAM
RCODE
Here is an example using NCAREN
to rename the variable
attribute units
to Units
for a variable rh
in an existing netCDF file named `foo.nc':
INCLUDE "netcdf.inc" ... INTEGER NCID ! netCDF ID INTEGER RHID ! variable ID ... NCID = NCOPN ("foo.nc", NCNOWRIT, RCODE) ... RHID = NCVID (NCID, "rh", RCODE) ... * rename attribute CALL NCAREN (NCID, RHID, "units", "Units", RCODE)
Go to the previous, next section.