test_regrid_values Subroutine

public subroutine test_regrid_values(this)

Arguments

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

Calls

proc~~test_regrid_values~~CallsGraph proc~test_regrid_values test_regrid_values ESMF_HConfigCreate ESMF_HConfigCreate proc~test_regrid_values->ESMF_HConfigCreate anyexceptions anyexceptions proc~test_regrid_values->anyexceptions assert_that assert_that proc~test_regrid_values->assert_that equal_to equal_to proc~test_regrid_values->equal_to esmf_fieldget esmf_fieldget proc~test_regrid_values->esmf_fieldget esmfregridderparam esmfregridderparam proc~test_regrid_values->esmfregridderparam every_item every_item proc~test_regrid_values->every_item geommanager geommanager proc~test_regrid_values->geommanager none~get_regridder RegridderManager%get_regridder proc~test_regrid_values->none~get_regridder proc~make_field~2 make_field proc~test_regrid_values->proc~make_field~2 proc~make_geom~5 make_geom proc~test_regrid_values->proc~make_geom~5 regrid regrid proc~test_regrid_values->regrid sourcelocation sourcelocation proc~test_regrid_values->sourcelocation find find none~get_regridder->find none~add_regridder RegridderManager%add_regridder none~get_regridder->none~add_regridder none~back~8 RegridderVector%back none~get_regridder->none~back~8 none~begin~141 RegridderSpecVector%begin none~get_regridder->none~begin~141 none~make_regridder~3 RegridderManager%make_regridder none~get_regridder->none~make_regridder~3 none~of~25 RegridderVector%of none~get_regridder->none~of~25 proc~mapl_return MAPL_Return none~get_regridder->proc~mapl_return proc~mapl_verify MAPL_Verify none~get_regridder->proc~mapl_verify proc~make_field~2->esmf_fieldget esmf_fieldemptycomplete esmf_fieldemptycomplete proc~make_field~2->esmf_fieldemptycomplete esmf_fieldemptycreate esmf_fieldemptycreate proc~make_field~2->esmf_fieldemptycreate esmf_fieldemptyset esmf_fieldemptyset proc~make_field~2->esmf_fieldemptyset proc~make_geom~5->ESMF_HConfigCreate get_geom get_geom proc~make_geom~5->get_geom get_mapl_geom get_mapl_geom proc~make_geom~5->get_mapl_geom

Source Code

   subroutine test_regrid_values(this)
      class(ESMF_TestMethod), intent(inout) :: this
      type(GeomManager) :: geom_mgr
      type(RegridderManager), target :: regridder_mgr
      type(RegridderSpec) :: spec
      integer :: status
      class(Regridder), pointer :: my_regridder
      type(ESMF_Geom) :: geom_1, geom_2
      type(ESMF_HConfig) :: hconfig
      type(ESMF_Field) :: f1, f2
      real(kind=ESMF_KIND_R4), pointer :: x1(:,:)
      real(kind=ESMF_KIND_R4), pointer :: x2(:,:)

      geom_mgr = GeomManager()
      regridder_mgr = RegridderManager()

      hconfig = ESMF_HConfigCreate(content="{class: latlon, im_world: 12, jm_world: 11, pole: PC, dateline: DE, nx: 1, ny: 1}", _RC)
      geom_1 = make_geom(geom_mgr, hconfig, _RC)

      hconfig = ESMF_HConfigCreate(content="{class: latlon, im_world: 6, jm_world: 5, pole: PC, dateline: DE, nx: 1, ny: 1}", _RC)
      geom_2 = make_geom(geom_mgr, hconfig, _RC) ! variant of geom_1

      spec = RegridderSpec(EsmfRegridderParam(regridmethod=ESMF_REGRIDMETHOD_CONSERVE), geom_1, geom_2)
      my_regridder => regridder_mgr%get_regridder(spec, _RC)

      f1 = make_field(geom_1, 'f1', value=2._ESMF_KIND_R4, _RC)
      call ESMF_FieldGet(f1, farrayptr=x1, _RC)
      x1(2::2,:) = 0 ! checkerboard
      
      f2 = make_field(geom_2, 'f2', value=0._ESMF_KIND_R4, _RC)

      ! (0 + 2)/2 == 1
      call my_regridder%regrid(f1, f2, _RC)
      call ESMF_FieldGet(f2, farrayptr=x2, _RC)
 
      @assert_that(x2, every_item(is(equal_to(1._ESMF_KIND_R4))))

   end subroutine test_regrid_values