Go to the previous, next section.
The function ncdimrename
(or NCDREN
for FORTRAN) renames
an existing dimension in a netCDF file open for writing. If the new name is
longer than the old name, the netCDF must be in define mode. You cannot
rename a dimension to have the same name as another dimension.
In case of an error, ncdimrename
returns -1; NCDREN
returns a
nonzero value in rcode
. Possible causes of errors include:
int ncdimrename(int ncid, int dimid, const char* name);
ncid
ncopen
or nccreate
.
dimid
ncdimid
or ncdimdef
.
name
Here is an example using ncdimrename
to rename the dimension
lat
to latitude
in an existing netCDF file named `foo.nc':
#include "netcdf.h" ... int ncid, latid; ... ncid = ncopen("foo.nc", NC_WRITE); /* open for writing */ ... ncredef(ncid); /* put in define mode to rename dimension */ latid = ncdimid(ncid, "lat"); ncdimrename(ncid, latid, "latitude"); ncendef(ncid); /* leave define mode */
SUBROUTINE NCDREN (INTEGER NCID, INTEGER DIMID, + CHARACTER*(*) DIMNAME, INTEGER RCODE)
NCID
NCOPN
or NCCRE
.
DIMID
NCDID
or
NCDDEF
.
DIMNAM
RCODE
Here is an example using NCDREN
to rename the dimension
"lat" to "latitude" in an existing netCDF file named `foo.nc':
INCLUDE 'netcdf.inc' ... INTEGER NCID, RCODE, LATID ... NCID = NCOPN('foo.nc', NCWRITE, RCODE) ... * put in define mode to rename dimension CALL NCREDF(NCID, RCODE) LATID = NCDID(NCID, 'lat', RCODE) CALL NCDREN(NCID, LATID, 'latitude', RCODE) * leave define mode CALL NCENDF(NCID, RCODE)
Go to the previous, next section.