Next: , Previous: NF_INQ_TYPEIDS, Up: User Defined Data Types


5.3 Learn About a User Defined Type: NF_INQ_TYPE

Given an ncid and a typeid, get the information about a type. This function will work on any type, including atomic and any user defined type, whether compound, opaque, enumeration, or variable length array.

For even more information about a user defined type NF_INQ_USER_TYPE.

Usage

     INTEGER FUNCTION NF_INQ_TYPE(INTEGER NCID, INTEGER XTYPE, CHARACTER*(*) NAME, INTEGER SIZE)
NCID
The ncid for the group containing the type (ignored for atomic types).
XTYPE
The typeid for this type, as returned by NF_DEF_COMPOUND, NF_DEF_OPAQUE, NF_DEF_ENUM, NF_DEF_VLEN, or NF_INQ_VAR, or as found in netcdf.inc in the list of atomic types (NF_CHAR, NF_INT, etc.).
NAME
The name of the user defined type will be copied here. It will be NF_MAX_NAME bytes or less. For atomic types, the type name from CDL will be given.
SIZEP
The size of the type (in bytes) will be copied here. VLEN type size is the size of one element of the VLEN. String size is returned as zero, since it varies from string to string.

Return Codes

NF_NOERR
No error.
NF_EBADTYPEID
Bad typeid.
NF_ENOTNC4
Seeking a user-defined type in a netCDF-3 file.
NF_ESTRICTNC3
Seeking a user-defined type in a netCDF-4 file for which classic model has been turned on.
NF_EBADGRPID
Bad group ID in ncid.
NF_EBADID
Type ID not found.
NF_EHDFERR
An error was reported by the HDF5 layer.

Example

This example is from the test program nf_test/ftst_vars3.F, and it uses all the possible inquiry functions on an enum type.

     C     Check the enum type.
           retval = NF_INQ_TYPEIDS(ncid, num_types, typeids)
           if (retval .ne. nf_noerr) call handle_err(retval)
           if (num_types .ne. MAX_TYPES) stop 2
           retval = nf_inq_enum(ncid, typeids(1), type_name, base_type,
          &     base_size, num_members)
           if (retval .ne. nf_noerr) call handle_err(retval)
           if (base_type .ne. NF_INT .or. num_members .ne. 2) stop 2
           retval = nf_inq_enum_member(ncid, typeids(1), 1, member_name,
          &     member_value)
           if (retval .ne. nf_noerr) call handle_err(retval)
           if (member_name(1:len(one_name)) .ne. one_name) stop 2