4.5 NF90_RENAME_DIM
The function NF90_RENAME_DIM renames an existing dimension in a netCDF
dataset open for writing. If the new name is longer than the old name,
the netCDF dataset must be in define mode. You cannot rename a
dimension to have the same name as another dimension.
Usage
function nf90_rename_dim(ncid, dimid, name)
integer, intent( in) :: ncid
character (len = *), intent( in) :: name
integer, intent( in) :: dimid
integer :: nf90_rename_dim
ncid- NetCDF ID, from a previous call to NF90_OPEN or NF90_CREATE.
dimid- Dimension ID, from a previous call to NF90_INQ_DIMID or NF90_DEF_DIM.
name- New dimension name.
Errors
NF90_RENAME_DIM returns the value NF90_NOERR if no errors
occurred. Otherwise, the returned status indicates an error. Possible
causes of errors include:
- The new name is the name of another dimension.
- The dimension ID is invalid for the specified netCDF dataset.
- The specified netCDF ID does not refer to an open netCDF dataset.
- The new name is longer than the old name and the netCDF dataset is not
in define mode.
Example
Here is an example using NF90_RENAME_DIM to rename the dimension lat to
latitude in an existing netCDF dataset named foo.nc:
use netcdf
implicit none
integer :: ncid, status, LatDimID
...
status = nf90_open("foo.nc", nf90_write, ncid)
if (status /= nf90_noerr) call handle_err(status)
...
! Put in define mode so we can rename the dimension
status = nf90_redef(ncid)
if (status /= nf90_noerr) call handle_err(status)
! Get the dimension ID for "Lat"...
status = nf90_inq_dimid(ncid, "Lat", LatDimID)
if (status /= nf90_noerr) call handle_err(status)
! ... and change the name to "Latitude".
status = nf90_rename_dim(ncid, LatDimID, "Latitude")
if (status /= nf90_noerr) call handle_err(status)
! Leave define mode
status = nf90_enddef(ncid)
if (status /= nf90_noerr) call handle_err(status)