test_main Subroutine

subroutine test_main()

Arguments

None

Calls

proc~~test_main~~CallsGraph proc~test_main test_main ESMF_CalendarSetDefault ESMF_CalendarSetDefault proc~test_main->ESMF_CalendarSetDefault ESMF_Finalize ESMF_Finalize proc~test_main->ESMF_Finalize ESMF_Initialize ESMF_Initialize proc~test_main->ESMF_Initialize ESMF_TimeSet ESMF_TimeSet proc~test_main->ESMF_TimeSet ESMF_VMGetGlobal ESMF_VMGetGlobal proc~test_main->ESMF_VMGetGlobal interface~esmf_ioread ESMF_ioRead proc~test_main->interface~esmf_ioread interface~mapl_am_i_root MAPL_Am_I_Root proc~test_main->interface~mapl_am_i_root mapl_verify mapl_verify proc~test_main->mapl_verify proc~mapl_gridget MAPL_GridGet proc~test_main->proc~mapl_gridget proc~mygridcreate_ MyGridCreate_ proc~test_main->proc~mygridcreate_ ESMF_AttributeGet ESMF_AttributeGet proc~mapl_gridget->ESMF_AttributeGet ESMF_DistGridGet ESMF_DistGridGet proc~mapl_gridget->ESMF_DistGridGet ESMF_GridGet ESMF_GridGet proc~mapl_gridget->ESMF_GridGet proc~mapl_distgridget MAPL_DistGridGet proc~mapl_gridget->proc~mapl_distgridget proc~mapl_getimsjms MAPL_GetImsJms proc~mapl_gridget->proc~mapl_getimsjms proc~mapl_gridhasde MAPL_GridHasDE proc~mapl_gridget->proc~mapl_gridhasde proc~mapl_return MAPL_Return proc~mapl_gridget->proc~mapl_return proc~mapl_verify MAPL_Verify proc~mapl_gridget->proc~mapl_verify proc~mygridcreate_->interface~mapl_am_i_root proc~mygridcreate_->mapl_verify ESMF_DELayoutCreate ESMF_DELayoutCreate proc~mygridcreate_->ESMF_DELayoutCreate esmf_gridaddvertheight esmf_gridaddvertheight proc~mygridcreate_->esmf_gridaddvertheight esmf_gridcreatehorzlatlonuni esmf_gridcreatehorzlatlonuni proc~mygridcreate_->esmf_gridcreatehorzlatlonuni esmf_griddistribute esmf_griddistribute proc~mygridcreate_->esmf_griddistribute mapl_get_local_dims mapl_get_local_dims proc~mygridcreate_->mapl_get_local_dims mapl_return mapl_return proc~mygridcreate_->mapl_return proc~mapl_gridgetlatlons MAPL_GridGetLatLons proc~mygridcreate_->proc~mapl_gridgetlatlons

Called by

proc~~test_main~~CalledByGraph proc~test_main test_main program~utcfio utCFIO program~utcfio->proc~test_main

Source Code

    subroutine test_main()

!   Initialize framework
!   --------------------
    call ESMF_Initialize (vm=vm, rc=status)
    _VERIFY(status)

    IamRoot = MAPL_am_I_root()

!   Get the global vm
!   -----------------
    call ESMF_VMGetGlobal(vm, rc=status)
    _VERIFY(status)

!   Create a grid
!   -------------
    call MyGridCreate_ ( vm, grid2d, grid3d, rc=status )
    _VERIFY(status)

!   Set the time as the one on the hardwired file name
!   --------------------------------------------------
    call ESMF_CalendarSetDefault ( ESMF_CALKIND_GREGORIAN, rc=status )
    _VERIFY(STATUS)
    call ESMF_TimeSet(Time2,  yy=2001, mm=1, dd=1,  h=0,  m=0, s=0, rc=status )
    _VERIFY(STATUS)
    call ESMF_TimeSet(Time3,  yy=2001, mm=1, dd=14, h=12, m=0, s=0, rc=status )
    _VERIFY(STATUS)
    call ESMF_TimeSet(Time2a, yy=2001, mm=3, dd=1,  h=12, m=0, s=0, rc=status )
    _VERIFY(STATUS)
    call ESMF_TimeSet(Times,  yy=1971, mm=6, dd=5,  h=0, m=0, s=0, rc=status )
    _VERIFY(STATUS)

!   Get Local dimensions
!   --------------------
    call MAPL_GridGet ( GRID3D, &
                        localCellCountPerDim=DIMS,RC=STATUS)
    _VERIFY(STATUS)

!   Allocate arrays
!   ---------------
    im = dims(1);   jm = dims(2);   km = dims(3)
    allocate( emcoterp(im,jm), emconvoc(im,jm), &
              oh(im,jm,km), ch4(im,jm,km), &
              stat=STATUS ) 
    _VERIFY(STATUS)

!   Read 2D arrays from file
!   ------------------------
!    if ( IamRoot ) print *, 'Reading ' // fFilename
    call ESMF_ioRead  ( 'du_src', src_Filename, Times, grid3d, emcoterp,  &
                        verbose=.true., force_regrid=.true.,                &
                        time_is_cyclic = .true., rc=STATUS                  )
    _VERIFY(STATUS)
    call ESMF_ioRead  ( 'emcoterp', f2d_Filename, Time2, grid3d, emcoterp,  &
                        verbose=.true., force_regrid=.true.,                &
                        time_is_cyclic = .true., rc=STATUS                  )
    _VERIFY(STATUS)
    call ESMF_ioRead  ( 'emconvoc', f2d_Filename, Time2, grid3d, emconvoc,  &
                        verbose=.true., force_regrid=.true.,                &
                        time_is_cyclic = .true., rc=STATUS                  )
    _VERIFY(STATUS)
    call ESMF_ioRead  ( 'OH',       f3d_Filename, Time3, grid3d, oh,        &
                        verbose=.true., force_regrid=.true., rc=STATUS      )
    _VERIFY(STATUS)
    call ESMF_ioRead  ( 'CH4',       f3d_Filename, Time3, grid3d, ch4,      &
                        verbose=.true., force_regrid=.true., rc=STATUS      )
    _VERIFY(STATUS)

    if ( IamRoot ) print *, 'Re-reading w/ time interpolation...'
    call ESMF_ioRead  ( 'emconvoc', f2d_Filename, Time2a, grid3d, emconvoc, &
                        verbose=.true., force_regrid=.true.,                &
                        time_is_cyclic = .true., time_interp=.true.,        &
                        rc=STATUS                  )
    _VERIFY(STATUS)

    deallocate(oh,ch4,emconvoc)

    allocate( xa(im,jm,km), xb(im,jm,km), xc(im,jm,km), &
              xm(im,jm,km), xe(im,jm,km),               &
              stat=STATUS ) 
    _VERIFY(STATUS)

    print *

!   Testing time interpolation
!   --------------------------
    call ESMF_TimeSet(Time3a, yy=2001, mm=3, dd=16, h=12, m=0, s=0, rc=status )
    call ESMF_TimeSet(Time3b, yy=2001, mm=3, dd=31, h=18, m=0, s=0, rc=status )
    call ESMF_TimeSet(Time3c, yy=2001, mm=4, dd=16, h= 0, m=0, s=0, rc=status )

    call ESMF_ioRead  ( 'CH4',       f3d_Filename, Time3a, grid3d, xa,      &
                        verbose=.true., force_regrid=.true.,                &
                        time_interp = .true.,                               &
                        rc=STATUS      )
    _VERIFY(STATUS)

    call ESMF_ioRead  ( 'CH4',       f3d_Filename, Time3b, grid3d, xb,      &
                        verbose=.true., force_regrid=.true., rc=STATUS,     &
                        time_interp = .true.                                )
    _VERIFY(STATUS)
    call ESMF_ioRead  ( 'CH4',       f3d_Filename, Time3c, grid3d, xc,      &
                        verbose=.true., force_regrid=.true., rc=STATUS,     &
                        time_interp = .true.                                )
    _VERIFY(STATUS)

    xm = ( xa + xc ) / 2.
    xe = abs ( xb  - xm )

    n = im * jm

    i = im/2

    if ( IamRoot ) then

         print *
         print *, 'Time interpolation stats: '
         print *
      do j = 1, jm, jm/4
         print *, 'Lat = ', lats(j)
         print *, 'CH4 at time a: ', (xa(i,j,k), k=1,km,km/4)
         print *, 'CH4 at time b: ', (xb(i,j,k), k=1,km,km/4)
         print *, 'CH4 m e a n  : ', (xm(i,j,k), k=1,km,km/4)
         print *, 'CH4 at time c: ', (xc(i,j,k), k=1,km,km/4)
         print *, 'CH4 e r r o r: ', (xe(i,j,k), k=1,km,km/4)
         print *
      end do

      print *, 'CH4 RMS error: ', sqrt(sum(xe*xe)/n)

    endif

!   All done
!   --------
    call ESMF_Finalize ( rc=status )
    _VERIFY(STATUS)
    
  end subroutine test_main