subroutine test_interp_midway(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
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, 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_interp_midway