test_anything Subroutine

public subroutine test_anything(this)

Arguments

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

Calls

proc~~test_anything~~CallsGraph proc~test_anything test_anything ESMF_HConfigAsStringMapKey ESMF_HConfigAsStringMapKey proc~test_anything->ESMF_HConfigAsStringMapKey ESMF_HConfigCreateAtMapVal ESMF_HConfigCreateAtMapVal proc~test_anything->ESMF_HConfigCreateAtMapVal ESMF_HConfigIterLoop ESMF_HConfigIterLoop proc~test_anything->ESMF_HConfigIterLoop anyexceptions anyexceptions proc~test_anything->anyexceptions assert_that assert_that proc~test_anything->assert_that asserttrue asserttrue proc~test_anything->asserttrue esmf_hconfigasstring esmf_hconfigasstring proc~test_anything->esmf_hconfigasstring esmf_hconfigcreateat esmf_hconfigcreateat proc~test_anything->esmf_hconfigcreateat esmf_hconfiggetsize esmf_hconfiggetsize proc~test_anything->esmf_hconfiggetsize esmf_hconfigisdefined esmf_hconfigisdefined proc~test_anything->esmf_hconfigisdefined esmf_hconfigismap esmf_hconfigismap proc~test_anything->esmf_hconfigismap esmf_hconfigiterbegin esmf_hconfigiterbegin proc~test_anything->esmf_hconfigiterbegin esmf_hconfigiterend esmf_hconfigiterend proc~test_anything->esmf_hconfigiterend none~get_state~2 MultiState%get_state proc~test_anything->none~get_state~2 proc~get_substates get_substates proc~test_anything->proc~get_substates sourcelocation sourcelocation proc~test_anything->sourcelocation none~get_state_by_esmf_intent MultiState%get_state_by_esmf_intent none~get_state~2->none~get_state_by_esmf_intent proc~get_substates->anyexceptions proc~get_substates->assert_that proc~get_substates->proc~get_substates proc~get_substates->sourcelocation interface~get_outer_meta get_outer_meta proc~get_substates->interface~get_outer_meta none~get_child~27 OuterMetaComponent%get_child proc~get_substates->none~get_child~27 none~get_gridcomp~3 GriddedComponentDriver%get_gridcomp proc~get_substates->none~get_gridcomp~3 none~get_states GriddedComponentDriver%get_states proc~get_substates->none~get_states none~get_user_gc_driver OuterMetaComponent%get_user_gc_driver proc~get_substates->none~get_user_gc_driver none~get_state_by_esmf_intent->none~get_state~2 proc~mapl_return MAPL_Return none~get_state_by_esmf_intent->proc~mapl_return proc~mapl_verify MAPL_Verify none~get_state_by_esmf_intent->proc~mapl_verify at at proc~mapl_return->at insert insert proc~mapl_return->insert proc~mapl_throw_exception MAPL_throw_exception proc~mapl_return->proc~mapl_throw_exception proc~mapl_verify->proc~mapl_throw_exception

Source Code

   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