GenericCoupler.F90 Source File


This file depends on

sourcefile~~genericcoupler.f90~~EfferentGraph sourcefile~genericcoupler.f90 GenericCoupler.F90 sourcefile~couplermetacomponent.f90 CouplerMetaComponent.F90 sourcefile~genericcoupler.f90->sourcefile~couplermetacomponent.f90 sourcefile~errorhandling.f90 ErrorHandling.F90 sourcefile~genericcoupler.f90->sourcefile~errorhandling.f90 sourcefile~extensionaction.f90 ExtensionAction.F90 sourcefile~genericcoupler.f90->sourcefile~extensionaction.f90 sourcefile~griddedcomponentdriver.f90 GriddedComponentDriver.F90 sourcefile~genericcoupler.f90->sourcefile~griddedcomponentdriver.f90 sourcefile~couplermetacomponent.f90->sourcefile~errorhandling.f90 sourcefile~couplermetacomponent.f90->sourcefile~extensionaction.f90 sourcefile~couplermetacomponent.f90->sourcefile~griddedcomponentdriver.f90 sourcefile~componentdriver.f90 ComponentDriver.F90 sourcefile~couplermetacomponent.f90->sourcefile~componentdriver.f90 sourcefile~componentdriverptrvector.f90 ComponentDriverPtrVector.F90 sourcefile~couplermetacomponent.f90->sourcefile~componentdriverptrvector.f90 sourcefile~componentdrivervector.f90 ComponentDriverVector.F90 sourcefile~couplermetacomponent.f90->sourcefile~componentdrivervector.f90 sourcefile~esmf_interfaces.f90 ESMF_Interfaces.F90 sourcefile~couplermetacomponent.f90->sourcefile~esmf_interfaces.f90 sourcefile~mapl_throw.f90 MAPL_Throw.F90 sourcefile~errorhandling.f90->sourcefile~mapl_throw.f90 sourcefile~griddedcomponentdriver.f90->sourcefile~errorhandling.f90 sourcefile~griddedcomponentdriver.f90->sourcefile~componentdriver.f90 sourcefile~griddedcomponentdriver.f90->sourcefile~componentdrivervector.f90 sourcefile~keywordenforcer.f90 KeywordEnforcer.F90 sourcefile~griddedcomponentdriver.f90->sourcefile~keywordenforcer.f90 sourcefile~multistate.f90 MultiState.F90 sourcefile~griddedcomponentdriver.f90->sourcefile~multistate.f90 sourcefile~componentdriver.f90->sourcefile~errorhandling.f90 sourcefile~componentdriver.f90->sourcefile~multistate.f90 sourcefile~maplshared.f90 MaplShared.F90 sourcefile~componentdriver.f90->sourcefile~maplshared.f90 sourcefile~componentdriverptrvector.f90->sourcefile~componentdriver.f90 sourcefile~componentdrivervector.f90->sourcefile~componentdriver.f90 sourcefile~multistate.f90->sourcefile~errorhandling.f90 sourcefile~multistate.f90->sourcefile~keywordenforcer.f90 sourcefile~esmf_utilities.f90 ESMF_Utilities.F90 sourcefile~multistate.f90->sourcefile~esmf_utilities.f90 sourcefile~esmf_utilities.f90->sourcefile~errorhandling.f90 sourcefile~maplshared.f90->sourcefile~errorhandling.f90 sourcefile~maplshared.f90->sourcefile~keywordenforcer.f90 sourcefile~maplshared.f90->sourcefile~mapl_throw.f90 sourcefile~abstractcommsplitter.f90 AbstractCommSplitter.F90 sourcefile~maplshared.f90->sourcefile~abstractcommsplitter.f90 sourcefile~commgroupdescription.f90 CommGroupDescription.F90 sourcefile~maplshared.f90->sourcefile~commgroupdescription.f90 sourcefile~constants.f90 Constants.F90 sourcefile~maplshared.f90->sourcefile~constants.f90 sourcefile~downbit.f90 DownBit.F90 sourcefile~maplshared.f90->sourcefile~downbit.f90 sourcefile~dso_utilities.f90 DSO_Utilities.F90 sourcefile~maplshared.f90->sourcefile~dso_utilities.f90 sourcefile~filesystemutilities.f90 FileSystemUtilities.F90 sourcefile~maplshared.f90->sourcefile~filesystemutilities.f90 sourcefile~interp.f90 Interp.F90 sourcefile~maplshared.f90->sourcefile~interp.f90 sourcefile~mapl_dirpath.f90 MAPL_DirPath.F90 sourcefile~maplshared.f90->sourcefile~mapl_dirpath.f90 sourcefile~mapl_hash.f90 MAPL_Hash.F90 sourcefile~maplshared.f90->sourcefile~mapl_hash.f90 sourcefile~mapl_loadbalance.f90 MAPL_LoadBalance.F90 sourcefile~maplshared.f90->sourcefile~mapl_loadbalance.f90 sourcefile~mapl_minmax.f90 MAPL_MinMax.F90 sourcefile~maplshared.f90->sourcefile~mapl_minmax.f90 sourcefile~mapl_range.f90 MAPL_Range.F90 sourcefile~maplshared.f90->sourcefile~mapl_range.f90 sourcefile~mapl_sleep.f90 MAPL_Sleep.F90 sourcefile~maplshared.f90->sourcefile~mapl_sleep.f90 sourcefile~mapl_sort.f90 MAPL_Sort.F90 sourcefile~maplshared.f90->sourcefile~mapl_sort.f90 sourcefile~shmem.f90 Shmem.F90 sourcefile~maplshared.f90->sourcefile~shmem.f90 sourcefile~simplecommsplitter.f90 SimpleCommSplitter.F90 sourcefile~maplshared.f90->sourcefile~simplecommsplitter.f90 sourcefile~splitcommunicator.f90 SplitCommunicator.F90 sourcefile~maplshared.f90->sourcefile~splitcommunicator.f90 sourcefile~string.f90 String.F90 sourcefile~maplshared.f90->sourcefile~string.f90

Files dependent on this one

sourcefile~~genericcoupler.f90~~AfferentGraph sourcefile~genericcoupler.f90 GenericCoupler.F90 sourcefile~stateitemextension.f90 StateItemExtension.F90 sourcefile~stateitemextension.f90->sourcefile~genericcoupler.f90 sourcefile~extensionfamily.f90 ExtensionFamily.F90 sourcefile~extensionfamily.f90->sourcefile~stateitemextension.f90 sourcefile~stateitemextensionptrvector.f90 StateItemExtensionPtrVector.F90 sourcefile~extensionfamily.f90->sourcefile~stateitemextensionptrvector.f90 sourcefile~mapl_generic.f90~2 MAPL_Generic.F90 sourcefile~mapl_generic.f90~2->sourcefile~stateitemextension.f90 sourcefile~mapl_generic.f90~2->sourcefile~extensionfamily.f90 sourcefile~stateregistry.f90 StateRegistry.F90 sourcefile~mapl_generic.f90~2->sourcefile~stateregistry.f90 sourcefile~matchconnection.f90 MatchConnection.F90 sourcefile~matchconnection.f90->sourcefile~stateitemextension.f90 sourcefile~simpleconnection.f90 SimpleConnection.F90 sourcefile~matchconnection.f90->sourcefile~simpleconnection.f90 sourcefile~matchconnection.f90->sourcefile~stateregistry.f90 sourcefile~modelverticalgrid.f90 ModelVerticalGrid.F90 sourcefile~modelverticalgrid.f90->sourcefile~stateitemextension.f90 sourcefile~modelverticalgrid.f90->sourcefile~extensionfamily.f90 sourcefile~modelverticalgrid.f90->sourcefile~stateitemextensionptrvector.f90 sourcefile~modelverticalgrid.f90->sourcefile~stateregistry.f90 sourcefile~protoextdatagc.f90 ProtoExtDataGC.F90 sourcefile~protoextdatagc.f90->sourcefile~stateitemextension.f90 sourcefile~protoextdatagc.f90->sourcefile~mapl_generic.f90~2 sourcefile~protoextdatagc.f90->sourcefile~simpleconnection.f90 sourcefile~protoextdatagc.f90->sourcefile~stateregistry.f90 sourcefile~servicespec.f90 ServiceSpec.F90 sourcefile~servicespec.f90->sourcefile~stateitemextension.f90 sourcefile~servicespec.f90->sourcefile~stateregistry.f90 sourcefile~simpleconnection.f90->sourcefile~stateitemextension.f90 sourcefile~simpleconnection.f90->sourcefile~stateitemextensionptrvector.f90 sourcefile~stateitemextensionvector.f90 StateItemExtensionVector.F90 sourcefile~simpleconnection.f90->sourcefile~stateitemextensionvector.f90 sourcefile~simpleconnection.f90->sourcefile~stateregistry.f90 sourcefile~stateitemextensionptrvector.f90->sourcefile~stateitemextension.f90 sourcefile~stateitemextensionvector.f90->sourcefile~stateitemextension.f90 sourcefile~stateregistry.f90->sourcefile~stateitemextension.f90 sourcefile~stateregistry.f90->sourcefile~extensionfamily.f90 sourcefile~stateregistry.f90->sourcefile~stateitemextensionptrvector.f90 sourcefile~stateregistry.f90->sourcefile~stateitemextensionvector.f90 sourcefile~test_extensionfamily.pf Test_ExtensionFamily.pf sourcefile~test_extensionfamily.pf->sourcefile~stateitemextension.f90 sourcefile~test_extensionfamily.pf->sourcefile~extensionfamily.f90 sourcefile~test_extensionfamily.pf->sourcefile~stateregistry.f90 sourcefile~test_modelverticalgrid.pf Test_ModelVerticalGrid.pf sourcefile~test_modelverticalgrid.pf->sourcefile~stateitemextension.f90 sourcefile~test_modelverticalgrid.pf->sourcefile~modelverticalgrid.f90 sourcefile~test_modelverticalgrid.pf->sourcefile~stateregistry.f90 sourcefile~test_stateregistry.pf Test_StateRegistry.pf sourcefile~test_stateregistry.pf->sourcefile~stateitemextension.f90 sourcefile~test_stateregistry.pf->sourcefile~extensionfamily.f90 sourcefile~test_stateregistry.pf->sourcefile~simpleconnection.f90 sourcefile~test_stateregistry.pf->sourcefile~stateitemextensionptrvector.f90 sourcefile~test_stateregistry.pf->sourcefile~stateregistry.f90 sourcefile~can_connect_to.f90 can_connect_to.F90 sourcefile~can_connect_to.f90->sourcefile~modelverticalgrid.f90 sourcefile~can_connect_to.f90~2 can_connect_to.F90 sourcefile~can_connect_to.f90~2->sourcefile~modelverticalgrid.f90 sourcefile~can_connect_to.f90~3 can_connect_to.F90 sourcefile~can_connect_to.f90~3->sourcefile~modelverticalgrid.f90 sourcefile~componentspecparser.f90 ComponentSpecParser.F90 sourcefile~componentspecparser.f90->sourcefile~matchconnection.f90 sourcefile~componentspecparser.f90->sourcefile~simpleconnection.f90 sourcefile~generic3g.f90 Generic3g.F90 sourcefile~generic3g.f90->sourcefile~mapl_generic.f90~2 sourcefile~make_itemspec.f90 make_itemSpec.F90 sourcefile~make_itemspec.f90->sourcefile~servicespec.f90 sourcefile~make_itemspec.f90->sourcefile~stateregistry.f90 sourcefile~mapl3_deprecated.f90 MAPL3_Deprecated.F90 sourcefile~mapl3_deprecated.f90->sourcefile~mapl_generic.f90~2 sourcefile~outermetacomponent.f90 OuterMetaComponent.F90 sourcefile~outermetacomponent.f90->sourcefile~matchconnection.f90 sourcefile~outermetacomponent.f90->sourcefile~stateregistry.f90 sourcefile~reexportconnection.f90 ReexportConnection.F90 sourcefile~reexportconnection.f90->sourcefile~extensionfamily.f90 sourcefile~reexportconnection.f90->sourcefile~stateregistry.f90 sourcefile~simpleleafgridcomp.f90 SimpleLeafGridComp.F90 sourcefile~simpleleafgridcomp.f90->sourcefile~mapl_generic.f90~2 sourcefile~simpleparentgridcomp.f90 SimpleParentGridComp.F90 sourcefile~simpleparentgridcomp.f90->sourcefile~mapl_generic.f90~2 sourcefile~test_runchild.pf Test_RunChild.pf sourcefile~test_runchild.pf->sourcefile~mapl_generic.f90~2 sourcefile~test_scenarios.pf Test_Scenarios.pf sourcefile~test_scenarios.pf->sourcefile~mapl_generic.f90~2 sourcefile~test_simpleleafgridcomp.pf Test_SimpleLeafGridComp.pf sourcefile~test_simpleleafgridcomp.pf->sourcefile~mapl_generic.f90~2 sourcefile~test_simpleparentgridcomp.pf Test_SimpleParentGridComp.pf sourcefile~test_simpleparentgridcomp.pf->sourcefile~mapl_generic.f90~2 sourcefile~variablespec.f90 VariableSpec.F90 sourcefile~variablespec.f90->sourcefile~stateregistry.f90 sourcefile~virtualptfamilymap.f90 VirtualPtFamilyMap.F90 sourcefile~virtualptfamilymap.f90->sourcefile~extensionfamily.f90

Source Code

#include "MAPL_Generic.h"

module mapl3g_GenericCoupler
   use mapl3g_CouplerMetaComponent
   use mapl3g_ExtensionAction
   use mapl3g_GriddedComponentDriver
   use mapl_ErrorHandlingMod
   use esmf
   implicit none
   private

   public :: setServices
   public :: make_coupler

   character(*), parameter :: COUPLER_PRIVATE_STATE = 'MAPL::CouplerMetaComponent::private'

contains

   function make_coupler(action, source, rc) result(coupler_gridcomp)
      type(ESMF_GridComp) :: coupler_gridcomp
      class(ExtensionAction), intent(in) :: action
      type(GriddedComponentDriver), target, optional, intent(in) :: source
      integer, optional, intent(out) :: rc

      integer :: status
      type(CouplerMetaComponent), pointer :: coupler_meta

      coupler_gridcomp = ESMF_GridCompCreate(name='coupler', contextFlag=ESMF_CONTEXT_PARENT_VM, _RC)
      call attach_coupler_meta(coupler_gridcomp, _RC)
      coupler_meta => get_coupler_meta(coupler_gridcomp, _RC)
#ifndef __GFORTRAN__
      coupler_meta = CouplerMetaComponent(action, source)
#else
      call ridiculous(coupler_meta, CouplerMetaComponent(action,source))
#endif

      call ESMF_GridCompSetServices(coupler_gridComp, setServices, _RC)

      _RETURN(_SUCCESS)

   contains

#ifdef __GFORTRAN__
      subroutine ridiculous(a, b)
         type(CouplerMetaComponent), intent(out) :: a
         type(CouplerMetaComponent), intent(in) :: b
         a = b
      end subroutine ridiculous
#endif

   end function make_coupler
   
   subroutine setServices(gridcomp, rc)
      type(ESMF_GridComp) :: gridcomp
      integer, intent(out) :: rc

      integer :: status

      call ESMF_GridCompSetEntryPoint(gridcomp, ESMF_METHOD_INITIALIZE, initialize, phase=GENERIC_COUPLER_INITIALIZE, _RC)

      call ESMF_GridCompSetEntryPoint(gridcomp, ESMF_METHOD_RUN, update, phase=GENERIC_COUPLER_UPDATE, _RC)
      call ESMF_GridCompSetEntryPoint(gridcomp, ESMF_METHOD_RUN, invalidate, phase=GENERIC_COUPLER_INVALIDATE, _RC)
      call ESMF_GridCompSetEntryPoint(gridcomp, ESMF_METHOD_RUN, clock_advance, phase=GENERIC_COUPLER_CLOCK_ADVANCE, _RC)

      _RETURN(_SUCCESS)
   end subroutine setServices


   subroutine initialize(gridcomp, importState, exportState, clock, rc)
      type(ESMF_GridComp) :: gridcomp
      type(ESMF_State) :: importState
      type(ESMF_State) :: exportState
      type(ESMF_Clock) :: clock
      integer, intent(out) :: rc
      
      integer :: status
      type(CouplerMetaComponent), pointer :: meta

      meta => get_coupler_meta(gridcomp, _RC)
      call meta%initialize(importState, exportState, clock, _RC)

      _RETURN(_SUCCESS)
   end subroutine initialize


   recursive subroutine update(gridcomp, importState, exportState, clock, rc)
      type(ESMF_GridComp) :: gridcomp
      type(ESMF_State) :: importState
      type(ESMF_State) :: exportState
      type(ESMF_Clock) :: clock
      integer, intent(out) :: rc
      
      integer :: status
      type(CouplerMetaComponent), pointer :: meta

      meta => get_coupler_meta(gridcomp, _RC)
      call meta%update(importState, exportState, clock, _RC)

      _RETURN(_SUCCESS)
   end subroutine update

   
   recursive subroutine invalidate(gridcomp, importState, exportState, clock, rc)
      type(ESMF_GridComp) :: gridcomp
      type(ESMF_State) :: importState
      type(ESMF_State) :: exportState
      type(ESMF_Clock) :: clock
      integer, intent(out) :: rc
      
      integer :: status
      type(CouplerMetaComponent), pointer :: meta

      meta => get_coupler_meta(gridcomp, _RC)
      call meta%invalidate(importstate, exportState, clock, _RC)

      _RETURN(_SUCCESS)
   end subroutine invalidate


   recursive subroutine clock_advance(gridcomp, importState, exportState, clock, rc)
      type(ESMF_GridComp) :: gridcomp
      type(ESMF_State) :: importState
      type(ESMF_State) :: exportState
      type(ESMF_Clock) :: clock
      integer, intent(out) :: rc
      
      integer :: status
      type(CouplerMetaComponent), pointer :: coupler_meta
      
      coupler_meta => get_coupler_meta(gridcomp)
      call coupler_meta%clock_advance(importState, exportState, clock, _RC)

      ! TBD: is this where it belongs?
      call ESMF_ClockAdvance(clock, _RC)
     
      _RETURN(_SUCCESS)
   end subroutine clock_advance


end module mapl3g_GenericCoupler