get_substate Subroutine

public subroutine get_substate(state, path, substate, rc)

Uses

  • proc~~get_substate~~UsesGraph proc~get_substate get_substate module~mapl_errorhandling mapl_ErrorHandling proc~get_substate->module~mapl_errorhandling module~mapl_throwmod MAPL_ThrowMod module~mapl_errorhandling->module~mapl_throwmod mpi mpi module~mapl_errorhandling->mpi

Arguments

Type IntentOptional Attributes Name
type(ESMF_State), intent(inout) :: state
character(len=*), intent(in) :: path
type(ESMF_State), intent(out) :: substate
integer, intent(out), optional :: rc

Calls

proc~~get_substate~~CallsGraph proc~get_substate get_substate esmf_stateadd esmf_stateadd proc~get_substate->esmf_stateadd esmf_statecreate esmf_statecreate proc~get_substate->esmf_statecreate esmf_stateget esmf_stateget proc~get_substate->esmf_stateget interface~mapl_assert MAPL_Assert proc~get_substate->interface~mapl_assert proc~mapl_return MAPL_Return proc~get_substate->proc~mapl_return proc~mapl_verify MAPL_Verify proc~get_substate->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

Called by

proc~~get_substate~~CalledByGraph proc~get_substate get_substate none~add_to_state~5 FieldSpec%add_to_state none~add_to_state~5->proc~get_substate proc~test_vertical test_vertical proc~test_vertical->none~add_to_state~5

Source Code

   subroutine get_substate(state, path, substate, rc)
      use mapl_ErrorHandling
      type(ESMF_State), intent(inout) :: state
      character(*), intent(in) :: path
      type(ESMF_State), intent(out) :: substate
      integer, optional, intent(out) :: rc

      integer :: status
      type(ESMF_StateItem_Flag) :: itemType
      character(:), allocatable :: substate_name, current_path
      type(ESMF_State) :: tmp_state
      integer :: idx

      substate = state
      if (path == '') then ! no substate
         _RETURN(_SUCCESS)
      end if

      current_path = path
      do while (path /= '')
         idx = index(current_path, '/')
         substate_name = current_path
         if (idx > 0) then
            substate_name = current_path(:idx-1)
         end if

         call ESMF_StateGet(substate, substate_name, itemType, _RC)
         
         if (itemType == ESMF_STATEITEM_NOTFOUND) then ! New tmp_state
            tmp_state = ESMF_StateCreate(name=substate_name, _RC)
            call ESMF_StateAdd(substate, [tmp_state], _RC)
         else
            _ASSERT(itemType == ESMF_STATEITEM_STATE, 'expected ' // substate_name // ' to be an ESMF_State.')
            call ESMF_StateGet(substate, substate_name, tmp_state, _RC)
         end if
         substate = tmp_state
         if (idx == 0) exit
         current_path = current_path(idx+1:)
      end do


      _RETURN(_SUCCESS)
   end subroutine get_substate