test_main Subroutine

public subroutine test_main(this)

Arguments

Type IntentOptional Attributes Name
class(ESMF_TestMethod), intent(inout) :: this

Calls

proc~~test_main~2~~CallsGraph proc~test_main~2 test_main ESMF_CalendarSetDefault ESMF_CalendarSetDefault proc~test_main~2->ESMF_CalendarSetDefault ESMF_ClockCreate ESMF_ClockCreate proc~test_main~2->ESMF_ClockCreate ESMF_TimeGet ESMF_TimeGet proc~test_main~2->ESMF_TimeGet ESMF_TimeIntervalSet ESMF_TimeIntervalSet proc~test_main~2->ESMF_TimeIntervalSet ESMF_TimeSet ESMF_TimeSet proc~test_main~2->ESMF_TimeSet esmf_fieldbundlecreate esmf_fieldbundlecreate proc~test_main~2->esmf_fieldbundlecreate esmf_fieldbundleset esmf_fieldbundleset proc~test_main~2->esmf_fieldbundleset interface~mapl_am_i_root MAPL_Am_I_Root proc~test_main~2->interface~mapl_am_i_root interface~mapl_cfioread MAPL_CFIORead proc~test_main~2->interface~mapl_cfioread interface~mapl_memutilswrite MAPL_MemUtilsWrite proc~test_main~2->interface~mapl_memutilswrite mpiassertequal mpiassertequal proc~test_main~2->mpiassertequal none~getvm ESMF_TestCase%getVM proc~test_main~2->none~getvm proc~mapl_memutilsinit MAPL_MemUtilsInit proc~test_main~2->proc~mapl_memutilsinit proc~mygridcreate_~2 MyGridCreate_ proc~test_main~2->proc~mygridcreate_~2 ESMF_GridCompGet ESMF_GridCompGet none~getvm->ESMF_GridCompGet proc~mapl_return MAPL_Return proc~mapl_memutilsinit->proc~mapl_return ESMF_ConfigCreate ESMF_ConfigCreate proc~mygridcreate_~2->ESMF_ConfigCreate ESMF_ConfigGetAttribute ESMF_ConfigGetAttribute proc~mygridcreate_~2->ESMF_ConfigGetAttribute ESMF_ConfigLoadFile ESMF_ConfigLoadFile proc~mygridcreate_~2->ESMF_ConfigLoadFile ESMF_ConfigSetAttribute ESMF_ConfigSetAttribute proc~mygridcreate_~2->ESMF_ConfigSetAttribute ESMF_VMGet ESMF_VMGet proc~mygridcreate_~2->ESMF_VMGet ESMF_VMGetCurrent ESMF_VMGetCurrent proc~mygridcreate_~2->ESMF_VMGetCurrent mapl_gridcreate mapl_gridcreate proc~mygridcreate_~2->mapl_gridcreate mapl_set mapl_set proc~mygridcreate_~2->mapl_set proc~mygridcreate_~2->proc~mapl_return proc~mapl_verify MAPL_Verify proc~mygridcreate_~2->proc~mapl_verify at at proc~mapl_return->at insert insert proc~mapl_return->insert proc~mapl_throw_exception MAPL_throw_exception proc~mapl_return->proc~mapl_throw_exception proc~mapl_verify->proc~mapl_throw_exception

Source Code

   subroutine test_main(this)
      class (ESMF_TestMethod), intent(inout) :: this

      character(len=ESMF_MAXSTR) :: string
      type(ESMF_Grid)     :: grid
      integer                    :: I


    vm = this%getVM()
    IamRoot = MAPL_am_I_root(vm)
    if (IamRoot) then
       block
         integer :: unit
         open(newunit=unit,file='tmp_CAP.rc', status='unknown',form='formatted')
         write(unit,*)'NX: 4'
         write(unit,*)'NY: 1'
         write(unit,*)"GRIDNAME: 'PC144x91-DC'"
         close(unit)
       end block
    end if

    call MAPL_MemUtilsInit( rc=STATUS )
    @mpiassertEqual(0, STATUS, Iam)


!   Create a grid
!   -------------
    grid = MyGridCreate_ ( vm, rc=status )
    @mpiassertEqual(0, STATUS, Iam)
!   Create empty bundles
!   --------------------
!    fBundle = ESMF_FieldBundleCreate ( name='Francesca', grid=grid, rc=status )
!    @mpiassertEqual(0, STATUS, Iam)
    fBundle = ESMF_FieldBundleCreate ( name='PRECIP', rc=status )
    @mpiassertEqual(0, STATUS, Iam)
    call ESMF_FieldBundleSet(fBundle, grid=grid, rc=status)
    @mpiassertEqual(0, STATUS, Iam)
    dBundle = ESMF_FieldBundleCreate ( name='Denise', rc=status )
    @mpiassertEqual(0, STATUS, Iam)
    call ESMF_FieldBundleSet(dBundle, grid=grid, rc=status)
    @mpiassertEqual(0, STATUS, Iam)

!   Set the time as the one on the hardwired file name
!   --------------------------------------------------
    call ESMF_CalendarSetDefault ( ESMF_CALKIND_GREGORIAN, rc=status )
    @mpiassertEqual(0, STATUS, Iam)
    call ESMF_TimeSet( fTime, yy=2006, mm=8, dd=9, h=6, m=30, s=0, rc=status )
    @mpiassertEqual(0, STATUS, Iam)
    call ESMF_TimeSet( dTime, yy=2006, mm=8, dd=9,  h=6, m=0, s=0, rc=status )
    @mpiassertEqual(0, STATUS, Iam)
    call ESMF_TimeIntervalSet( fTimeStep, h=6, m=0, s=0, rc=status )
    @mpiassertEqual(0, STATUS, Iam)
    fClock = ESMF_ClockCreate ( name="Clovis", timeStep=fTimeStep, &
                                startTime=fTime, rc=status )
    @mpiassertEqual(0, STATUS, Iam)

!   Read Bundle from file on a clean slate
!   --------------------------------------
    if ( IamRoot ) print *, 'Reading ' // fFilename
    call ESMF_TimeGet  ( fTime, TimeString=string  ,rc=STATUS )
    @mpiassertEqual(0, STATUS, Iam)
    string(11:11)=" "
    if ( IamRoot ) print *, 'time ' // trim(string)


    DO I = 1, 30
       call MAPL_CFIORead( fFilename, fTime, fBundle, NOREAD=.true., RC=STATUS)
       @mpiassertEqual(0, STATUS, Iam)

       if (mod(I,10)==0) then
          call MAPL_MemUtilsWrite( vm, 'noRead', RC=status )
          @mpiassertEqual(0, STATUS, Iam)
       end if

       call MAPL_CFIORead( fFilename, fTime, fBundle, RC=STATUS)
       @mpiassertEqual(0, STATUS, Iam)
       if (mod(I,10)==0) then
          call MAPL_MemUtilsWrite( vm, 'Read', RC=status )
          @mpiassertEqual(0, STATUS, Iam)
       end if
    end DO


#if 0
! this the equivalent of ESMF_ioRead
    call MAPL_cfioRead  ( fFilename, fTime, fBundle, rc=status, &
                        verbose=.true., force_regrid=.true.   )
    @mpiassertEqual(0, STATUS, Iam)

!   Next, create a bundle with same variables as the first one, and use
!    that to determine which variables to read from the second file
!   -------------------------------------------------------------------

    call MAPL_cfioRead  ( fFilename, fTime, dBundle, rc=status, &
                        verbose=.true., noRead = .true.,      &
                        only_vars = 'phis,qv' )

    @mpiassertEqual(0, STATUS, Iam)
    if ( IamRoot ) print *, 'Reading ' // fFilename
    call MAPL_cfioRead  ( fFilename, dTime, dBundle, rc=status, &
                        verbose=.true., force_regrid=.true. )
    @mpiassertEqual(0, STATUS, Iam)

!   Setup data types need for write
!   -------------------------------
    allocate ( resolution(2), levels(KM_WORLD), stat=status )
    @mpiassertEqual(0, STATUS, Iam)
    resolution = (/ IM_WORLD/2, JM_WORLD/2 /)
    levels     = (/ (k, k=1,KM_WORLD) /)

!   Write the same bundle to a differfent file
!   ------------------------------------------
    call MAPL_cfioCreate ( cfio, 'Cindy', fClock, fBundle, fTimeStep, &
         resolution, levels, descr='Bundle Write Test', rc=status )
    @mpiassertEqual(0, STATUS, Iam)

    call MAPL_cfioWrite ( cfio, fClock, fBundle, rc=status, &
                          verbose = .true. )
    @mpiassertEqual(0, STATUS, Iam)

    call MAPL_cfioDestroy ( cfio )
#else
    print *,'calling Finalize'
#endif

    
 end subroutine test_main