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