4.2 NF_DEF_DIM
The function NF_DEF_DIM adds a new dimension to an open netCDF dataset
in define mode. It returns (as an argument) a dimension ID, given the
netCDF ID, the dimension name, and the dimension length. At most one
unlimited length dimension, called the record dimension, may be
defined for each netCDF dataset.
Usage
INTEGER FUNCTION NF_DEF_DIM (INTEGER NCID, CHARACTER*(*) NAME,
INTEGER LEN, INTEGER dimid)
NCID- NetCDF ID, from a previous call to NF_OPEN or NF_CREATE.
NAME- Dimension name. Must begin with an alphabetic character, followed by
zero or more alphanumeric characters including the underscore
('_'). Case is significant.
LEN- Length of dimension; that is, number of values for this dimension as
an index to variables that use it. This should be either a positive
integer or the predefined constant NF_UNLIMITED.
dimid- Returned dimension ID.
Errors
NF_DEF_DIM returns the value NF_NOERR if no errors
occurred. Otherwise, the returned status indicates an error. Possible
causes of errors include:
- The netCDF dataset is not in definition mode.
- The specified dimension name is the name of another existing
dimension.
- The specified length is not greater than zero.
- The specified length is unlimited, but there is already an unlimited
length dimension defined for this netCDF dataset.
- The specified netCDF ID does not refer to an open netCDF dataset.
Example
Here is an example using NF_DEF_DIM to create a dimension named lat of
length 18 and a unlimited dimension named rec in a new netCDF dataset
named foo.nc:
INCLUDE 'netcdf.inc'
...
INTEGER STATUS, NCID, LATID, RECID
...
STATUS = NF_CREATE('foo.nc', NF_NOCLOBBER, NCID)
IF (STATUS .NE. NF_NOERR) CALL HANDLE_ERR(STATUS)
...
STATUS = NF_DEF_DIM(NCID, 'lat', 18, LATID)
IF (STATUS .NE. NF_NOERR) CALL HANDLE_ERR(STATUS)
STATUS = NF_DEF_DIM(NCID, 'rec', NF_UNLIMITED, RECID)
IF (STATUS .NE. NF_NOERR) CALL HANDLE_ERR(STATUS)