test_mapl_undef Subroutine

public subroutine test_mapl_undef(this)

Arguments

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

Calls

proc~~test_mapl_undef~~CallsGraph proc~test_mapl_undef test_mapl_undef ESMF_GeomCreate ESMF_GeomCreate proc~test_mapl_undef->ESMF_GeomCreate ESMF_GeomDestroy ESMF_GeomDestroy proc~test_mapl_undef->ESMF_GeomDestroy ESMF_GridCreateNoPeriDim ESMF_GridCreateNoPeriDim proc~test_mapl_undef->ESMF_GridCreateNoPeriDim ESMF_GridDestroy ESMF_GridDestroy proc~test_mapl_undef->ESMF_GridDestroy anyexceptions anyexceptions proc~test_mapl_undef->anyexceptions assert_that assert_that proc~test_mapl_undef->assert_that equal_to equal_to proc~test_mapl_undef->equal_to esmf_fieldbundlecreate esmf_fieldbundlecreate proc~test_mapl_undef->esmf_fieldbundlecreate esmf_fieldbundledestroy esmf_fieldbundledestroy proc~test_mapl_undef->esmf_fieldbundledestroy esmf_fielddestroy esmf_fielddestroy proc~test_mapl_undef->esmf_fielddestroy esmf_fieldemptycomplete esmf_fieldemptycomplete proc~test_mapl_undef->esmf_fieldemptycomplete esmf_fieldemptycreate esmf_fieldemptycreate proc~test_mapl_undef->esmf_fieldemptycreate esmf_fieldemptyset esmf_fieldemptyset proc~test_mapl_undef->esmf_fieldemptyset esmf_stateadd esmf_stateadd proc~test_mapl_undef->esmf_stateadd esmf_statecreate esmf_statecreate proc~test_mapl_undef->esmf_statecreate esmf_statedestroy esmf_statedestroy proc~test_mapl_undef->esmf_statedestroy every_item every_item proc~test_mapl_undef->every_item interface~assign_fptr assign_fptr proc~test_mapl_undef->interface~assign_fptr interface~mapl_fieldbundleset MAPL_FieldBundleSet proc~test_mapl_undef->interface~mapl_fieldbundleset none~update TimeInterpolateAction%update proc~test_mapl_undef->none~update sourcelocation sourcelocation proc~test_mapl_undef->sourcelocation none~update->interface~assign_fptr esmf_fieldget esmf_fieldget none~update->esmf_fieldget esmf_stateget esmf_stateget none~update->esmf_stateget interface~mapl_assert MAPL_Assert none~update->interface~mapl_assert interface~mapl_fieldbundleget MAPL_FieldBundleGet none~update->interface~mapl_fieldbundleget proc~mapl_return MAPL_Return none~update->proc~mapl_return proc~mapl_verify MAPL_Verify none~update->proc~mapl_verify at at proc~mapl_return->at insert insert proc~mapl_return->insert proc~mapl_throw_exception MAPL_throw_exception proc~mapl_return->proc~mapl_throw_exception proc~mapl_verify->proc~mapl_throw_exception

Source Code

   subroutine test_mapl_undef(this)
      class(ESMF_TestMethod), intent(inout) :: this

      type(ESMF_State) :: importState, exportState
      type(ESMF_FieldBundle) :: bracket
      type(ESMF_Field) :: f
      type(TimeinterpolateAction) :: action
      type(ESMF_Clock) :: clock
      type(ESMF_Geom) :: geom
      type(ESMF_Grid) :: grid
      integer :: status
      integer :: i
      real(kind=ESMF_KIND_R4), pointer :: x(:)
      type(ESMF_Field) :: b(2)

      importState = ESMF_StateCreate(_RC)
      exportState = ESMF_StateCreate(_RC)
      grid = ESMF_GridCreateNoPeriDim(maxIndex=[4,4], name='I_AM_GROOT', _RC)
      geom = ESMF_GeomCreate(grid, _RC)

      do i = 1, 2
         b(i) = ESMF_FieldEmptyCreate(name='b', _RC)
         call ESMF_FieldEmptySet(b(i), geom=geom, _RC)
         call ESMF_FieldEmptyComplete(b(i), typekind=ESMF_TYPEKIND_R4, _RC)
         call assign_fptr(b(i), x, _RC)
         x = 2. * i
      end do

      ! Set an isolated point in the input to UNDEF and verify that
      ! the result is undefined at the same location.
      
      x(2) = MAPL_UNDEFINED_REAL
      bracket = ESMF_FieldBundleCreate(name='import[1]', multiflag=.true., fieldList=b, _RC)
      call ESMF_StateAdd(importState, [bracket], _RC)
      call MAPL_FieldBundleSet(bracket, interpolation_weights=[1.0, 0.5, 0.5], _RC)

      f = ESMF_FieldEmptyCreate(name='export[1]', _RC)
      call ESMF_FieldEmptySet(f, geom=geom, _RC)
      call ESMF_FieldEmptyComplete(f, typekind=ESMF_TYPEKIND_R4, _RC)
      call ESMF_StateAdd(exportState, [f], _RC)

      call action%update(importState, exportState, clock, _RC)

      call assign_fptr(f, x, _RC)
      @assert_that(x(1), is(equal_to(4.)))
      @assert_that(x(2), is(equal_to(MAPL_UNDEFINED_REAL)))
      @assert_that(x(3:), every_item(is(equal_to(4.))))

      call ESMF_FieldDestroy(f, _RC)
      call ESMF_FieldDestroy(b(1), _RC)
      call ESMF_FieldDestroy(b(2), _RC)
      call ESMF_FieldBundleDestroy(bracket, _RC)
      call ESMF_StateDestroy(importState, _RC)
      call ESMF_StateDestroy(exportState, _RC)
      call ESMF_GridDestroy(grid, _RC)
      call ESMF_GeomDestroy(geom, _RC)
      
   end subroutine test_mapl_undef