test_change_weights_with_ungridded Subroutine

public subroutine test_change_weights_with_ungridded(this)

Arguments

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

Calls

proc~~test_change_weights_with_ungridded~~CallsGraph proc~test_change_weights_with_ungridded test_change_weights_with_ungridded anyexceptions anyexceptions proc~test_change_weights_with_ungridded->anyexceptions assert_that assert_that proc~test_change_weights_with_ungridded->assert_that assertequal assertequal proc~test_change_weights_with_ungridded->assertequal equal_to equal_to proc~test_change_weights_with_ungridded->equal_to esmf_fieldget esmf_fieldget proc~test_change_weights_with_ungridded->esmf_fieldget interface~mapl_fieldbundleget~2 MAPL_FieldBundleGet proc~test_change_weights_with_ungridded->interface~mapl_fieldbundleget~2 interface~mapl_fieldget MAPL_FieldGet proc~test_change_weights_with_ungridded->interface~mapl_fieldget none~get_num_ungridded UngriddedDims%get_num_ungridded proc~test_change_weights_with_ungridded->none~get_num_ungridded none~update_bundle FieldBundleDelta%update_bundle proc~test_change_weights_with_ungridded->none~update_bundle proc~setup_bundle setup_bundle proc~test_change_weights_with_ungridded->proc~setup_bundle proc~setup_geom setup_geom proc~test_change_weights_with_ungridded->proc~setup_geom proc~teardown_bundle teardown_bundle proc~test_change_weights_with_ungridded->proc~teardown_bundle proc~teardown_geom teardown_geom proc~test_change_weights_with_ungridded->proc~teardown_geom sourcelocation sourcelocation proc~test_change_weights_with_ungridded->sourcelocation true true proc~test_change_weights_with_ungridded->true none~update_bundle->interface~mapl_fieldbundleget~2 interface~mapl_fieldbundleset MAPL_FieldBundleSet none~update_bundle->interface~mapl_fieldbundleset none~reallocate_bundle FieldBundleDelta%reallocate_bundle none~update_bundle->none~reallocate_bundle none~update_fields FieldDelta%update_fields none~update_bundle->none~update_fields proc~mapl_return MAPL_Return none~update_bundle->proc~mapl_return proc~mapl_verify MAPL_Verify none~update_bundle->proc~mapl_verify esmf_fieldbundleadd esmf_fieldbundleadd proc~setup_bundle->esmf_fieldbundleadd esmf_fieldbundlecreate esmf_fieldbundlecreate proc~setup_bundle->esmf_fieldbundlecreate proc~setup_bundle->interface~mapl_fieldbundleset none~add_dim UngriddedDims%add_dim proc~setup_bundle->none~add_dim proc~setup_field setup_field proc~setup_bundle->proc~setup_field ESMF_GeomCreate ESMF_GeomCreate proc~setup_geom->ESMF_GeomCreate ESMF_GridCreateNoPeriDim ESMF_GridCreateNoPeriDim proc~setup_geom->ESMF_GridCreateNoPeriDim proc~teardown_bundle->interface~mapl_fieldbundleget~2 esmf_fieldbundledestroy esmf_fieldbundledestroy proc~teardown_bundle->esmf_fieldbundledestroy esmf_fielddestroy esmf_fielddestroy proc~teardown_bundle->esmf_fielddestroy ESMF_GeomDestroy ESMF_GeomDestroy proc~teardown_geom->ESMF_GeomDestroy ESMF_GeomGet ESMF_GeomGet proc~teardown_geom->ESMF_GeomGet ESMF_GridDestroy ESMF_GridDestroy proc~teardown_geom->ESMF_GridDestroy

Source Code

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

      integer :: status
      type(Fieldbundledelta) :: delta
      type(ESMF_Geom) :: geom, tmp_geom
      type(ESMF_FieldBundle) :: bundle
      integer :: i
      type(ESMF_Field), allocatable :: fieldList(:)
      real(kind=ESMF_KIND_R4), pointer :: x_r4(:,:,:,:)
      character(:), allocatable :: new_units
      real(kind=ESMF_KIND_R4), allocatable :: weights(:)
      real(kind=ESMF_KIND_R4), parameter :: new_weights(*) = [0.,0.25,0.75]
      integer :: nlevels, rank
      type(UngriddedDims) :: ungridded_dims

      call setup_geom(geom, 4)
      call setup_bundle(bundle, weights=DEFAULT_WEIGHTS, geom=geom, typekind=ESMF_TYPEKIND_R4, units='km', with_ungridded=.true.)


      delta = FieldBundleDelta(interpolation_weights=new_weights) 
      call delta%update_bundle(bundle, _RC) ! should not reallocate fields

      call MAPL_FieldBundleGet(bundle, fieldList=fieldList, _RC)
      @assert_that(size(fieldList), is(FIELD_COUNT))

      do i = 1, FIELD_COUNT
         call ESMF_FieldGet(fieldList(i), rank=rank, _RC)
         call ESMF_FieldGet(fieldList(i), fArrayPtr=x_r4, _RC)
         @assert_that(shape(x_r4), is(equal_to([4,4,NUM_LEVELS_VGRID,NUM_RADII])))
         @assert_that(all(x_r4 == FILL_VALUE), is(true()))

         call MAPL_FieldGet(fieldList(i), units=new_units, _RC)
         @assertEqual('km', new_units)

         call ESMF_FieldGet(fieldList(i), geom=tmp_geom, _RC)
         @assert_that(tmp_geom == geom, is(true()))

         call MAPL_FieldGet(fieldList(i), ungridded_dims=ungridded_dims, _RC)
         @assert_that(ungridded_dims%get_num_ungridded(), is(1))

         call MAPL_FieldGet(fieldList(i), num_levels=nlevels, _RC)
         @assert_that(nlevels, is(NUM_LEVELS_VGRID))

      end do

      call MAPL_FieldBundleGet(bundle, interpolation_weights=weights, _RC)
      @assert_that(weights, is(equal_to(new_weights)))

      call MAPL_FieldBundleGet(bundle, ungridded_dims=ungridded_dims, _RC)
      @assert_that(ungridded_dims%get_num_ungridded(), is(1))

      call MAPL_FieldBundleGet(bundle, num_levels=nlevels, _RC)
      @assert_that(nlevels, is(NUM_LEVELS_VGRID))

      call teardown_bundle(bundle)
      call teardown_geom(geom)

      _UNUSED_DUMMY(this)
   end subroutine test_change_weights_with_ungridded