5.5.4 Learn About a Compound Type: NF_INQ_COMPOUND
Get the number of fields, length in bytes, and name of a compound
type.
In addtion to the NF_INQ_COMPOUND function, three additional functions
are provided which get only the name, size, and number of fields.
Usage
INTEGER FUNCTION NF_INQ_COMPOUND(INTEGER NCID, INTEGER XTYPE,
CHARACTER*(*) NAME, INTEGER SIZEP, INTEGER NFIELDSP)
INTEGER FUNCTION NF_INQ_COMPOUND_NAME(INTEGER NCID, INTEGER XTYPE,
CHARACTER*(*) NAME)
INTEGER FUNCTION NF_INQ_COMPOUND_SIZE(INTEGER NCID, INTEGER XTYPE,
INTEGER SIZEP)
INTEGER FUNCTION NF_INQ_COMPOUND_NFIELDS(INTEGER NCID, INTEGER XTYPE,
INTEGER NFIELDSP)
NCID- The ID of any group in the file that contains the compound type.
XTYPE- The typeid for this compound type, as returned by NF_DEF_COMPOUND, or
NF_INQ_VAR.
NAME- Character array which will get the name of the compound type. It will
have a maximum length of NF_MAX_NAME.
SIZEP- The size of the compound type in bytes will be put here.
NFIELDSP- The number of fields in the compound type will be placed here.
Return Codes
NF_NOERR- No error.
NF_EBADID- Couldn't find this ncid.
NF_ENOTNC4- Not a netCDF-4/HDF5 file.
NF_ESTRICTNC3- A netCDF-4/HDF5 file, but with CLASSIC_MODEL. No user defined types
are allowed in the classic model.
NF_EBADTYPE- This type not a compound type.
NF_EBADTYPEID- Bad type id.
NF_EHDFERR- An error was reported by the HDF5 layer.
Example
This example is from nf_test/ftst_types.F.
C Check it differently.
retval = nf_inq_compound(ncid, typeids(1), name_in, size_in,
& nfields_in)
if (retval .ne. nf_noerr) call handle_err(retval)
if (name_in(1:len(type_name)) .ne. type_name .or.
& size_in .ne. WIND_T_SIZE .or. nfields_in .ne. 2) stop 2
C Check it one piece at a time.
retval = nf_inq_compound_nfields(ncid, typeids(1), nfields_in)
if (retval .ne. nf_noerr) call handle_err(retval)
if (nfields_in .ne. 2) stop 2
retval = nf_inq_compound_size(ncid, typeids(1), size_in)
if (retval .ne. nf_noerr) call handle_err(retval)
if (size_in .ne. WIND_T_SIZE) stop 2
retval = nf_inq_compound_name(ncid, typeids(1), name_in)
if (retval .ne. nf_noerr) call handle_err(retval)
if (name_in(1:len(type_name)) .ne. type_name) stop 2