test_accumulate_mean_R4 Subroutine

public subroutine test_accumulate_mean_R4(this)

Arguments

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

Calls

proc~~test_accumulate_mean_r4~~CallsGraph proc~test_accumulate_mean_r4 test_accumulate_mean_R4 anyexceptions anyexceptions proc~test_accumulate_mean_r4->anyexceptions assert_that assert_that proc~test_accumulate_mean_r4->assert_that assertequal assertequal proc~test_accumulate_mean_r4->assertequal esmf_fielddestroy esmf_fielddestroy proc~test_accumulate_mean_r4->esmf_fielddestroy interface~assign_fptr assign_fptr proc~test_accumulate_mean_r4->interface~assign_fptr interface~fieldset FieldSet proc~test_accumulate_mean_r4->interface~fieldset interface~initialize_field initialize_field proc~test_accumulate_mean_r4->interface~initialize_field none~accumulate_r4~4 MeanAction%accumulate_R4 proc~test_accumulate_mean_r4->none~accumulate_r4~4 none~initialize~30 AccumulatorAction%initialize proc~test_accumulate_mean_r4->none~initialize~30 proc~destroy_objects destroy_objects proc~test_accumulate_mean_r4->proc~destroy_objects proc~initialize_objects initialize_objects proc~test_accumulate_mean_r4->proc~initialize_objects proc~set_undef set_undef proc~test_accumulate_mean_r4->proc~set_undef sourcelocation sourcelocation proc~test_accumulate_mean_r4->sourcelocation

Source Code

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

      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)
      ! set update field
      call FieldSet(update_field, UPDATE_VALUE, _RC)
      call assign_fptr(update_field, upPtr, _RC)
      ! set last element of update field to UNDEF
      n = size(upPtr)
      call set_undef(upPtr(n))
      ! run subroutine to test
      call acc%accumulate_R4(update_field, _RC)
      call assign_fptr(acc%accumulation_field, accPtr, _RC)
      call assign_fptr(acc%counter_field, countPtr, _RC)
      allocate(expected_count(size(countPtr)))
      expected_count = 1_I4
      expected_count(n) = 0_I4
      @assertEqual(expected_count, countPtr, 'Counts do not match.')

      call ESMF_FieldDestroy(update_field)
      call destroy_objects(importState, exportState, clock, _RC)

   end subroutine test_accumulate_mean_R4