CFIO_GetAttNames
– Get global attribute names
This routine allows the user to get the names of global attributes.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer | :: | fid |
File handle |
|||
integer | :: | ngatts |
Expected number of attributes (input) Actual number of attributes (output if rc=-2) |
|||
character(len=*) | :: | aname(ngatts) |
Array of attribute names |
|||
integer | :: | rc |
Error return code: rc = 0 all is well rc = -10 ngatts is incompatible with file rc = -11 character string not long enough NetCDF Errors rc = -48 error from NF90_INQUIRE rc = -57 error from NF90_INQ_ATTNAME |
subroutine CFIO_GetAttNames ( fid, ngatts, aname, rc ) ! ! !USES: ! Implicit NONE ! ! !INPUT PARAMETERS: ! integer fid !! File handle ! ! !INPUT/OUTPUT PARAMETERS: ! integer ngatts !! Expected number of attributes (input) !! Actual number of attributes (output if rc=-2) ! ! !OUTPUT PARAMETERS: ! character(len=*) aname(ngatts) !! Array of attribute names integer rc !! Error return code: !! rc = 0 all is well !! rc = -10 ngatts is incompatible with file !! rc = -11 character string not long enough !! !! NetCDF Errors !! ------------- !! rc = -48 error from NF90_INQUIRE !! rc = -57 error from NF90_INQ_ATTNAME ! !------------------------------------------------------------------------- integer ngattsFile, i integer nDims,dimSize,recDim ! Check number of attributes against file rc = NF90_INQUIRE (fid,nDims,dimSize,ngattsFile,recdim) if (err("GetAttNames: NF90_INQUIRE failed",rc,-48) .NE. 0) return if (ngattsFile .NE. ngatts) then rc = -10 ngatts = ngattsFile return endif ! Check length of aname string if (LEN(aname(1)) .lt. MAXNCNAM) then print *,'CFIO_GetAttNames: length of aname array must be at ', & 'least ',MAXNCNAM,' bytes.' rc = -11 return endif ! Read global attribute names do i=1,ngatts rc = NF90_INQ_ATTNAME(fid,NF90_GLOBAL,i,aname(i)) if (err("GetAttNames: error reading attribute name",rc,-57) & .NE. 0) return enddo rc = 0 return end subroutine CFIO_GetAttNames