Next: , Previous: NF_INQ_DIMID, Up: Dimensions


3.4 NF_INQ_DIM Family

This family of functions returns information about a netCDF dimension. Information about a dimension includes its name and its length. The length for the unlimited dimension, if any, is the number of records written so far.

The functions in this family include NF_INQ_DIM, NF_INQ_DIMNAME, and NF_INQ_DIMLEN. The function NF_INQ_DIM returns all the information about a dimension; the other functions each return just one item of information.

Usage

     INTEGER FUNCTION NF_INQ_DIM     (INTEGER NCID, INTEGER DIMID,
                                      CHARACTER*(*) name, INTEGER len)
     INTEGER FUNCTION NF_INQ_DIMNAME (INTEGER NCID, INTEGER DIMID,
                                      CHARACTER*(*) name)
     INTEGER FUNCTION NF_INQ_DIMLEN  (INTEGER NCID, INTEGER DIMID,
                                      INTEGER len)
NCID
NetCDF ID, from a previous call to NF_OPEN or NF_CREATE.
DIMID
Dimension ID, from a previous call to NF_INQ_DIMID or NF_DEF_DIM.
NAME
Returned dimension name. The caller must allocate space for the returned name. The maximum possible length, in characters, of a dimension name is given by the predefined constant NF_MAX_NAME.
len
Returned length of dimension. For the unlimited dimension, this is the current maximum value used for writing any variables with this dimension, that is the maximum record number.

Errors

These functions return 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_INQ_DIM to determine the length of a dimension named lat, and the name and current maximum length of the unlimited dimension for an existing netCDF dataset named foo.nc:

     INCLUDE 'netcdf.inc'
        ...
     INTEGER STATUS, NCID, LATID, LATLEN, RECID, NRECS
     CHARACTER*(NF_MAX_NAME) LATNAM, RECNAM
        ...
     STATUS = NF_OPEN('foo.nc', NF_NOWRITE, NCID)
     IF (STATUS .NE. NF_NOERR) CALL HANDLE_ERR(STATUS)
     ! get ID of unlimited dimension
     STATUS = NF_INQ_UNLIMDIM(NCID, RECID)
     IF (STATUS .NE. NF_NOERR) CALL HANDLE_ERR(STATUS)
        ...
     STATUS = NF_INQ_DIMID(NCID, 'lat', LATID)
     IF (STATUS .NE. NF_NOERR) CALL HANDLE_ERR(STATUS)
     ! get lat length
     STATUS = NF_INQ_DIMLEN(NCID, LATID, LATLEN)
     IF (STATUS .NE. NF_NOERR) CALL HANDLE_ERR(STATUS)
     ! get unlimited dimension name and current length
     STATUS = NF_INQ_DIM(NCID, RECID, RECNAME, NRECS)
     IF (STATUS .NE. NF_NOERR) CALL HANDLE_ERR(STATUS)