Unidata - To provide the data services, tools, and cyberinfrastructure leadership that advance Earth system science, enhance educational opportunities, and broaden participation. Unidata
         
  advanced  
 

Next: , Previous: Fill Values, Up: Variables



6.26 NF_RENAME_VAR

The function NF_RENAME_VAR changes the name of a netCDF variable in an open netCDF dataset. If the new name is longer than the old name, the netCDF dataset must be in define mode. You cannot rename a variable to have the name of any existing variable.

Usage

     INTEGER FUNCTION NF_RENAME_VAR (INTEGER NCID, INTEGER VARID,
                                     CHARACTER*(*) NEWNAM)
NCID
NetCDF ID, from a previous call to NF_OPEN or NF_CREATE.
VARID
Variable ID.
NAME
New name for the specified variable.

Errors

NF_RENAME_VAR 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_VAR to rename the variable rh to rel_hum in an existing netCDF dataset named foo.nc:

     INCLUDE 'netcdf.inc'
        ...
     INTEGER  STATUS, NCID
     INTEGER  RHID             ! variable ID
        ...
     STATUS = NF_OPEN ('foo.nc', NF_WRITE, NCID)
     IF (STATUS .NE. NF_NOERR) CALL HANDLE_ERR(STATUS)
        ...
     STATUS = NF_REDEF (NCID)  ! enter definition mode
     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)
     STATUS = NF_RENAME_VAR (NCID, RHID, 'rel_hum')
     IF (STATUS .NE. NF_NOERR) CALL HANDLE_ERR(STATUS)
     STATUS = NC_ENDDEF (NCID) ! leave definition mode
     IF (STATUS .NE. NF_NOERR) CALL HANDLE_ERR(STATUS)
 
 
  Contact Us     Site Map     Search     Terms and Conditions     Privacy Policy     Participation Policy
 
National Science Foundation (NSF) UCAR Office of Programs University Corporation for Atmospheric Research (UCAR)   Unidata is a member of the UCAR Office of Programs, is managed by the University Corporation for Atmospheric Research, and is sponsored by the National Science Foundation.
P.O. Box 3000     Boulder, CO 80307-3000 USA     Tel: 303-497-8643     Fax: 303-497-8690