CFIO_PutIntAtt Subroutine

public subroutine CFIO_PutIntAtt(fid, name, count, buf, prec, rc)

CFIO_PutIntAtt – Write a user-defined integer attribute

This routine allows the user to define an integer attribute in an open CFIO file.

History

  • 1998.07.30 Lucchesi Initial interface design.
  • 1998.07.30 Lucchesi Initial coding.
  • 1998.09.24 Lucchesi Changed error handling.
  • 1998.09.28 Lucchesi Added support for multiple precisions

Arguments

Type IntentOptional Attributes Name
integer :: fid

File handle

character(len=*) :: name

Name of attribute

integer :: count

Number of integers to write

integer :: buf(count)

Buffer with integer values

integer :: prec

Desired precision of attribute value: 0 = 32 bit 1 = 64 bit

integer :: rc

Error return code: rc = 0 all is well rc = -12 error determining default precision

NetCDF Errors


rc = -36 error from NF90_PUT_ATT (global attribute) rc = -55 error from NF90_REDEF (enter define mode) rc = -56 error from NF90_ENDDEF (exit define mode)


Calls

proc~~cfio_putintatt~~CallsGraph proc~cfio_putintatt CFIO_PutIntAtt nf90_enddef nf90_enddef proc~cfio_putintatt->nf90_enddef nf90_put_att nf90_put_att proc~cfio_putintatt->nf90_put_att nf90_redef nf90_redef proc~cfio_putintatt->nf90_redef proc~err err proc~cfio_putintatt->proc~err

Called by

proc~~cfio_putintatt~~CalledByGraph proc~cfio_putintatt CFIO_PutIntAtt proc~esmf_cfiosdffilecreate ESMF_CFIOSdfFileCreate proc~esmf_cfiosdffilecreate->proc~cfio_putintatt proc~esmf_cfiofilecreate ESMF_CFIOFileCreate proc~esmf_cfiofilecreate->proc~esmf_cfiosdffilecreate proc~mapl_cfiocreatewrite MAPL_CFIOCreatewrite proc~mapl_cfiocreatewrite->proc~esmf_cfiofilecreate program~test~11 test program~test~11->proc~esmf_cfiofilecreate program~test~12 test program~test~12->proc~esmf_cfiofilecreate program~test~14 test program~test~14->proc~esmf_cfiofilecreate program~test~2 test program~test~2->proc~esmf_cfiofilecreate program~test~3 test program~test~3->proc~esmf_cfiofilecreate program~test~5 test program~test~5->proc~esmf_cfiofilecreate program~test~6 test program~test~6->proc~esmf_cfiofilecreate program~test~7 test program~test~7->proc~esmf_cfiofilecreate program~test~8 test program~test~8->proc~esmf_cfiofilecreate program~test~9 test program~test~9->proc~esmf_cfiofilecreate

Source Code

      subroutine CFIO_PutIntAtt ( fid, name, count, buf, prec, rc )
!
! !USES:
!
      Implicit NONE
!
! !INPUT PARAMETERS:
!
      integer        fid        !! File handle
      character(len=*)  name       !! Name of attribute
      integer        count      !! Number of integers to write
      integer        buf(count) !! Buffer with integer values
      integer        prec       !! Desired precision of attribute value:
                                !!   0 = 32 bit
                                !!   1 = 64 bit
!
! !OUTPUT PARAMETERS:
!
      integer     rc     !! Error return code:
                         !!   rc = 0    all is well
                         !!   rc = -12  error determining default precision
                         !!
                         !!  NetCDF Errors
                         !!  -------------
                         !!   rc = -36  error from NF90_PUT_ATT (global attribute)
                         !!   rc = -55  error from NF90_REDEF (enter define mode)
                         !!   rc = -56  error from NF90_ENDDEF (exit define mode)
!
!-------------------------------------------------------------------------

      integer(kind=INT32) dummy32
      integer(kind=INT64) dummy64
      integer i

      integer(kind=INT32), allocatable :: buf32(:)
      integer(kind=INT64), allocatable :: buf64(:)

      rc = NF90_REDEF ( fid )
      if (err("PutIntAtt: could not enter define mode",rc,-55) .NE. 0) &
         return

      if ( HUGE(dummy32) .EQ. HUGE(i) .AND. prec .EQ. 0 ) then     ! -i4
        rc = NF90_PUT_ATT ( fid, NF90_GLOBAL, name, buf) ! 32-bit out

      else if ( HUGE(dummy32) .EQ. HUGE(i) .AND. prec .EQ. 1 ) then  ! -i4
        allocate ( buf64(count) )                                    ! 64-bit out
        do i=1,count
          buf64(i) = buf(i)
        enddo
        rc = NF90_PUT_ATT ( fid, NF90_GLOBAL, name, buf64 )
        deallocate (buf64)

      else if  (HUGE(dummy64) .EQ. HUGE(i) .AND. prec .EQ. 0 ) then  ! -i8
        allocate ( buf32(count) )                                    ! 32-bit out
        do i=1,count
          buf32(i) = buf(i)
        enddo
        rc = NF90_PUT_ATT ( fid, NF90_GLOBAL, name, buf32 )
        deallocate (buf32)

      else if (HUGE(dummy64) .EQ. HUGE(i) .AND. prec .EQ. 1 ) then   ! -i8
        rc = NF90_PUT_ATT ( fid, NF90_GLOBAL, name, buf ) ! 64-bit out

      else
        rc = -12
        return
      endif
      if (err("PutIntAtt: error writing attribute",rc,-36) .NE. 0) &
         return

      rc = NF90_ENDDEF(fid)
      if (err("PutIntAtt: could not exit define mode",rc,-56) .NE. 0) &
         return

      rc = 0
      return
      end subroutine CFIO_PutIntAtt