subroutine test_change_weights(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]
call setup_geom(geom, 4)
call setup_bundle(bundle, weights=DEFAULT_WEIGHTS, geom=geom, typekind=ESMF_TYPEKIND_R4, units='km')
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), fArrayPtr=x_r4, _RC)
@assert_that(shape(x_r4), is(equal_to([4,4])))
@assert_that(x_r4, every_item(is(FILL_VALUE)))
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()))
end do
call MAPL_FieldBundleGet(bundle, interpolation_weights=weights, _RC)
@assert_that(weights, is(equal_to(new_weights)))
call teardown_bundle(bundle)
call teardown_geom(geom)
_UNUSED_DUMMY(this)
end subroutine test_change_weights