CFIO_GetCharAtt Subroutine

public subroutine CFIO_GetCharAtt(fid, name, count, buf, rc)

CFIO_GetCharAtt – Read a user-defined character attribute

This routine allows the user to read a character attribute from an open CFIO file.

History

  • 1998.07.30 Lucchesi Initial interface design.
  • 1998.07.30 Lucchesi Initial coding.
  • 1998.09.29 Lucchesi Changed error handling.

Arguments

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


Calls

proc~~cfio_getcharatt~~CallsGraph proc~cfio_getcharatt CFIO_GetCharAtt nf90_get_att nf90_get_att proc~cfio_getcharatt->nf90_get_att nf90_inquire_attribute nf90_inquire_attribute proc~cfio_getcharatt->nf90_inquire_attribute proc~err err proc~cfio_getcharatt->proc~err

Called by

proc~~cfio_getcharatt~~CalledByGraph proc~cfio_getcharatt CFIO_GetCharAtt proc~esmf_cfiosdffileopen ESMF_CFIOSdfFileOpen proc~esmf_cfiosdffileopen->proc~cfio_getcharatt 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_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