#include "MAPL_TestErr.h" #include "unused_dummy.H" module Test_FieldReset use mapl3g_FieldCreate use mapl3g_FieldReset use mapl3g_FieldGet use funit use ESMF_TestMethod_mod use esmf implicit none(type,external) contains @test(type=ESMF_TestMethod, npes=[1]) subroutine test_reset_gridset(this) class(ESMF_TestMethod), intent(inout) :: this type(ESMF_Field) :: field type(ESMF_Geom) :: geom type(ESMF_Grid) :: grid character(*), parameter :: EXPECTED_UNITS = 'km' integer :: status type(ESMF_FieldStatus_Flag) :: field_status type(ESMF_TypeKind_Flag) :: typekind grid = ESMF_GridCreateNoPeriDim(maxIndex=[4,4], _RC) geom = ESMF_GeomCreate(grid, _RC) field = MAPL_FieldCreate(geom, typekind=ESMF_TYPEKIND_R4, units=EXPECTED_UNITS, _RC) call MAPL_FieldReset(field, new_status=ESMF_FIELDSTATUS_GRIDSET, _RC) call ESMF_FieldGet(field, status=field_status, _RC) @assert_that(field_status == ESMF_FIELDSTATUS_GRIDSET, is(true())) ! Can we complete the field now? call MAPL_FieldEmptyComplete(field, typekind=ESMF_TYPEKIND_R8, _RC) call ESMF_FieldGet(field, status=field_status, typekind=typekind, _RC) @assert_that(field_status == ESMF_FIELDSTATUS_COMPLETE, is(true())) @assert_that(typekind == ESMF_TYPEKIND_R8, is(true())) call ESMF_FieldDestroy(field, _RC) call ESMF_GridDestroy(grid, _RC) call ESMF_GeomDestroy(geom, _RC) _UNUSED_DUMMY(this) end subroutine test_reset_gridset @test(type=ESMF_TestMethod, npes=[1]) subroutine test_reset_empty(this) class(ESMF_TestMethod), intent(inout) :: this type(ESMF_Field) :: field type(ESMF_Geom) :: geom type(ESMF_Grid) :: grid character(*), parameter :: EXPECTED_UNITS = 'km' integer :: status type(ESMF_FieldStatus_Flag) :: field_status type(ESMF_TypeKind_Flag) :: typekind grid = ESMF_GridCreateNoPeriDim(maxIndex=[4,4], _RC) geom = ESMF_GeomCreate(grid, _RC) field = MAPL_FieldCreate(geom, typekind=ESMF_TYPEKIND_R4, units=EXPECTED_UNITS, _RC) call MAPL_FieldReset(field, new_status=ESMF_FIELDSTATUS_EMPTY, _RC) call ESMF_FieldGet(field, status=field_status, _RC) @assert_that(field_status == ESMF_FIELDSTATUS_EMPTY, is(true())) call ESMF_FieldEmptySet(field, geom=geom, _RC) call ESMF_FieldGet(field, status=field_status, _RC) @assert_that(field_status == ESMF_FIELDSTATUS_GRIDSET, is(true())) ! Can we complete the field now? call MAPL_FieldEmptyComplete(field, typekind=ESMF_TYPEKIND_R8, _RC) call ESMF_FieldGet(field, status=field_status, typekind=typekind, _RC) @assert_that(field_status == ESMF_FIELDSTATUS_COMPLETE, is(true())) @assert_that(typekind == ESMF_TYPEKIND_R8, is(true())) call ESMF_FieldDestroy(field, _RC) call ESMF_GridDestroy(grid, _RC) call ESMF_GeomDestroy(geom, _RC) _UNUSED_DUMMY(this) end subroutine test_reset_empty end module Test_FieldReset