utDownBit Program

Uses

  • program~~utdownbit~~UsesGraph program~utdownbit utDownBit module~esmf_cfiomod ESMF_CFIOMod program~utdownbit->module~esmf_cfiomod ESMF ESMF module~esmf_cfiomod->ESMF iso_fortran_env iso_fortran_env module~esmf_cfiomod->iso_fortran_env module~esmf_cfiofilemod ESMF_CFIOFileMod module~esmf_cfiomod->module~esmf_cfiofilemod module~esmf_cfiogridmod ESMF_CFIOGridMod module~esmf_cfiomod->module~esmf_cfiogridmod module~esmf_cfiosdfmod ESMF_CFIOSdfMod module~esmf_cfiomod->module~esmf_cfiosdfmod module~esmf_cfioutilmod ESMF_CFIOUtilMod module~esmf_cfiomod->module~esmf_cfioutilmod module~esmf_cfiovarinfomod ESMF_CFIOVarInfoMod module~esmf_cfiomod->module~esmf_cfiovarinfomod module~esmf_cfiofilemod->module~esmf_cfiogridmod module~esmf_cfiofilemod->module~esmf_cfioutilmod module~esmf_cfiofilemod->module~esmf_cfiovarinfomod module~esmf_cfiogridmod->iso_fortran_env module~esmf_cfiogridmod->module~esmf_cfioutilmod module~esmf_cfiosdfmod->iso_fortran_env module~esmf_cfiosdfmod->module~esmf_cfiofilemod module~esmf_cfiosdfmod->module~esmf_cfiogridmod module~esmf_cfiosdfmod->module~esmf_cfioutilmod module~esmf_cfiosdfmod->module~esmf_cfiovarinfomod netcdf netcdf module~esmf_cfiosdfmod->netcdf module~esmf_cfioutilmod->iso_fortran_env ESMF_CFIOBaseMod ESMF_CFIOBaseMod module~esmf_cfioutilmod->ESMF_CFIOBaseMod module~esmf_cfioutilmod->netcdf module~esmf_cfiovarinfomod->module~esmf_cfiogridmod module~esmf_cfiovarinfomod->module~esmf_cfioutilmod

Calls

program~~utdownbit~~CallsGraph program~utdownbit utDownBit interface~esmf_cfiodownbit ESMF_CFIODownBit program~utdownbit->interface~esmf_cfiodownbit stats_ stats_ program~utdownbit->stats_

Variables

Type Attributes Name Initial
character(len=80) :: fname
character(len=80) :: ifname
integer, parameter :: im = 288
integer, parameter :: jm = 181
integer, parameter :: lu = 10
integer :: nbits
integer :: rc
real(kind=4) :: xr(im,jm)
real :: x(im,jm)
real :: xmax
real :: xmin

Source Code

     Program utDownBit

     use ESMF_CFIOMod, only: ESMF_CFIODownBit

     implicit NONE

     integer, parameter :: im = 288, jm=181, lu=10
     real :: x(im,jm),  xmin, xmax
     real*4 :: xr(im,jm)
     integer :: nbits, rc

     character(len=80) :: ifname, fname

     print *, 'Enter 2D sequential data set name: '
     read *, ifname

     open(lu,file=trim(ifname),form='unformatted')
     read(lu) x
     close(lu)

     xmin = minval(x)
     xmax = maxval(x)

     print *, 'File name: ', trim(ifname)
     print *, ' -- Min: ',xmin, ' -- Max: ',xmax, &
              ' -- Range: ', xmax-xmin

     call system ( 'mkdir -p done' )

     print *

!    Slow flops
!    ----------
     do nbits = 16, 8, -1

        call ESMF_CFIODownBit ( x, xr, nbits, 1.0E15, flops=.true., rc=rc )
        if ( rc /= 0 ) then
             print *, 'Error: rc = ', rc
             call exit(1)
        endif
  
        call stats_ ( 'Mean/max error [F]: ', &
                       nbits, xr-x, 100*(xr-x)/x, im, jm )

        write(fname,"('done/',a2,'_f',I2.2,'.bin')") ifname(1:2), nbits
        open(lu,file=trim(fname),form='unformatted')
        write(lu) xr
        close(lu)

     end do

     print *

!    Fast bit shifts
!    ---------------
     do nbits = 16, 8, -1

        call ESMF_CFIODownBit ( x, xr, nbits, 1.0E15, rc=rc )
        if ( rc /= 0 ) then
             print *, 'Error: rc = ', rc
             call exit(1)
        endif
  
  
        call stats_ ( 'Mean/max error [C]: ', &
                       nbits, xr-x, 100*(xr-x)/x, im, jm )

        write(fname,"('done/',a2,'_c',I2.2,'.bin')") ifname(1:2), nbits
        open(lu,file=trim(fname),form='unformatted')
        write(lu) xr
        close(lu)

     end do

   end Program utDownBit