test_main Subroutine

subroutine test_main()

Arguments

None

Calls

proc~~test_main~5~~CallsGraph proc~test_main~5 test_main esmf_bundlecreate esmf_bundlecreate proc~test_main~5->esmf_bundlecreate esmf_calendarsetdefault esmf_calendarsetdefault proc~test_main~5->esmf_calendarsetdefault esmf_clockcreate esmf_clockcreate proc~test_main~5->esmf_clockcreate esmf_finalize esmf_finalize proc~test_main~5->esmf_finalize esmf_initialize esmf_initialize proc~test_main~5->esmf_initialize esmf_timeintervalset esmf_timeintervalset proc~test_main~5->esmf_timeintervalset esmf_timeset esmf_timeset proc~test_main~5->esmf_timeset esmf_vmgetglobal esmf_vmgetglobal proc~test_main~5->esmf_vmgetglobal interface~esmf_iocreate ESMF_ioCreate proc~test_main~5->interface~esmf_iocreate interface~esmf_iodestroy ESMF_ioDestroy proc~test_main~5->interface~esmf_iodestroy interface~esmf_ioread ESMF_ioRead proc~test_main~5->interface~esmf_ioread interface~esmf_iowrite ESMF_ioWrite proc~test_main~5->interface~esmf_iowrite interface~mapl_am_i_root MAPL_Am_I_Root proc~test_main~5->interface~mapl_am_i_root mapl_verify mapl_verify proc~test_main~5->mapl_verify proc~mygridcreate_~5 MyGridCreate_ proc~test_main~5->proc~mygridcreate_~5 proc~mapl_cfiodestroy MAPL_CFIODestroy interface~esmf_iodestroy->proc~mapl_cfiodestroy proc~mygridcreate_~5->interface~mapl_am_i_root proc~mygridcreate_~5->mapl_verify esmf_delayoutcreate esmf_delayoutcreate proc~mygridcreate_~5->esmf_delayoutcreate esmf_gridaddvertheight esmf_gridaddvertheight proc~mygridcreate_~5->esmf_gridaddvertheight esmf_gridcreatehorzlatlonuni esmf_gridcreatehorzlatlonuni proc~mygridcreate_~5->esmf_gridcreatehorzlatlonuni esmf_griddistribute esmf_griddistribute proc~mygridcreate_~5->esmf_griddistribute mapl_get_local_dims mapl_get_local_dims proc~mygridcreate_~5->mapl_get_local_dims mapl_return mapl_return proc~mygridcreate_~5->mapl_return proc~esmf_cfiodestroy ESMF_CFIODestroy proc~mapl_cfiodestroy->proc~esmf_cfiodestroy proc~esmf_cfiofileclose ESMF_CFIOFileClose proc~mapl_cfiodestroy->proc~esmf_cfiofileclose proc~mapl_return MAPL_Return proc~mapl_cfiodestroy->proc~mapl_return proc~mapl_verify MAPL_Verify proc~mapl_cfiodestroy->proc~mapl_verify

Called by

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

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
!   -------------
    grid = MyGridCreate_ ( vm, rc=status )
    _VERIFY(status)

!   Create empty bundles
!   --------------------
    fBundle = ESMF_BundleCreate ( name='Francesca', grid=grid, rc=status )
    _VERIFY(status)
    dBundle = ESMF_BundleCreate ( name='Denise',    grid=grid, rc=status )
    _VERIFY(status)

!   Set the time as the one on the hardwired file name
!   --------------------------------------------------
    call ESMF_CalendarSetDefault ( ESMF_CAL_GREGORIAN, rc=status )
    _VERIFY(STATUS)
    call ESMF_TimeSet( fTime, yy=2002, mm=7, dd=15, h=12, m=0, s=0, rc=status )
    _VERIFY(STATUS)
    call ESMF_TimeIntervalSet( fTimeStep, h=6, m=0, s=0, rc=status )
    _VERIFY(STATUS)
    fClock = ESMF_ClockCreate ( name="Clovis", timeStep=fTimeStep, &
                                startTime=fTime, rc=status )
    _VERIFY(STATUS)

!   Read Bundle from file on a clean slate
!   --------------------------------------
    if ( IamRoot ) print *, 'Reading ' // fFilename
    call ESMF_ioRead  ( fFilename, fTime, fBundle, rc=status, &
                        verbose=.true., force_regrid=.true.   )
    _VERIFY(status)

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

!   Write the same bundle to a different file, each time with
!    different precision
!   ----------------------------------------------------------
     nbits = 32 ! full precision
     write(fname,"('test.aero.eta.',I2.2)") nbits

     call ESMF_ioCreate ( cfio, fname, fClock, fBundle, fTimeStep, &
                          resolution, levels, 'Bundle Write Test', rc=status )
     _VERIFY(status)

     call ESMF_ioWrite ( cfio, fClock, fBundle, fTimeStep, levels, rc=status, &
                         verbose = .true. ) ! omit nbits
     _VERIFY(status)

     call ESMF_ioDestroy ( cfio )

    do nbits = 16, 8, -2

     write(fname,"('test.aero.eta.',I2.2)") nbits

     call ESMF_ioCreate ( cfio, fname, fClock, fBundle, fTimeStep, &
                          resolution, levels, 'Bundle Write Test', rc=status )
     _VERIFY(status)

     call ESMF_ioWrite ( cfio, fClock, fBundle, fTimeStep, levels, rc=status, &
                         nbits = nbits, verbose = .true. )
     _VERIFY(status)

     call ESMF_ioDestroy ( cfio )

    end do ! precision loop

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