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