Next: , Previous: NF90_INQ_DIMID, Up: Dimensions


3.4 NF90_INQUIRE_DIMENSION

This function 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.

Usage

      function nf90_inquire_dimension(ncid, dimid, name, len)
        integer,                       intent( in) :: ncid, dimid
        character (len = *), optional, intent(out) :: name
        integer,             optional, intent(out) :: len
        integer                                    :: nf90_inquire_dimension
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
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 NF90_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 NF90_NOERR if no errors occurred. Otherwise, the returned status indicates an error. Possible causes of errors include:

Example

Here is an example using NF90_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:

      use netcdf
      implicit none
      integer :: ncid, status, LatDimID, RecordDimID
      integer :: nLats, nRecords
      character(len = nf90_max_name) :: RecordDimName
      ...
      status = nf90_open("foo.nc", nf90_nowrite, ncid)
      if (status /= nf90_noerr) call handle_err(status)
      ! Get ID of unlimited dimension
      status = nf90_inquire(ncid, unlimitedDimId = RecordDimID)
      if (status /= nf90_noerr) call handle_err(status)
      ...
      status = nf90_inq_dimid(ncid, "Lat", LatDimID)
      if (status /= nf90_noerr) call handle_err(status)
      ! How many values of "lat" are there?
      status = nf90_inquire_dimension(ncid, LatDimID, len = nLats)
      if (status /= nf90_noerr) call handle_err(status)
      ! What is the name of the unlimited dimension, how many records are there?
      status = nf90_inquire_dimension(ncid, RecordDimID, &
                                      name = RecordDimName, len = Records)
      if (status /= nf90_noerr) call handle_err(status)