test_field_update_from_field_ignore_geom Subroutine

public subroutine test_field_update_from_field_ignore_geom(this)

Arguments

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

Calls

proc~~test_field_update_from_field_ignore_geom~~CallsGraph proc~test_field_update_from_field_ignore_geom test_field_update_from_field_ignore_geom ESMF_GeomCreate ESMF_GeomCreate proc~test_field_update_from_field_ignore_geom->ESMF_GeomCreate ESMF_GeomDestroy ESMF_GeomDestroy proc~test_field_update_from_field_ignore_geom->ESMF_GeomDestroy ESMF_GridCreateNoPeriDim ESMF_GridCreateNoPeriDim proc~test_field_update_from_field_ignore_geom->ESMF_GridCreateNoPeriDim ESMF_GridDestroy ESMF_GridDestroy proc~test_field_update_from_field_ignore_geom->ESMF_GridDestroy anyexceptions anyexceptions proc~test_field_update_from_field_ignore_geom->anyexceptions assert_that assert_that proc~test_field_update_from_field_ignore_geom->assert_that assertequal assertequal proc~test_field_update_from_field_ignore_geom->assertequal equal_to equal_to proc~test_field_update_from_field_ignore_geom->equal_to esmf_fieldcreate esmf_fieldcreate proc~test_field_update_from_field_ignore_geom->esmf_fieldcreate esmf_fielddestroy esmf_fielddestroy proc~test_field_update_from_field_ignore_geom->esmf_fielddestroy esmf_fieldget esmf_fieldget proc~test_field_update_from_field_ignore_geom->esmf_fieldget interface~mapl_fieldget MAPL_FieldGet proc~test_field_update_from_field_ignore_geom->interface~mapl_fieldget interface~mapl_fieldset MAPL_FieldSet proc~test_field_update_from_field_ignore_geom->interface~mapl_fieldset none~initialize~15 FieldDelta%initialize proc~test_field_update_from_field_ignore_geom->none~initialize~15 none~update_field~4 FieldDelta%update_field proc~test_field_update_from_field_ignore_geom->none~update_field~4 sourcelocation sourcelocation proc~test_field_update_from_field_ignore_geom->sourcelocation true true proc~test_field_update_from_field_ignore_geom->true none~initialize_field_delta_degenerate FieldDelta%initialize_field_delta_degenerate none~initialize~15->none~initialize_field_delta_degenerate none~update_field~4->interface~mapl_fieldset none~reallocate_field FieldDelta%reallocate_field none~update_field~4->none~reallocate_field proc~mapl_return MAPL_Return none~update_field~4->proc~mapl_return proc~mapl_verify MAPL_Verify none~update_field~4->proc~mapl_verify none~initialize_field_delta_degenerate->esmf_fieldget none~initialize_field_delta_degenerate->interface~mapl_fieldget none~initialize_field_delta_degenerate->proc~mapl_return none~initialize_field_delta_degenerate->proc~mapl_verify none~reallocate_field->esmf_fieldget none~reallocate_field->interface~mapl_fieldget none~reallocate_field->proc~mapl_return none~reallocate_field->proc~mapl_verify esmf_arraydestroy esmf_arraydestroy none~reallocate_field->esmf_arraydestroy esmf_fieldemptycomplete esmf_fieldemptycomplete none~reallocate_field->esmf_fieldemptycomplete esmf_fieldemptyset esmf_fieldemptyset none~reallocate_field->esmf_fieldemptyset interface~fieldgetlocalelementcount FieldGetLocalElementCount none~reallocate_field->interface~fieldgetlocalelementcount interface~mapl_assert MAPL_Assert none~reallocate_field->interface~mapl_assert 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_field_update_from_field_ignore_geom(this)
      class(ESMF_TestMethod), intent(inout) :: this
      type(ESMF_Field) :: f, f_ref
      type(ESMF_Grid) :: grid, grid_ref
      type(ESMF_Geom) :: geom, geom_ref, new_geom
      character(:), allocatable :: new_units

      integer :: status
      type(ESMF_FieldStatus_Flag) :: field_status
      real(ESMF_KIND_R8), pointer :: x8(:,:,:,:)
      type(ESMF_TypeKind_Flag) :: typekind
      type(FieldDelta) :: delta

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

      grid_ref = ESMF_GridCreateNoPeriDim(maxIndex=[7,7], name='I_AM_GROOT', _RC)
      geom_ref = ESMF_GeomCreate(grid_ref, _RC)

      f = ESMF_FieldCreate(geom, typekind=ESMF_TYPEKIND_R4, name='in', &
           ungriddedLbound=[1,1], ungriddedUbound=[ORIG_VGRID_LEVELS,3], _RC)

      f_ref = ESMF_FieldCreate(geom_ref, typekind=ESMF_TYPEKIND_R8, name='in', &
           ungriddedLbound=[1,1], ungriddedUbound=[ORIG_VGRID_LEVELS-1,3], _RC)

      call MAPL_FieldSet(f, num_levels=ORIG_VGRID_LEVELS, vert_staggerloc=VERTICAL_STAGGER_CENTER, &
           units=ORIGINAL_UNITS, _RC)
      call MAPL_FieldSet(f_ref, num_levels=ORIG_VGRID_LEVELS, vert_staggerloc=VERTICAL_STAGGER_CENTER, &
           units=REFERENCE_UNITS, _RC)


      call delta%initialize(f, f_ref, _RC)
      call delta%update_field(f, ignore='geom', _RC)

      call ESMF_FieldGet(f, status=field_status, typekind=typekind, geom=new_geom, _RC)
      @assert_that(field_status == ESMF_FIELDSTATUS_COMPLETE, is(true()))
      @assert_that(typekind == ESMF_TYPEKIND_R8, is(true()))
      @assert_that(new_geom == geom, is(true()))

      call MAPL_FieldGet(f, units=new_units, _RC)
      @assertEqual(REFERENCE_UNITS, new_units)

      ! check that field shape is changed due to new num levels
      call ESMF_FieldGet(f, fArrayPtr=x8, _RC)
      @assert_that(shape(x8),is(equal_to([4,4,ORIG_VGRID_LEVELS,3])))

      call ESMF_FieldDestroy(f, _RC)
      call ESMF_GridDestroy(grid, _RC)
      call ESMF_GeomDestroy(geom, _RC)

      _UNUSED_DUMMY(this)
   end subroutine test_field_update_from_field_ignore_geom