test_accumulate_with_undef_some_steps Subroutine

public subroutine test_accumulate_with_undef_some_steps(this)

Arguments

Type IntentOptional Attributes Name
class(ESMF_TestMethod), intent(inout) :: this

Calls

proc~~test_accumulate_with_undef_some_steps~~CallsGraph proc~test_accumulate_with_undef_some_steps test_accumulate_with_undef_some_steps anyexceptions anyexceptions proc~test_accumulate_with_undef_some_steps->anyexceptions assert_that assert_that proc~test_accumulate_with_undef_some_steps->assert_that assertequal assertequal proc~test_accumulate_with_undef_some_steps->assertequal asserttrue asserttrue proc~test_accumulate_with_undef_some_steps->asserttrue esmf_fielddestroy esmf_fielddestroy proc~test_accumulate_with_undef_some_steps->esmf_fielddestroy interface~assign_fptr assign_fptr proc~test_accumulate_with_undef_some_steps->interface~assign_fptr interface~initialize_field initialize_field proc~test_accumulate_with_undef_some_steps->interface~initialize_field none~accumulate~6 AccumulatorAction%accumulate proc~test_accumulate_with_undef_some_steps->none~accumulate~6 none~initialize~30 AccumulatorAction%initialize proc~test_accumulate_with_undef_some_steps->none~initialize~30 proc~destroy_objects destroy_objects proc~test_accumulate_with_undef_some_steps->proc~destroy_objects proc~initialize_objects initialize_objects proc~test_accumulate_with_undef_some_steps->proc~initialize_objects proc~set_undef set_undef proc~test_accumulate_with_undef_some_steps->proc~set_undef sourcelocation sourcelocation proc~test_accumulate_with_undef_some_steps->sourcelocation

Source Code

   subroutine test_accumulate_with_undef_some_steps(this)
      class(ESMF_TestMethod), intent(inout) :: this
      type(MeanAction) :: acc
      type(ESMF_State) :: importState, exportState
      type(ESMF_Clock) :: clock
      integer :: status
      type(ESMF_Field) :: update_field
      integer :: n
      real(kind=ESMF_KIND_R4), parameter :: UPDATE_VALUE = 3.0_R4
      real(kind=ESMF_KIND_R4), pointer :: upPtr(:), accPtr(:)
      integer(kind=ESMF_KIND_I4), pointer :: countPtr(:)
      logical, allocatable :: mask(:)

      call initialize_objects(importState, exportState, clock, ESMF_TYPEKIND_R4, _RC)
      call acc%initialize(importState, exportState, clock, _RC)
      call initialize_field(update_field, acc%accumulation_field, _RC)
      call assign_fptr(update_field, upPtr, _RC)
      upPtr = UPDATE_VALUE
      allocate(mask(size(upPtr)))
      mask = .TRUE.

      call acc%accumulate(update_field, _RC)
      call acc%accumulate(update_field, _RC)

      call assign_fptr(update_field, upPtr, _RC)
      n = size(upPtr) - 1
      call set_undef(upPtr(n)) 
      call acc%accumulate(update_field, _RC)
      mask(n) = .FALSE.

      call assign_fptr(update_field, upPtr, _RC)
      upPtr = UPDATE_VALUE
      call acc%accumulate(update_field, _RC)
      call acc%accumulate(update_field, _RC)

      call assign_fptr(acc%counter_field, countPtr, _RC)
      @assertEqual(4, countPtr(n), 'Missing point counter does not match.')
      @assertTrue(all(pack(countPtr, mask) == 5), 'Other point counters do not match.')

      call assign_fptr(acc%accumulation_field, accPtr, _RC)
      @assertEqual(4*UPDATE_VALUE, accPtr(n), 'Missing point does not match.')
      @assertTrue(all(pack(accPtr, mask) == 5*UPDATE_VALUE), 'Other points do not match.')
      call destroy_objects(importState, exportState, clock, _RC)
      call ESMF_FieldDestroy(update_field)

   end subroutine test_accumulate_with_undef_some_steps