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~couplerphases.f90 CouplerPhases.F90 sourcefile~genericcoupler.f90->sourcefile~couplerphases.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~verticalregridaction.f90 VerticalRegridAction.F90 sourcefile~genericcoupler.f90->sourcefile~verticalregridaction.f90 sourcefile~couplermetacomponent.f90->sourcefile~couplerphases.f90 sourcefile~couplermetacomponent.f90->sourcefile~errorhandling.f90 sourcefile~couplermetacomponent.f90->sourcefile~extensionaction.f90 sourcefile~couplermetacomponent.f90->sourcefile~griddedcomponentdriver.f90 sourcefile~couplermetacomponent.f90->sourcefile~verticalregridaction.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~extensionaction.f90->sourcefile~errorhandling.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~verticalregridaction.f90->sourcefile~couplerphases.f90 sourcefile~verticalregridaction.f90->sourcefile~errorhandling.f90 sourcefile~verticalregridaction.f90->sourcefile~extensionaction.f90 sourcefile~verticalregridaction.f90->sourcefile~griddedcomponentdriver.f90 sourcefile~csr_sparsematrix.f90 CSR_SparseMatrix.F90 sourcefile~verticalregridaction.f90->sourcefile~csr_sparsematrix.f90 sourcefile~fieldcondensedarray.f90 FieldCondensedArray.F90 sourcefile~verticalregridaction.f90->sourcefile~fieldcondensedarray.f90 sourcefile~verticallinearmap.f90 VerticalLinearMap.F90 sourcefile~verticalregridaction.f90->sourcefile~verticallinearmap.f90 sourcefile~verticalregridmethod.f90 VerticalRegridMethod.F90 sourcefile~verticalregridaction.f90->sourcefile~verticalregridmethod.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~csr_sparsematrix.f90->sourcefile~keywordenforcer.f90 sourcefile~fieldcondensedarray_private.f90 FieldCondensedArray_private.F90 sourcefile~fieldcondensedarray.f90->sourcefile~fieldcondensedarray_private.f90 sourcefile~fieldget.f90 FieldGet.F90 sourcefile~fieldcondensedarray.f90->sourcefile~fieldget.f90 sourcefile~fieldpointerutilities.f90 FieldPointerUtilities.F90 sourcefile~fieldcondensedarray.f90->sourcefile~fieldpointerutilities.f90 sourcefile~mapl_exceptionhandling.f90 MAPL_ExceptionHandling.F90 sourcefile~fieldcondensedarray.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~verticalstaggerloc.f90 VerticalStaggerLoc.F90 sourcefile~fieldcondensedarray.f90->sourcefile~verticalstaggerloc.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~verticallinearmap.f90->sourcefile~errorhandling.f90 sourcefile~verticallinearmap.f90->sourcefile~csr_sparsematrix.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~mapl_generic.f90 MAPL_Generic.F90 sourcefile~mapl_generic.f90->sourcefile~stateitemextension.f90 sourcefile~matchconnection.f90 MatchConnection.F90 sourcefile~matchconnection.f90->sourcefile~stateitemextension.f90 sourcefile~modelverticalgrid.f90 ModelVerticalGrid.F90 sourcefile~modelverticalgrid.f90->sourcefile~stateitemextension.f90 sourcefile~protoextdatagc.f90 ProtoExtDataGC.F90 sourcefile~protoextdatagc.f90->sourcefile~stateitemextension.f90 sourcefile~servicespec.f90 ServiceSpec.F90 sourcefile~servicespec.f90->sourcefile~stateitemextension.f90 sourcefile~simpleconnection.f90 SimpleConnection.F90 sourcefile~simpleconnection.f90->sourcefile~stateitemextension.f90 sourcefile~stateitemextensionptrvector.f90 StateItemExtensionPtrVector.F90 sourcefile~stateitemextensionptrvector.f90->sourcefile~stateitemextension.f90 sourcefile~stateitemextensionvector.f90 StateItemExtensionVector.F90 sourcefile~stateitemextensionvector.f90->sourcefile~stateitemextension.f90 sourcefile~stateregistry.f90 StateRegistry.F90 sourcefile~stateregistry.f90->sourcefile~stateitemextension.f90 sourcefile~test_extensionfamily.pf Test_ExtensionFamily.pf sourcefile~test_extensionfamily.pf->sourcefile~stateitemextension.f90 sourcefile~test_modelverticalgrid.pf Test_ModelVerticalGrid.pf sourcefile~test_modelverticalgrid.pf->sourcefile~stateitemextension.f90 sourcefile~test_stateregistry.pf Test_StateRegistry.pf sourcefile~test_stateregistry.pf->sourcefile~stateitemextension.f90

Source Code

#include "MAPL_Generic.h"

module mapl3g_GenericCoupler

   use mapl3g_CouplerPhases
   use mapl3g_CouplerMetaComponent
   use mapl3g_ExtensionAction
   use mapl3g_VerticalRegridAction
   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_time_varying(importState, exportState, _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_time_varying(importState, exportState, _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