Test_FieldReset.pf Source File


This file depends on

sourcefile~~test_fieldreset.pf~~EfferentGraph sourcefile~test_fieldreset.pf Test_FieldReset.pf sourcefile~esmf_testmethod.f90 ESMF_TestMethod.F90 sourcefile~test_fieldreset.pf->sourcefile~esmf_testmethod.f90 sourcefile~fieldcreate.f90 FieldCreate.F90 sourcefile~test_fieldreset.pf->sourcefile~fieldcreate.f90 sourcefile~fieldget.f90 FieldGet.F90 sourcefile~test_fieldreset.pf->sourcefile~fieldget.f90 sourcefile~fieldreset.f90 FieldReset.F90 sourcefile~test_fieldreset.pf->sourcefile~fieldreset.f90 sourcefile~esmf_testcase.f90 ESMF_TestCase.F90 sourcefile~esmf_testmethod.f90->sourcefile~esmf_testcase.f90 sourcefile~esmf_testparameter.f90 ESMF_TestParameter.F90 sourcefile~esmf_testmethod.f90->sourcefile~esmf_testparameter.f90 sourcefile~errorhandling.f90 ErrorHandling.F90 sourcefile~fieldcreate.f90->sourcefile~errorhandling.f90 sourcefile~fieldinfo.f90 FieldInfo.F90 sourcefile~fieldcreate.f90->sourcefile~fieldinfo.f90 sourcefile~keywordenforcer.f90 KeywordEnforcer.F90 sourcefile~fieldcreate.f90->sourcefile~keywordenforcer.f90 sourcefile~lu_bound.f90 LU_Bound.F90 sourcefile~fieldcreate.f90->sourcefile~lu_bound.f90 sourcefile~ungriddeddims.f90 UngriddedDims.F90 sourcefile~fieldcreate.f90->sourcefile~ungriddeddims.f90 sourcefile~verticalstaggerloc.f90 VerticalStaggerLoc.F90 sourcefile~fieldcreate.f90->sourcefile~verticalstaggerloc.f90 sourcefile~fieldget.f90->sourcefile~errorhandling.f90 sourcefile~fieldget.f90->sourcefile~fieldinfo.f90 sourcefile~fieldget.f90->sourcefile~keywordenforcer.f90 sourcefile~fieldget.f90->sourcefile~ungriddeddims.f90 sourcefile~fieldget.f90->sourcefile~verticalstaggerloc.f90 sourcefile~fieldreset.f90->sourcefile~errorhandling.f90 sourcefile~mapl_throw.f90 MAPL_Throw.F90 sourcefile~errorhandling.f90->sourcefile~mapl_throw.f90 sourcefile~esmf_testcase.f90->sourcefile~esmf_testparameter.f90 sourcefile~fieldinfo.f90->sourcefile~errorhandling.f90 sourcefile~fieldinfo.f90->sourcefile~keywordenforcer.f90 sourcefile~fieldinfo.f90->sourcefile~ungriddeddims.f90 sourcefile~fieldinfo.f90->sourcefile~verticalstaggerloc.f90 sourcefile~infoutilities.f90 InfoUtilities.F90 sourcefile~fieldinfo.f90->sourcefile~infoutilities.f90 sourcefile~mapl_esmf_infokeys.f90 MAPL_ESMF_InfoKeys.F90 sourcefile~fieldinfo.f90->sourcefile~mapl_esmf_infokeys.f90 sourcefile~ungriddeddims.f90->sourcefile~errorhandling.f90 sourcefile~ungriddeddims.f90->sourcefile~lu_bound.f90 sourcefile~ungriddeddims.f90->sourcefile~infoutilities.f90 sourcefile~ungriddeddims.f90->sourcefile~mapl_esmf_infokeys.f90 sourcefile~ungriddeddim.f90 UngriddedDim.F90 sourcefile~ungriddeddims.f90->sourcefile~ungriddeddim.f90 sourcefile~ungriddeddimvector.f90 UngriddedDimVector.F90 sourcefile~ungriddeddims.f90->sourcefile~ungriddeddimvector.f90 sourcefile~infoutilities.f90->sourcefile~errorhandling.f90 sourcefile~infoutilities.f90->sourcefile~keywordenforcer.f90 sourcefile~infoutilities.f90->sourcefile~mapl_esmf_infokeys.f90 sourcefile~mapl_esmf_infokeys.f90->sourcefile~errorhandling.f90 sourcefile~ungriddeddim.f90->sourcefile~errorhandling.f90 sourcefile~ungriddeddim.f90->sourcefile~lu_bound.f90 sourcefile~ungriddeddim.f90->sourcefile~infoutilities.f90 sourcefile~ungriddeddimvector.f90->sourcefile~ungriddeddim.f90

Source Code

#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