CFIO_PutRealAtt
– Write a user-defined real attribute
This routine allows the user to define a real 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 |
|||
real | :: | buf(count) |
Buffer with real 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_PutRealAtt ( 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 real buf(count) !! Buffer with real 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) ! !------------------------------------------------------------------------- real(kind=REAL32) dummy32 real(kind=REAL64) dummy64 real r integer i real(kind=REAL32), allocatable :: buf32(:) real(kind=REAL64), allocatable :: buf64(:) rc = NF90_REDEF ( fid ) if (err("PutRealAtt: could not enter define mode",rc,-55) .NE. 0) & return if (HUGE(dummy32) .EQ. HUGE(r) .AND. prec .EQ. 0) then ! -r4 rc = NF90_PUT_ATT ( fid, NF90_GLOBAL, name, buf ) ! 32-bit out else if (HUGE(dummy32) .EQ. HUGE(r) .AND. prec .EQ. 1) then ! -r4 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(r) .AND. prec .EQ. 0) then ! -r8 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(r) .AND. prec .EQ. 1) then ! -r8 rc = NF90_PUT_ATT ( fid, NF90_GLOBAL, name, buf ) ! 64-bit out else rc = -12 return endif if (err("PutRealAtt: error writing attribute",rc,-36) .NE. 0) & return rc = NF90_ENDDEF(fid) if (err("PutRealAtt: could not exit define mode",rc,-56) .NE. 0) & return rc = 0 return end subroutine CFIO_PutRealAtt