make_subgridcomps Function

public function make_subgridcomps(GridComp, run_entry_points, num_grids, unusable, rc) result(subgridcomps)

Uses

  • proc~~make_subgridcomps~~UsesGraph proc~make_subgridcomps make_subgridcomps module~mapl_entrypointvector MAPL_EntryPointVector proc~make_subgridcomps->module~mapl_entrypointvector module~mapl_runentrypoint MAPL_RunEntryPoint proc~make_subgridcomps->module~mapl_runentrypoint module~mapl_entrypointvector->module~mapl_runentrypoint

Arguments

Type IntentOptional Attributes Name
type(ESMF_GridComp), intent(in) :: GridComp
type(entryPointVector), intent(in) :: run_entry_points
integer, intent(in) :: num_grids
class(KeywordEnforcer), intent(in), optional :: unusable
integer, intent(out), optional :: rc

Return Value type(ESMF_GridComp), allocatable, (:)


Calls

proc~~make_subgridcomps~~CallsGraph proc~make_subgridcomps make_subgridcomps ESMF_GridCompCreate ESMF_GridCompCreate proc~make_subgridcomps->ESMF_GridCompCreate ESMF_GridCompGet ESMF_GridCompGet proc~make_subgridcomps->ESMF_GridCompGet ESMF_InternalStateGet ESMF_InternalStateGet proc~make_subgridcomps->ESMF_InternalStateGet ESMF_UserCompGetInternalState ESMF_UserCompGetInternalState proc~make_subgridcomps->ESMF_UserCompGetInternalState ESMF_UserCompSetInternalState ESMF_UserCompSetInternalState proc~make_subgridcomps->ESMF_UserCompSetInternalState ESMF_VMGet ESMF_VMGet proc~make_subgridcomps->ESMF_VMGet ESMF_VMGetCurrent ESMF_VMGetCurrent proc~make_subgridcomps->ESMF_VMGetCurrent esmf_gridcompsetservices esmf_gridcompsetservices proc~make_subgridcomps->esmf_gridcompsetservices proc~mapl_return MAPL_Return proc~make_subgridcomps->proc~mapl_return proc~mapl_verify MAPL_Verify proc~make_subgridcomps->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

    function make_subgridcomps(GridComp, run_entry_points, num_grids, unusable, rc) result(subgridcomps)
        use mapl_RunEntryPoint
        use mapl_EntryPointVector
        type(ESMF_GridComp), allocatable :: subgridcomps(:)
        type(ESMF_GridComp), intent(in)  :: GridComp
        type(EntryPointVector), intent(in) :: run_entry_points
        integer, intent(in) :: num_grids
        class(KeywordEnforcer), optional, intent(in) :: unusable
        integer, optional, intent(out) :: rc

        integer :: status, user_status
        type(ESMF_VM) :: vm
        integer :: myPet, i, ilabel
        logical :: has_private_state
        type(runEntryPoint), pointer :: run_entry_point
        procedure(), pointer :: user_method => null()

        type MAPL_GenericWrap
           type(ESMF_Clock), pointer :: dummy
        end type MAPL_GenericWrap

        type (MAPL_GenericWrap) :: wrap !, wrap_private
        character(len=ESMF_MAXSTR) :: comp_name
        character(len=:), allocatable :: labels(:)
        integer :: phase
        type(ESMF_Config) :: CF

        allocate(subgridcomps(num_grids))

        call ESMF_VMGetCurrent(vm, _RC)
        call ESMF_VMGet(vm, localPET=myPET, _RC)

        call ESMF_GridCompGet(GridComp, config=CF, name=comp_name, _RC)
        call ESMF_InternalStateGet(GridComp, labelList=labels, _RC)

        do i = 1, num_grids
          associate (gc => subgridcomps(i) )
            gc = ESMF_GridCompCreate(name=trim(comp_name), config=CF, petlist=[myPet], &
                 & contextflag=ESMF_CONTEXT_OWN_VM, _RC)
            call ESMF_GridCompSetServices(gc, set_services, userrc=user_status, _RC)
            _VERIFY(user_status)
          end associate
        end do

        do ilabel = 1, size(labels)
           call ESMF_UserCompGetInternalState(GridComp, trim(labels(ilabel)), wrap, status)
           has_private_state = (status == ESMF_SUCCESS)
           do i = 1, num_grids
              associate (gc => subgridcomps(i) )
                if (has_private_state) then
                   call ESMF_UserCompSetInternalState(gc, trim(labels(ilabel)), wrap, status)
                   _VERIFY(status)
                end if
              end associate
           end do
        end do

        _RETURN(ESMF_SUCCESS)
        _UNUSED_DUMMY(unusable)

        contains

        subroutine set_services(gc, rc)
           type(ESMF_GridComp) :: gc
           integer, intent(out):: rc
           integer :: status
            do phase = 1, run_entry_points%size()
               run_entry_point => run_entry_points%of(phase)
               if(associated(run_entry_point%run_entry_point)) then
                  user_method => run_entry_point%run_entry_point

                  call ESMF_GridCompSetEntryPoint(gc, ESMF_METHOD_RUN, phase=phase, userroutine=user_method, _RC)
                end if
            end do
           _RETURN(ESMF_SUCCESS)
        end subroutine set_services

    end function make_subgridcomps