subroutine test_main() character(len=ESMF_MAXSTR) :: string type(ESMF_Grid) :: grid integer :: I ! 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) call MAPL_MemUtilsInit( rc=STATUS ) _VERIFY(STATUS) ! Create a grid ! ------------- grid = MyGridCreate_ ( vm, rc=status ) _VERIFY(status) ! Create empty bundles ! -------------------- ! fBundle = ESMF_FieldBundleCreate ( name='Francesca', grid=grid, rc=status ) ! _VERIFY(status) fBundle = ESMF_FieldBundleCreate ( name='PRECIP', rc=status ) _VERIFY(status) call ESMF_FieldBundleSet(fBundle, grid=grid, rc=status) _VERIFY(STATUS) dBundle = ESMF_FieldBundleCreate ( name='Denise', rc=status ) _VERIFY(status) call ESMF_FieldBundleSet(dBundle, grid=grid, 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( fTime, yy=2006, mm=8, dd=9, h=6, m=30, s=0, rc=status ) _VERIFY(STATUS) call ESMF_TimeSet( dTime, yy=2006, mm=8, dd=9, h=6, 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_TimeGet ( fTime, TimeString=string ,rc=STATUS ) _VERIFY(STATUS) string(11:11)=" " if ( IamRoot ) print *, 'time ' // trim(string) DO I = 1, 30 call MAPL_CFIORead( fFilename, fTime, fBundle, NOREAD=.true., RC=STATUS) _VERIFY(STATUS) if (mod(I,10)==0) then call MAPL_MemUtilsWrite( vm, 'noRead', RC=status ) _VERIFY(STATUS) end if call MAPL_CFIORead( fFilename, fTime, fBundle, RC=STATUS) _VERIFY(STATUS) if (mod(I,10)==0) then call MAPL_MemUtilsWrite( vm, 'Read', RC=status ) _VERIFY(STATUS) 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. ) _VERIFY(status) ! 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' ) _VERIFY(status) if ( IamRoot ) print *, 'Reading ' // fFilename call MAPL_cfioRead ( fFilename, dTime, dBundle, 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 differfent file ! ------------------------------------------ call MAPL_cfioCreate ( cfio, 'Cindy', fClock, fBundle, fTimeStep, & resolution, levels, descr='Bundle Write Test', rc=status ) _VERIFY(status) call MAPL_cfioWrite ( cfio, fClock, fBundle, rc=status, & verbose = .true. ) _VERIFY(status) call MAPL_cfioDestroy ( cfio ) #else print *,'calling Finalize' #endif ! All done ! -------- call ESMF_Finalize ( rc=status ) _VERIFY(STATUS) end subroutine test_main