subroutine test_filter_region_mask_2d(this)
class(ESMF_TestMethod), intent(inout) :: this
integer :: status, rc
real(ESMF_KIND_R4), pointer :: ptr2d(:,:), mask_ptr(:,:)
real(ESMF_KIND_R4), allocatable :: expected_array(:,:), masked_array(:,:)
real(ESMF_KIND_R4) :: rval
type(ESMF_Config) :: cf
type(ESMF_HConfig) :: hcf
hcf = ESMF_HConfigCreate(content='{FILTER.field_2d: "regionmask(@,region_mask;2,5)"}', _RC)
cf = ESMF_ConfigCreate(hconfig=hcf, _RC)
call ESMF_FieldGet(mask_field, 0, farrayPtr=mask_ptr, _RC)
call ESMF_FieldGet(field_2d, 0, farrayPtr=ptr2d, _RC)
rval = 17.0
ptr2d = rval
allocate(expected_array(3,3),_STAT)
expected_array= reshape([0.0, rval, 0.0, rval, rval, 0.0, rval, rval, 0.0],shape=[3,3])
mask_ptr = reshape([1.0, 5.0, 1.0, 5.0, 2.0, 1.0, 2.0, 5.0, 1.0],shape=[3,3])
call MAPL_StateFilterItem(state, cf, "field_2d", masked_array, _RC)
@assertEqual(expected_array, masked_array)
_RETURN(_SUCCESS)
end subroutine test_filter_region_mask_2d