CFIO_PutIntAtt
– Write a user-defined integer attribute
This routine allows the user to define an integer attribute in an open CFIO file.
Type | Intent | Optional | 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) |
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