test_add_to_state Subroutine

public subroutine test_add_to_state(this)

Arguments

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

Calls

proc~~test_add_to_state~~CallsGraph proc~test_add_to_state test_add_to_state ESMF_InfoGetFromHost ESMF_InfoGetFromHost proc~test_add_to_state->ESMF_InfoGetFromHost ESMF_InfoIsPresent ESMF_InfoIsPresent proc~test_add_to_state->ESMF_InfoIsPresent anyexceptions anyexceptions proc~test_add_to_state->anyexceptions assert_that assert_that proc~test_add_to_state->assert_that false false proc~test_add_to_state->false none~add_primary_spec StateRegistry%add_primary_spec proc~test_add_to_state->none~add_primary_spec none~add_subregistry StateRegistry%add_subregistry proc~test_add_to_state->none~add_subregistry none~add_to_states StateRegistry%add_to_states proc~test_add_to_state->none~add_to_states none~propagate_exports~3 StateRegistry%propagate_exports proc~test_add_to_state->none~propagate_exports~3 none~propagate_unsatisfied_imports~3 StateRegistry%propagate_unsatisfied_imports proc~test_add_to_state->none~propagate_unsatisfied_imports~3 sourcelocation sourcelocation proc~test_add_to_state->sourcelocation true true proc~test_add_to_state->true

Source Code

   subroutine test_add_to_state(this)
      class(ESMF_TestMethod), intent(inout) :: this
      
      type(StateRegistry), target :: r
      type(StateRegistry), target :: r_A ! child registry
      type(VirtualConnectionPt) :: cp_e1, cp_e2
      type(VirtualConnectionPt) :: cp_i1, cp_i2
      integer :: status
      type(MultiState) :: user_states, outer_states
      type(ESMF_Info) :: info

      r = StateRegistry('P')
      r_a = StateRegistry('child_A')
      call r%add_subregistry(r_a)

      cp_e1 = VirtualConnectionPt(state_intent='export', short_name='e1')
      cp_e2 = VirtualConnectionPt(state_intent='export', short_name='e2')

      cp_i1 = VirtualConnectionPt(state_intent='import', short_name='i1')
      cp_i2 = VirtualConnectionPt(state_intent='import', short_name='i2')

      call r_a%add_primary_spec(cp_e1, MockItemSpec('e1'))
      call r_a%add_primary_spec(cp_i1, MockItemSpec('i1'))

      call r%add_primary_spec(cp_e2, MockItemSpec('e2'))
      call r%add_primary_spec(cp_i1, MockItemSpec('i1')) ! intentional duplicate with r_A
      call r%add_primary_spec(cp_i2, MockItemSpec('i2'))

      call r%propagate_exports(_RC)
      call r%propagate_unsatisfied_imports(_RC)

      user_states = MultiState()

      call r%add_to_states(user_states, 'user', _RC)
      ! expect e2 and i2 only
      call ESMF_InfoGetFromHost(user_states%exportstate, info, _RC)
      @assert_that(ESMF_InfoIsPresent(info, 'e2'), is(true()))
      @assert_that(ESMF_InfoIsPresent(info, 'a/e1'), is(false()))
      call ESMF_InfoGetFromHost(user_states%importstate, info, _RC)
      @assert_that(ESMF_InfoIsPresent(info, 'i2'), is(true()))
      @assert_that(ESMF_InfoIsPresent(info, 'i1'), is(true()))
      @assert_that(ESMF_InfoIsPresent(info, 'i1(1)'), is(false()))

      outer_states = MultiState()
      call r%add_to_states(outer_states, 'outer', _RC)
      ! expect e2 and i2 only
      call ESMF_InfoGetFromHost(outer_states%exportstate, info, _RC)
      @assert_that(ESMF_InfoIsPresent(info, 'e2'), is(true()))
      @assert_that(ESMF_InfoIsPresent(info, 'child_A/e1'), is(true()))
      call ESMF_InfoGetFromHost(outer_states%importstate, info, _RC)
      @assert_that(ESMF_InfoIsPresent(info, 'i2'), is(true()))
      @assert_that(ESMF_InfoIsPresent(info, 'i1'), is(true()))
      @assert_that(ESMF_InfoIsPresent(info, 'i1(1)'), is(true()))

      _UNUSED_DUMMY(this)
   end subroutine test_add_to_state