subroutine test_anything(this)
class(Scenario), intent(inout) :: this
integer :: status
integer :: i
character(:), allocatable :: comp_path, item_name
type(ESMF_HConfig) :: comp_expectations, expected_properties
type(MultiState) :: comp_states
type(ESMF_HConfig) :: state_items
integer :: item_count, expected_item_count
type(ESMF_Field) :: field
type(ESMF_FieldStatus_Flag) :: expected_field_status, field_status
character(:), allocatable :: expected_status
components: do i = 1, ESMF_HConfigGetSize(this%expectations)
comp_expectations = ESMF_HConfigCreateAt(this%expectations,index=i,_RC)
comp_path = ESMF_HConfigAsString(comp_expectations,keyString='component',_RC)
call get_substates(this%outer_gc, this%outer_states, comp_path, substates=comp_states, _RC)
call check_items_in_state('import', _RC)
call check_items_in_state('export', _RC)
call check_items_in_state('internal', _RC)
end do components
contains
subroutine check_items_in_state(state_intent, rc)
character(*), intent(in) :: state_intent
integer, intent(out) :: rc
integer :: status
type(ESMF_HConfig) :: state_items
type(ESMF_State) :: state
character(:), allocatable :: msg
type(ESMF_HConfigIter) :: hconfigIter,hconfigIterBegin,hconfigIterEnd
rc = -1
if (.not. ESMF_HConfigIsDefined(comp_expectations,keyString=state_intent)) then
rc = 0 ! that's ok
return
end if
call comp_states%get_state(state, state_intent, _RC)
msg = comp_path // '::' // state_intent
state_items = ESMF_HConfigCreateAt(comp_expectations,keyString=state_intent,_RC)
@assertTrue(ESMF_HConfigIsMap(state_items), msg)
hconfigIter = ESMF_HConfigIterBegin(state_items)
hconfigIterBegin = ESMF_HConfigIterBegin(state_items)
hconfigIterEnd = ESMF_HConfigIterEnd(state_items)
do while (ESMF_HConfigIterLoop(hconfigIter,hconfigIterBegin,hconfigIterEnd))
item_name = ESMF_HConfigAsStringMapKey(hconfigIter,_RC)
expected_properties = ESMF_HConfigCreateAtMapVal(hconfigIter,_RC)
msg = comp_path // '::' // state_intent // '::' // item_name
associate (test_description => msg // '::' // this%check_name)
call this%check_stateitem(expected_properties, state, item_name, test_description, _RC)
end associate
end do
rc = 0
end subroutine check_items_in_state
end subroutine test_anything