CFIO_GetAttNames Subroutine

public subroutine CFIO_GetAttNames(fid, ngatts, aname, rc)

CFIO_GetAttNames – Get global attribute names

This routine allows the user to get the names of global attributes.

History

  • 1998.08.05 Lucchesi Initial interface design.
  • 1998.08.05 Lucchesi Initial coding.
  • 1998.09.24 Lucchesi Changed error handling.

Arguments

Type IntentOptional 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


Calls

proc~~cfio_getattnames~~CallsGraph proc~cfio_getattnames CFIO_GetAttNames nf90_inq_attname nf90_inq_attname proc~cfio_getattnames->nf90_inq_attname nf90_inquire nf90_inquire proc~cfio_getattnames->nf90_inquire proc~err err proc~cfio_getattnames->proc~err

Called by

proc~~cfio_getattnames~~CalledByGraph proc~cfio_getattnames CFIO_GetAttNames proc~esmf_cfiosdffileopen ESMF_CFIOSdfFileOpen proc~esmf_cfiosdffileopen->proc~cfio_getattnames proc~esmf_cfiofileopen ESMF_CFIOFileOpen proc~esmf_cfiofileopen->proc~esmf_cfiosdffileopen none~find~4 CFIOCollection%find none~find~4->proc~esmf_cfiofileopen proc~mapl_cfioopenwrite MAPL_CFIOOpenWrite proc~mapl_cfioopenwrite->proc~esmf_cfiofileopen program~test~11 test program~test~11->proc~esmf_cfiofileopen program~test~2 test program~test~2->proc~esmf_cfiofileopen program~test~4 test program~test~4->proc~esmf_cfiofileopen program~test~6 test program~test~6->proc~esmf_cfiofileopen proc~mapl_cfiocreatefromfile MAPL_CFIOCreateFromFile proc~mapl_cfiocreatefromfile->none~find~4 proc~mapl_cfioreadbundleread MAPL_CFIOReadBundleRead proc~mapl_cfioreadbundleread->none~find~4

Source Code

      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