test_calculate_mean_R4 Subroutine

public subroutine test_calculate_mean_R4(this)

Arguments

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

Calls

proc~~test_calculate_mean_r4~~CallsGraph proc~test_calculate_mean_r4 test_calculate_mean_R4 anyexceptions anyexceptions proc~test_calculate_mean_r4->anyexceptions assert_that assert_that proc~test_calculate_mean_r4->assert_that asserttrue asserttrue proc~test_calculate_mean_r4->asserttrue interface~assign_fptr assign_fptr proc~test_calculate_mean_r4->interface~assign_fptr interface~fieldisconstant FieldIsConstant proc~test_calculate_mean_r4->interface~fieldisconstant interface~fieldset FieldSet proc~test_calculate_mean_r4->interface~fieldset none~calculate_mean_r4 MeanAction%calculate_mean_R4 proc~test_calculate_mean_r4->none~calculate_mean_r4 none~initialize~30 AccumulatorAction%initialize proc~test_calculate_mean_r4->none~initialize~30 proc~destroy_objects destroy_objects proc~test_calculate_mean_r4->proc~destroy_objects proc~initialize_objects initialize_objects proc~test_calculate_mean_r4->proc~initialize_objects proc~undef undef proc~test_calculate_mean_r4->proc~undef sourcelocation sourcelocation proc~test_calculate_mean_r4->sourcelocation

Source Code

   subroutine test_calculate_mean_R4(this)
      class(ESMF_TestMethod), intent(inout) :: this
      type(MeanAction) :: acc
      type(ESMF_State) :: importState, exportState
      type(ESMF_Clock) :: clock
      integer :: status
      integer(kind=ESMF_KIND_I4), parameter :: COUNTER = 4
      real(kind=ESMF_KIND_R4), parameter :: MEAN = 4.0_R4
      logical :: matches_expected
      real(kind=ESMF_KIND_R4), pointer :: fptr(:)
      integer(kind=ESMF_KIND_I4), pointer :: ifptr(:)
      integer :: n
      logical, allocatable :: mask(:)

      call initialize_objects(importState, exportState, clock, ESMF_TYPEKIND_R4, _RC)
      call acc%initialize(importState, exportState, clock, _RC)
      call FieldSet(acc%accumulation_field, COUNTER*MEAN, _RC)
      call assign_fptr(acc%accumulation_field, fptr, _RC)
      call assign_fptr(acc%counter_field, ifptr, _RC)
      ifptr = COUNTER
      n = size(fptr)-1

      ! All points are not UNDEF and counter > 0
      call acc%calculate_mean_R4(_RC)
      matches_expected = FieldIsConstant(acc%accumulation_field, MEAN, _RC)
      @assertTrue(matches_expected, 'accumulation_field not equal to MEAN')

      ! counter 0 at one point
      call FieldSet(acc%accumulation_field, COUNTER*MEAN, _RC)
      call assign_fptr(acc%counter_field, fptr, _RC)
      fptr(n) = 0
      mask = fptr /= 0
      call assign_fptr(acc%accumulation_field, fptr, _RC)
      call acc%calculate_mean_R4(_RC)
      @assertTrue(all(pack(fptr, mask) == MEAN), 'Some valid points not equal to MEAN')
      @assertTrue(undef(fptr(n)), 'mean at point was not UNDEF')
      call destroy_objects(importState, exportState, clock, _RC)

   end subroutine test_calculate_mean_R4