Next: , Previous: NF_CLOSE, Up: Datasets


2.13 NF_INQ Family

Members of the NF_INQ family of functions return information about an open netCDF dataset, given its netCDF ID. Dataset inquire functions may be called from either define mode or data mode. The first function, NF_INQ, returns values for the number of dimensions, the number of variables, the number of global attributes, and the dimension ID of the dimension defined with unlimited length, if any. The other functions in the family each return just one of these items of information.

For FORTRAN, these functions include NF_INQ, NF_INQ_NDIMS, NF_INQ_NVARS, NF_INQ_NATTS, and NF_INQ_UNLIMDIM. An additional function, NF_INQ_FORMAT, returns the (rarely needed) format version.

No I/O is performed when these functions are called, since the required information is available in memory for each open netCDF dataset.

Usage

     INTEGER FUNCTION NF_INQ          (INTEGER NCID, INTEGER ndims,
                                       INTEGER nvars,INTEGER ngatts,
                                       INTEGER unlimdimid)
     INTEGER FUNCTION NF_INQ_NDIMS    (INTEGER NCID, INTEGER ndims)
     INTEGER FUNCTION NF_INQ_NVARS    (INTEGER NCID, INTEGER nvars)
     INTEGER FUNCTION NF_INQ_NATTS    (INTEGER NCID, INTEGER ngatts)
     INTEGER FUNCTION NF_INQ_UNLIMDIM (INTEGER NCID, INTEGER unlimdimid)
     INTEGER FUNCTION NF_INQ_FORMAT   (INTEGER NCID, INTEGER format)
NCID
NetCDF ID, from a previous call to NF_OPEN or NF_CREATE.
ndims
Returned number of dimensions defined for this netCDF dataset.
nvars
Returned number of variables defined for this netCDF dataset.
ngatts
Returned number of global attributes defined for this netCDF dataset.
unlimdimid
Returned ID of the unlimited dimension, if there is one for this netCDF dataset. If no unlimited length dimension has been defined, -1 is returned.
format
Returned format version, one of NF_FORMAT_CLASSIC, NF_FORMAT_64BIT, NF_FORMAT_NETCDF4, NF_FORMAT_NETCDF4_CLASSIC.

Errors

All members of the NF_INQ family 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 to find out about a netCDF dataset named foo.nc:

     INCLUDE 'netcdf.inc'
        ...
     INTEGER STATUS, NCID, NDIMS, NVARS, NGATTS, UNLIMDIMID
        ...
     STATUS = NF_OPEN('foo.nc', NF_NOWRITE, NCID)
     IF (STATUS .NE. NF_NOERR) CALL HANDLE_ERR(STATUS)
        ...
     STATUS = NF_INQ(NCID, NDIMS, NVARS, NGATTS, UNLIMDIMID)
     IF (STATUS .NE. NF_NOERR) CALL HANDLE_ERR(STATUS)