test_max_accumulate_R4 Subroutine

public subroutine test_max_accumulate_R4()

Arguments

None

Calls

proc~~test_max_accumulate_r4~~CallsGraph proc~test_max_accumulate_r4 test_max_accumulate_R4 anyexceptions anyexceptions proc~test_max_accumulate_r4->anyexceptions assert_that assert_that proc~test_max_accumulate_r4->assert_that assertequal assertequal proc~test_max_accumulate_r4->assertequal esmf_fielddestroy esmf_fielddestroy proc~test_max_accumulate_r4->esmf_fielddestroy interface~assign_fptr assign_fptr proc~test_max_accumulate_r4->interface~assign_fptr none~accumulate_r4~3 MaxAction%accumulate_R4 proc~test_max_accumulate_r4->none~accumulate_r4~3 none~initialize~38 AccumulatorAction%initialize proc~test_max_accumulate_r4->none~initialize~38 proc~destroy_objects destroy_objects proc~test_max_accumulate_r4->proc~destroy_objects proc~initialize_field initialize_field proc~test_max_accumulate_r4->proc~initialize_field proc~initialize_objects initialize_objects proc~test_max_accumulate_r4->proc~initialize_objects proc~set_undef set_undef proc~test_max_accumulate_r4->proc~set_undef sourcelocation sourcelocation proc~test_max_accumulate_r4->sourcelocation

Source Code

   subroutine test_max_accumulate_R4()
      type(MaxAction) :: acc
      type(ESMF_State) :: importState, exportState
      type(ESMF_Clock) :: clock
      integer :: status
      type(ESMF_Field) :: update_field
      type(ESMF_TypeKind_Flag), parameter :: tk =ESMF_TYPEKIND_R4
      real(kind=ESMF_KIND_R4), pointer :: upPtr(:), accPtr(:)
      real(kind=ESMF_KIND_R4), parameter :: UPDATE_VALUE = 1.0_R4, ACCUMULATED_VALUE = 3.0_R4
      real(kind=ESMF_KIND_R4) :: undef_value
      real(kind=ESMF_KIND_R4), allocatable :: expected(:)
      integer :: i, n

      ! Initialize
      call set_undef(undef_value)
      call initialize_objects(importState, exportState, clock, tk, _RC)
      call acc%initialize(importState, exportState, clock, _RC)
      call initialize_field(update_field, typekind=tk, _RC)
      call assign_fptr(acc%accumulation_field, accPtr, _RC)
      call assign_fptr(update_field, upPtr, _RC)
      n = size(upPtr)
      i = n - 3
      accPtr(i:n) = [undef_value, ACCUMULATED_VALUE, ACCUMULATED_VALUE, ACCUMULATED_VALUE]
      upPtr(i:n) = [UPDATE_VALUE, undef_value, UPDATE_VALUE, UPDATE_VALUE+ACCUMULATED_VALUE]
      expected = [UPDATE_VALUE, ACCUMULATED_VALUE, ACCUMULATED_VALUE, UPDATE_VALUE+ACCUMULATED_VALUE]
      call acc%accumulate_R4(update_field, _RC)
      @assertEqual(expected, accPtr, 'accumulated_field not equal to expected values')
      call ESMF_FieldDestroy(update_field, _RC)
      call destroy_objects(importState, exportState, clock, _RC)

   end subroutine test_max_accumulate_R4