Test_RouteHandleManager.pf Source File


This file depends on

sourcefile~~test_routehandlemanager.pf~~EfferentGraph sourcefile~test_routehandlemanager.pf Test_RouteHandleManager.pf sourcefile~esmf_testmethod.f90 ESMF_TestMethod.F90 sourcefile~test_routehandlemanager.pf->sourcefile~esmf_testmethod.f90 sourcefile~geom_mgr.f90 geom_mgr.F90 sourcefile~test_routehandlemanager.pf->sourcefile~geom_mgr.f90 sourcefile~regridder_mgr.f90 regridder_mgr.F90 sourcefile~test_routehandlemanager.pf->sourcefile~regridder_mgr.f90 sourcefile~esmf_testcase.f90 ESMF_TestCase.F90 sourcefile~esmf_testmethod.f90->sourcefile~esmf_testcase.f90 sourcefile~esmf_testparameter.f90 ESMF_TestParameter.F90 sourcefile~esmf_testmethod.f90->sourcefile~esmf_testparameter.f90 sourcefile~geomspec.f90 GeomSpec.F90 sourcefile~geom_mgr.f90->sourcefile~geomspec.f90 sourcefile~geomutilities.f90 GeomUtilities.F90 sourcefile~geom_mgr.f90->sourcefile~geomutilities.f90 sourcefile~dynamicmask.f90 DynamicMask.F90 sourcefile~regridder_mgr.f90->sourcefile~dynamicmask.f90 sourcefile~regriddermanager.f90 RegridderManager.F90 sourcefile~regridder_mgr.f90->sourcefile~regriddermanager.f90 sourcefile~regridderspec.f90 RegridderSpec.F90 sourcefile~regridder_mgr.f90->sourcefile~regridderspec.f90 sourcefile~base_base.f90 Base_Base.F90 sourcefile~dynamicmask.f90->sourcefile~base_base.f90 sourcefile~errorhandling.f90 ErrorHandling.F90 sourcefile~dynamicmask.f90->sourcefile~errorhandling.f90 sourcefile~esmf_testcase.f90->sourcefile~esmf_testparameter.f90 sourcefile~geomutilities.f90->sourcefile~errorhandling.f90 sourcefile~regriddermanager.f90->sourcefile~regridderspec.f90 sourcefile~regriddermanager.f90->sourcefile~errorhandling.f90 sourcefile~esmfregridderfactory.f90 EsmfRegridderFactory.F90 sourcefile~regriddermanager.f90->sourcefile~esmfregridderfactory.f90 sourcefile~nullregridder.f90 NullRegridder.F90 sourcefile~regriddermanager.f90->sourcefile~nullregridder.f90 sourcefile~regridderfactory.f90 RegridderFactory.F90 sourcefile~regriddermanager.f90->sourcefile~regridderfactory.f90 sourcefile~regridderfactoryvector.f90 RegridderFactoryVector.F90 sourcefile~regriddermanager.f90->sourcefile~regridderfactoryvector.f90 sourcefile~regridderspecvector.f90 RegridderSpecVector.F90 sourcefile~regriddermanager.f90->sourcefile~regridderspecvector.f90 sourcefile~regriddervector.f90 RegridderVector.F90 sourcefile~regriddermanager.f90->sourcefile~regriddervector.f90 sourcefile~regridderspec.f90->sourcefile~geom_mgr.f90 sourcefile~regridderparam.f90 RegridderParam.F90 sourcefile~regridderspec.f90->sourcefile~regridderparam.f90 sourcefile~constants.f90 Constants.F90 sourcefile~base_base.f90->sourcefile~constants.f90 sourcefile~keywordenforcer.f90 KeywordEnforcer.F90 sourcefile~base_base.f90->sourcefile~keywordenforcer.f90 sourcefile~mapl_range.f90 MAPL_Range.F90 sourcefile~base_base.f90->sourcefile~mapl_range.f90 sourcefile~maplgrid.f90 MaplGrid.F90 sourcefile~base_base.f90->sourcefile~maplgrid.f90 sourcefile~mapl_throw.f90 MAPL_Throw.F90 sourcefile~errorhandling.f90->sourcefile~mapl_throw.f90 sourcefile~esmfregridderfactory.f90->sourcefile~regridderspec.f90 sourcefile~esmfregridderfactory.f90->sourcefile~errorhandling.f90 sourcefile~esmfregridderfactory.f90->sourcefile~nullregridder.f90 sourcefile~esmfregridderfactory.f90->sourcefile~regridderfactory.f90 sourcefile~esmfregridderfactory.f90->sourcefile~regridderparam.f90 sourcefile~routehandlemanager.f90 RoutehandleManager.F90 sourcefile~esmfregridderfactory.f90->sourcefile~routehandlemanager.f90 sourcefile~routehandleparam.f90 RoutehandleParam.F90 sourcefile~esmfregridderfactory.f90->sourcefile~routehandleparam.f90 sourcefile~nullregridder.f90->sourcefile~errorhandling.f90 sourcefile~regridderfactoryvector.f90->sourcefile~regridderfactory.f90 sourcefile~regridderspecvector.f90->sourcefile~regridderspec.f90

Source Code

#define _VERIFY(status) \
   if(status /= 0) then; \
      call assert_that(status, is(0), location=SourceLocation(__FILE__,__LINE__)); \
      if (anyExceptions()) return; \
   endif
#define _RC rc=status); _VERIFY(status

! Helper procedures
#define _SUCCESS 0
#define _RC2 rc=status); _VERIFY2(status
#define _VERIFY2(status)  if (status /= 0) then; if (present(rc)) rc=status; return; endif
#define _RETURN(status) if (present(rc)) rc=status; return

module Test_RouteHandleManager
   use pfunit
   use mapl3g_regridder_mgr
   use mapl3g_geom_mgr
   use esmf_TestMethod_mod ! mapl
   use esmf
   implicit none

contains

   ! Helper procedures
   ! TODO add error handling to helper procedures
   
   function make_geom(geom_mgr, hconfig, rc) result(geom)
      type(ESMF_Geom) :: geom
      type(GeomManager), intent(inout) :: geom_mgr
      type(ESMF_HConfig), optional, intent(in) :: hconfig
      integer, optional, intent(out) :: rc

      type(MaplGeom), pointer :: mapl_geom
      class(GeomSpec), allocatable :: spec
      integer :: status
      type(ESMF_HConfig) :: hconfig_

      hconfig_ = ESMF_HConfigCreate(content="{class: latlon, im_world: 12, jm_world: 13, pole: PC, dateline: DC, nx: 1, ny: 1}", _RC2)
      if (present(hconfig)) hconfig_ = hconfig

      mapl_geom => geom_mgr%get_mapl_geom(hconfig_, _RC2)
      geom = mapl_geom%get_geom()

      _RETURN(_SUCCESS)
   end function make_geom

   function make_field(geom, name, value, rc) result(field)
      type(ESMF_Field) :: field
      type(ESMF_Geom), intent(in) :: geom
      character(*), intent(in) :: name
      real(kind=ESMF_KIND_R4), intent(in) :: value
      integer, optional, intent(out) :: rc

      real(kind=ESMF_KIND_R4), pointer :: x(:,:)
      integer :: status

      field = ESMF_FieldEmptyCreate(name=name, _RC2)
      call ESMF_FieldEmptySet(field, geom, _RC2)
      call ESMF_FieldEmptyComplete(field, typekind=ESMF_TypeKind_R4, _RC2)
      call ESMF_FieldGet(field, farrayptr=x, _RC2)
      x = value

   end function make_field

   @test(type=ESMF_TestMethod, npes=[1])
   ! Just execute a series of plausible commands and ensure that no
   ! failures are indicated Regrid a constant field onto identical
   ! geometry should not change any values.
   subroutine test_basic(this)
      class(ESMF_TestMethod), intent(inout) :: this
      type(GeomManager), target :: geom_mgr
      type(RegridderManager) :: regridder_mgr
      type(RegridderSpec) :: regridder_spec
      integer :: status
      class(Regridder), pointer :: my_regridder
      type(ESMF_Geom) :: geom

      type(ESMF_Field) :: f1, f2
      real(kind=ESMF_KIND_R4), pointer :: x(:,:)

      geom_mgr = GeomManager()
      regridder_mgr = RegridderManager()

      geom = make_geom(geom_mgr, _RC)

      ! use default esmf regrid parameters: method, zero region, etc
      regridder_spec = RegridderSpec(EsmfRegridderParam(), geom, geom)

      my_regridder => regridder_mgr%get_regridder(regridder_spec, _RC)

      f1 = make_field(geom, 'f1', value=3._ESMF_KIND_R4, _RC)
      f2 = make_field(geom, 'f2', value=0._ESMF_KIND_R4, _RC)

      call my_regridder%regrid(f1, f2, _RC)

      call ESMF_FieldGet(f1, farrayptr=x, _RC)

      @assert_that(x, every_item(is(equal_to(3._ESMF_KIND_R4))))

   end subroutine test_basic

end module Test_RouteHandleManager