CFIO_GetCharAtt
– Read a user-defined character attribute
This routine allows the user to read a character attribute from an open CFIO file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer | :: | fid |
File handle |
|||
character(len=*) | :: | name |
Name of attribute |
|||
integer | :: | count |
On input: Number of items in attribute On output: If rc = -1, count will contain the correct number of attributes |
|||
character(len=1) | :: | buf(count) |
Buffer with character values |
|||
integer | :: | rc |
Error return code: rc = 0 all is well rc = -1 invalid count rc = -2 type mismatch NetCDF Errors rc = -36 error from NF90_PUT_ATT (global attribute) rc = -51 error from NF90_GET_ATT (global attribute) |
subroutine CFIO_GetCharAtt ( fid, name, count, buf, rc ) ! ! !USES: ! Implicit NONE ! ! !INPUT PARAMETERS: ! integer fid !! File handle character(len=*) name !! Name of attribute ! ! !INPUT/OUTPUT PARAMETERS: ! integer count !! On input: Number of items in attribute !! On output: If rc = -1, count will contain !! the correct number of attributes ! ! !OUTPUT PARAMETERS: ! character :: buf(count) !! Buffer with character values ! character(len=MLEN) :: buf !! Buffer with character values integer rc !! Error return code: !! rc = 0 all is well !! rc = -1 invalid count !! rc = -2 type mismatch !! !! NetCDF Errors !! ------------- !! rc = -36 error from NF90_PUT_ATT (global attribute) !! rc = -51 error from NF90_GET_ATT (global attribute) ! !------------------------------------------------------------------------- integer length, type character(len=count) :: chartmp rc = NF90_INQUIRE_ATTRIBUTE (fid, NF90_GLOBAL, name, type, length) if (err("GetCharAtt: error reading attribute info",rc,-58) & .NE. 0) return if ( count .NE. length ) then rc = -1 count = length return endif if ( type .NE. NCCHAR) then rc = -2 return endif rc = NF90_GET_ATT(fid,NF90_GLOBAL,name,chartmp) if (err("GetCharAtt: error reading attribute value",rc,-51) & .NE. 0) return buf = chartmp rc = 0 return end subroutine CFIO_GetCharAtt