Next: , Previous: NF_COPY_ATT, Up: Attributes


5.7 NF_RENAME_ATT

The function NF_RENAME_ATT changes the name of an attribute. If the new name is longer than the original name, the netCDF dataset must be in define mode. You cannot rename an attribute to have the same name as another attribute of the same variable.

Usage

     INTEGER FUNCTION NF_RENAME_ATT (INTEGER NCID, INTEGER VARID,
                                     CHARACTER*(*) NAME,
                                     CHARACTER*(*) NEWNAME)
NCID
NetCDF ID, from a previous call to NF_OPEN or NF_CREATE
VARID
ID of the attribute's variable, or NF_GLOBAL for a global attribute
NAME
The current attribute name.
NEWNAME
The new name to be assigned to the specified attribute. If the new name is longer than the current name, the netCDF dataset must be in define mode.

Errors

NF_RENAME_ATT returns the value NF_NOERR if no errors occurred. Otherwise, the returned status indicates an error. Possible causes of errors include:

Example

Here is an example using NF_RENAME_ATT to rename the variable attribute units to Units for a variable rh in an existing netCDF dataset named foo.nc:

     INCLUDE "netcdf.inc"
        ...
     INTEGER STATUS   ! error status
     INTEGER NCID     ! netCDF ID
     INTEGER RHID     ! variable ID
        ...
     STATUS = NF_OPEN ("foo.nc", NF_NOWRITE, NCID)
     IF (STATUS .NE. NF_NOERR) CALL HANDLE_ERR(STATUS)
        ...
     STATUS = NF_INQ_VARID (NCID, "rh", RHID)
     IF (STATUS .NE. NF_NOERR) CALL HANDLE_ERR(STATUS)
        ...
     ! rename attribute
     STATUS = NF_RENAME_ATT (NCID, RHID, "units", "Units")
     IF (STATUS .NE. NF_NOERR) CALL HANDLE_ERR(STATUS)