CFIO_AttInquire
– Get information about an attribute
This routine allows the user to get information about a global attribute of an open CFIO file. This is most useful for determining the number of values stored in an attribute.
@note Note The returned integer “type” for 64-bit integer is not supported in the current implementation of netCDF/HDF. When a user writes a 64-bit integer attribute using PutIntAtt, it is actually saved as a 64-bit real by the HDF library. Thus, upon reading the attribute, there is no way for HDF/CFIO to distinguish it from a REAL number. The user must realize this variable is really an integer and call GetIntAtt to read it. Even for a 64-bit integer, type=4 will never be returned unless there are changed to HDF/netCDF.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer | :: | fid |
File handle |
|||
character(len=*) | :: | name |
Name of attribute |
|||
integer | :: | type |
Code for attribute type 0 = integer 1 = real 2 = character 3 = 64-bit real 4 = 64-bit integer -1 = other |
|||
integer | :: | count |
Number of items (length of array) |
|||
integer | :: | rc |
Error return code: rc = 0 all is well NetCDF Errors rc = -58 error from NF90_INQUIRE_ATTRIBUTE |
subroutine CFIO_AttInquire ( fid, name, type, count, rc ) ! ! !USES: ! Implicit NONE ! ! !INPUT PARAMETERS: ! integer fid !! File handle character(len=*) name !! Name of attribute ! ! !OUTPUT PARAMETERS: ! integer type !! Code for attribute type !! 0 = integer !! 1 = real !! 2 = character !! 3 = 64-bit real !! 4 = 64-bit integer !! -1 = other integer count !! Number of items (length of array) integer rc !! Error return code: !! rc = 0 all is well !! !! NetCDF Errors !! ------------- !! rc = -58 error from NF90_INQUIRE_ATTRIBUTE ! !------------------------------------------------------------------------- integer nctype rc = NF90_INQUIRE_ATTRIBUTE (fid, NF90_GLOBAL, name, nctype, count) if (err("AttInquire: error reading attribute info",rc,-58) & .NE. 0) return if (nctype .EQ. NF90_INT) then type = 0 elseif (nctype .EQ. NF90_FLOAT) then type = 1 elseif (nctype .EQ. NCCHAR) then type = 2 elseif (nctype .EQ. NF90_DOUBLE) then type = 3 else type = -1 endif rc = 0 return end subroutine CFIO_AttInquire