From 998f9a86f20c749ab6377a3da7066c84d9e5df49 Mon Sep 17 00:00:00 2001 From: Jules Kouatchou Date: Tue, 21 May 2024 08:59:17 -0400 Subject: [PATCH] Break the file GriddedComponentDriver_smod.F90 into individual submodule files --- generic3g/CMakeLists.txt | 2 +- .../GriddedComponentDriver/CMakeLists.txt | 13 ++ .../GriddedComponentDriver/clock_advance.F90 | 23 +++ generic3g/GriddedComponentDriver/finalize.F90 | 36 ++++ .../GriddedComponentDriver/get_clock.F90 | 19 ++ .../GriddedComponentDriver/get_states.F90 | 20 +++ .../GriddedComponentDriver/initialize.F90 | 35 ++++ generic3g/GriddedComponentDriver/run.F90 | 41 +++++ .../run_export_couplers.F90 | 35 ++++ .../run_import_couplers.F90 | 32 ++++ .../GriddedComponentDriver/set_clock.F90 | 19 ++ generic3g/GriddedComponentDriver_smod.F90 | 164 ------------------ 12 files changed, 274 insertions(+), 165 deletions(-) create mode 100644 generic3g/GriddedComponentDriver/CMakeLists.txt create mode 100644 generic3g/GriddedComponentDriver/clock_advance.F90 create mode 100644 generic3g/GriddedComponentDriver/finalize.F90 create mode 100644 generic3g/GriddedComponentDriver/get_clock.F90 create mode 100644 generic3g/GriddedComponentDriver/get_states.F90 create mode 100644 generic3g/GriddedComponentDriver/initialize.F90 create mode 100644 generic3g/GriddedComponentDriver/run.F90 create mode 100644 generic3g/GriddedComponentDriver/run_export_couplers.F90 create mode 100644 generic3g/GriddedComponentDriver/run_import_couplers.F90 create mode 100644 generic3g/GriddedComponentDriver/set_clock.F90 delete mode 100644 generic3g/GriddedComponentDriver_smod.F90 diff --git a/generic3g/CMakeLists.txt b/generic3g/CMakeLists.txt index d3f00e0f61a3..45788dea3d23 100644 --- a/generic3g/CMakeLists.txt +++ b/generic3g/CMakeLists.txt @@ -19,7 +19,6 @@ set(srcs ComponentDriver.F90 ComponentDriverVector.F90 GriddedComponentDriver.F90 - GriddedComponentDriver_smod.F90 GriddedComponentDriverMap.F90 MultiState.F90 @@ -66,6 +65,7 @@ add_subdirectory(actions) add_subdirectory(couplers) add_subdirectory(ComponentSpecParser) add_subdirectory(ESMF_HConfigUtilities) +add_subdirectory(GriddedComponentDriver) target_include_directories (${this} PUBLIC $) diff --git a/generic3g/GriddedComponentDriver/CMakeLists.txt b/generic3g/GriddedComponentDriver/CMakeLists.txt new file mode 100644 index 000000000000..5ab2d7d93559 --- /dev/null +++ b/generic3g/GriddedComponentDriver/CMakeLists.txt @@ -0,0 +1,13 @@ +target_sources(MAPL.generic3g PRIVATE + + initialize.F90 + run.F90 + finalize.F90 + get_states.F90 + get_clock.F90 + set_clock.F90 + run_export_couplers.F90 + run_import_couplers.F90 + clock_advance.F90 + +) diff --git a/generic3g/GriddedComponentDriver/clock_advance.F90 b/generic3g/GriddedComponentDriver/clock_advance.F90 new file mode 100644 index 000000000000..9b16e55b6863 --- /dev/null +++ b/generic3g/GriddedComponentDriver/clock_advance.F90 @@ -0,0 +1,23 @@ +#include "MAPL_ErrLog.h" + +submodule(mapl3g_GriddedComponentDriver) clock_advance_smod + use :: mapl_ErrorHandling + use :: mapl3g_OuterMetaComponent + use :: mapl3g_MethodPhasesMapUtils + use mapl3g_CouplerMetaComponent, only: GENERIC_COUPLER_INVALIDATE, GENERIC_COUPLER_UPDATE + implicit none + +contains + + module subroutine clock_advance(this, rc) + class(GriddedComponentDriver), intent(inout) :: this + integer, optional, intent(out) :: rc + + integer :: status + + call ESMF_ClockAdvance(this%clock, _RC) + + _RETURN(_SUCCESS) + end subroutine clock_advance + +end submodule clock_advance_smod diff --git a/generic3g/GriddedComponentDriver/finalize.F90 b/generic3g/GriddedComponentDriver/finalize.F90 new file mode 100644 index 000000000000..ef672ca17e77 --- /dev/null +++ b/generic3g/GriddedComponentDriver/finalize.F90 @@ -0,0 +1,36 @@ +#include "MAPL_ErrLog.h" + +submodule(mapl3g_GriddedComponentDriver) finalize_smod + use :: mapl_ErrorHandling + use :: mapl3g_OuterMetaComponent + use :: mapl3g_MethodPhasesMapUtils + use mapl3g_CouplerMetaComponent, only: GENERIC_COUPLER_INVALIDATE, GENERIC_COUPLER_UPDATE + implicit none + +contains + + module recursive subroutine finalize(this, unusable, phase_idx, rc) + class(GriddedComponentDriver), intent(inout) :: this + class(KE), optional, intent(in) :: unusable + integer, optional, intent(in) :: phase_idx + integer, optional, intent(out) :: rc + + integer :: status, user_status + + associate ( & + importState => this%states%importState, & + exportState => this%states%exportState) + + call ESMF_GridCompFinalize(this%gridcomp, & + importState=importState, exportState=exportState, clock=this%clock, & + phase=phase_idx, _USERRC) + + end associate + + call ESMF_GridCompDestroy(this%gridcomp, _RC) + + _RETURN(_SUCCESS) + _UNUSED_DUMMY(unusable) + end subroutine finalize + +end submodule finalize_smod diff --git a/generic3g/GriddedComponentDriver/get_clock.F90 b/generic3g/GriddedComponentDriver/get_clock.F90 new file mode 100644 index 000000000000..36c7735981e9 --- /dev/null +++ b/generic3g/GriddedComponentDriver/get_clock.F90 @@ -0,0 +1,19 @@ +#include "MAPL_ErrLog.h" + +submodule(mapl3g_GriddedComponentDriver) get_clock_smod + use :: mapl_ErrorHandling + use :: mapl3g_OuterMetaComponent + use :: mapl3g_MethodPhasesMapUtils + use mapl3g_CouplerMetaComponent, only: GENERIC_COUPLER_INVALIDATE, GENERIC_COUPLER_UPDATE + implicit none + +contains + + module function get_clock(this) result(clock) + type(ESMF_Clock) :: clock + class(GriddedComponentDriver), intent(in) :: this + + clock = this%clock + end function get_clock + +end submodule get_clock_smod diff --git a/generic3g/GriddedComponentDriver/get_states.F90 b/generic3g/GriddedComponentDriver/get_states.F90 new file mode 100644 index 000000000000..4e067a5951c5 --- /dev/null +++ b/generic3g/GriddedComponentDriver/get_states.F90 @@ -0,0 +1,20 @@ +#include "MAPL_ErrLog.h" + +submodule(mapl3g_GriddedComponentDriver) get_states_smod + use :: mapl_ErrorHandling + use :: mapl3g_OuterMetaComponent + use :: mapl3g_MethodPhasesMapUtils + use mapl3g_CouplerMetaComponent, only: GENERIC_COUPLER_INVALIDATE, GENERIC_COUPLER_UPDATE + implicit none + +contains + + module function get_states(this) result(states) + type(MultiState) :: states + class(GriddedComponentDriver), intent(in) :: this + + states = this%states + end function get_states + + +end submodule get_states_smod diff --git a/generic3g/GriddedComponentDriver/initialize.F90 b/generic3g/GriddedComponentDriver/initialize.F90 new file mode 100644 index 000000000000..e6e4b61c2fc7 --- /dev/null +++ b/generic3g/GriddedComponentDriver/initialize.F90 @@ -0,0 +1,35 @@ +#include "MAPL_ErrLog.h" + +submodule(mapl3g_GriddedComponentDriver) initialize_smod + use :: mapl_ErrorHandling + use :: mapl3g_OuterMetaComponent + use :: mapl3g_MethodPhasesMapUtils + use mapl3g_CouplerMetaComponent, only: GENERIC_COUPLER_INVALIDATE, GENERIC_COUPLER_UPDATE + implicit none + +contains + + + recursive module subroutine initialize(this, unusable, phase_idx, rc) + class(GriddedComponentDriver), intent(inout) :: this + class(KE), optional, intent(in) :: unusable + integer, optional, intent(in) :: phase_idx + integer, optional, intent(out) :: rc + + integer :: status, user_status + + associate ( & + importState => this%states%importState, & + exportState => this%states%exportState) + + call ESMF_GridCompInitialize(this%gridcomp, & + importState=importState, exportState=exportState, clock=this%clock, & + phase=phase_idx, _USERRC) + + end associate + + _RETURN(_SUCCESS) + _UNUSED_DUMMY(unusable) + end subroutine initialize + +end submodule initialize_smod diff --git a/generic3g/GriddedComponentDriver/run.F90 b/generic3g/GriddedComponentDriver/run.F90 new file mode 100644 index 000000000000..62a64b050cc7 --- /dev/null +++ b/generic3g/GriddedComponentDriver/run.F90 @@ -0,0 +1,41 @@ +#include "MAPL_ErrLog.h" + +submodule(mapl3g_GriddedComponentDriver) run_smod + use :: mapl_ErrorHandling + use :: mapl3g_OuterMetaComponent + use :: mapl3g_MethodPhasesMapUtils + use mapl3g_CouplerMetaComponent, only: GENERIC_COUPLER_INVALIDATE, GENERIC_COUPLER_UPDATE + implicit none + +contains + + module recursive subroutine run(this, unusable, phase_idx, rc) + class(GriddedComponentDriver), intent(inout) :: this + class(KE), optional, intent(in) :: unusable + integer, optional, intent(in) :: phase_idx + integer, optional, intent(out) :: rc + + integer :: status, user_status + + _ASSERT(present(phase_idx), 'until made not optional') + call this%run_import_couplers(_RC) + + associate ( & + importState => this%states%importState, & + exportState => this%states%exportState) + + call ESMF_GridCompRun(this%gridcomp, & + importState=importState, & + exportState=exportState, & + clock=this%clock, & + phase=phase_idx, _USERRC) + + end associate + + call this%run_export_couplers(phase_idx=phase_idx, _RC) + + _RETURN(_SUCCESS) + _UNUSED_DUMMY(unusable) + end subroutine run + +end submodule run_smod diff --git a/generic3g/GriddedComponentDriver/run_export_couplers.F90 b/generic3g/GriddedComponentDriver/run_export_couplers.F90 new file mode 100644 index 000000000000..b623d0f1add8 --- /dev/null +++ b/generic3g/GriddedComponentDriver/run_export_couplers.F90 @@ -0,0 +1,35 @@ +#include "MAPL_ErrLog.h" + +submodule(mapl3g_GriddedComponentDriver) run_export_couplers_smod + use :: mapl_ErrorHandling + use :: mapl3g_OuterMetaComponent + use :: mapl3g_MethodPhasesMapUtils + use mapl3g_CouplerMetaComponent, only: GENERIC_COUPLER_INVALIDATE, GENERIC_COUPLER_UPDATE + implicit none + +contains + + recursive module subroutine run_export_couplers(this, unusable, phase_idx, rc) + class(GriddedComponentDriver), intent(inout) :: this + class(KE), optional, intent(in) :: unusable + integer, optional, intent(in) :: phase_idx + integer, optional, intent(out) :: rc + + integer :: status + type(ComponentDriverVectorIterator) :: iter + class(ComponentDriver), pointer :: driver + + associate (e => this%export_couplers%ftn_end() ) + iter = this%export_couplers%ftn_begin() + do while (iter /= e) + call iter%next() + driver => iter%of() + call driver%run(phase_idx=GENERIC_COUPLER_INVALIDATE, _RC) + end do + end associate + + _RETURN(_SUCCESS) + _UNUSED_DUMMY(unusable) + end subroutine run_export_couplers + +end submodule run_export_couplers_smod diff --git a/generic3g/GriddedComponentDriver/run_import_couplers.F90 b/generic3g/GriddedComponentDriver/run_import_couplers.F90 new file mode 100644 index 000000000000..2c5a07e5afa7 --- /dev/null +++ b/generic3g/GriddedComponentDriver/run_import_couplers.F90 @@ -0,0 +1,32 @@ +#include "MAPL_ErrLog.h" + +submodule(mapl3g_GriddedComponentDriver) run_import_couplers_smod + use :: mapl_ErrorHandling + use :: mapl3g_OuterMetaComponent + use :: mapl3g_MethodPhasesMapUtils + use mapl3g_CouplerMetaComponent, only: GENERIC_COUPLER_INVALIDATE, GENERIC_COUPLER_UPDATE + implicit none + +contains + + recursive module subroutine run_import_couplers(this, rc) + class(GriddedComponentDriver), intent(inout) :: this + integer, optional, intent(out) :: rc + + integer :: status + type(ComponentDriverVectorIterator) :: iter + class(ComponentDriver), pointer :: driver + + associate (e => this%import_couplers%ftn_end() ) + iter = this%import_couplers%ftn_begin() + do while (iter /= e) + call iter%next() + driver => iter%of() + call driver%run(phase_idx=GENERIC_COUPLER_UPDATE, _RC) + end do + end associate + + _RETURN(_SUCCESS) + end subroutine run_import_couplers + +end submodule run_import_couplers_smod diff --git a/generic3g/GriddedComponentDriver/set_clock.F90 b/generic3g/GriddedComponentDriver/set_clock.F90 new file mode 100644 index 000000000000..6ca0cff7462c --- /dev/null +++ b/generic3g/GriddedComponentDriver/set_clock.F90 @@ -0,0 +1,19 @@ +#include "MAPL_ErrLog.h" + +submodule(mapl3g_GriddedComponentDriver) set_clock_smod + use :: mapl_ErrorHandling + use :: mapl3g_OuterMetaComponent + use :: mapl3g_MethodPhasesMapUtils + use mapl3g_CouplerMetaComponent, only: GENERIC_COUPLER_INVALIDATE, GENERIC_COUPLER_UPDATE + implicit none + +contains + + module subroutine set_clock(this, clock) + class(GriddedComponentDriver), intent(inout) :: this + type(ESMF_Clock), intent(in) :: clock + + this%clock = clock + end subroutine set_clock + +end submodule set_clock_smod diff --git a/generic3g/GriddedComponentDriver_smod.F90 b/generic3g/GriddedComponentDriver_smod.F90 deleted file mode 100644 index 31480c622bd1..000000000000 --- a/generic3g/GriddedComponentDriver_smod.F90 +++ /dev/null @@ -1,164 +0,0 @@ -#include "MAPL_ErrLog.h" - -submodule(mapl3g_GriddedComponentDriver) GriddedComponentDriver_run_smod - use :: mapl_ErrorHandling - use :: mapl3g_OuterMetaComponent - use :: mapl3g_MethodPhasesMapUtils - use mapl3g_CouplerMetaComponent, only: GENERIC_COUPLER_INVALIDATE, GENERIC_COUPLER_UPDATE - implicit none - -contains - - module recursive subroutine run(this, unusable, phase_idx, rc) - class(GriddedComponentDriver), intent(inout) :: this - class(KE), optional, intent(in) :: unusable - integer, optional, intent(in) :: phase_idx - integer, optional, intent(out) :: rc - - integer :: status, user_status - - _ASSERT(present(phase_idx), 'until made not optional') - call this%run_import_couplers(_RC) - - associate ( & - importState => this%states%importState, & - exportState => this%states%exportState) - - call ESMF_GridCompRun(this%gridcomp, & - importState=importState, & - exportState=exportState, & - clock=this%clock, & - phase=phase_idx, _USERRC) - - end associate - - call this%run_export_couplers(phase_idx=phase_idx, _RC) - - _RETURN(_SUCCESS) - _UNUSED_DUMMY(unusable) - end subroutine run - - recursive module subroutine initialize(this, unusable, phase_idx, rc) - class(GriddedComponentDriver), intent(inout) :: this - class(KE), optional, intent(in) :: unusable - integer, optional, intent(in) :: phase_idx - integer, optional, intent(out) :: rc - - integer :: status, user_status - - associate ( & - importState => this%states%importState, & - exportState => this%states%exportState) - - call ESMF_GridCompInitialize(this%gridcomp, & - importState=importState, exportState=exportState, clock=this%clock, & - phase=phase_idx, _USERRC) - - end associate - - _RETURN(_SUCCESS) - _UNUSED_DUMMY(unusable) - end subroutine initialize - - module recursive subroutine finalize(this, unusable, phase_idx, rc) - class(GriddedComponentDriver), intent(inout) :: this - class(KE), optional, intent(in) :: unusable - integer, optional, intent(in) :: phase_idx - integer, optional, intent(out) :: rc - - integer :: status, user_status - - associate ( & - importState => this%states%importState, & - exportState => this%states%exportState) - - call ESMF_GridCompFinalize(this%gridcomp, & - importState=importState, exportState=exportState, clock=this%clock, & - phase=phase_idx, _USERRC) - - end associate - - call ESMF_GridCompDestroy(this%gridcomp, _RC) - - _RETURN(_SUCCESS) - _UNUSED_DUMMY(unusable) - end subroutine finalize - - - module function get_clock(this) result(clock) - type(ESMF_Clock) :: clock - class(GriddedComponentDriver), intent(in) :: this - - clock = this%clock - end function get_clock - - module subroutine set_clock(this, clock) - class(GriddedComponentDriver), intent(inout) :: this - type(ESMF_Clock), intent(in) :: clock - - this%clock = clock - end subroutine set_clock - - - module function get_states(this) result(states) - type(MultiState) :: states - class(GriddedComponentDriver), intent(in) :: this - - states = this%states - end function get_states - - recursive module subroutine run_import_couplers(this, rc) - class(GriddedComponentDriver), intent(inout) :: this - integer, optional, intent(out) :: rc - - integer :: status - type(ComponentDriverVectorIterator) :: iter - class(ComponentDriver), pointer :: driver - - associate (e => this%import_couplers%ftn_end() ) - iter = this%import_couplers%ftn_begin() - do while (iter /= e) - call iter%next() - driver => iter%of() - call driver%run(phase_idx=GENERIC_COUPLER_UPDATE, _RC) - end do - end associate - - _RETURN(_SUCCESS) - end subroutine run_import_couplers - - recursive module subroutine run_export_couplers(this, unusable, phase_idx, rc) - class(GriddedComponentDriver), intent(inout) :: this - class(KE), optional, intent(in) :: unusable - integer, optional, intent(in) :: phase_idx - integer, optional, intent(out) :: rc - - integer :: status - type(ComponentDriverVectorIterator) :: iter - class(ComponentDriver), pointer :: driver - - associate (e => this%export_couplers%ftn_end() ) - iter = this%export_couplers%ftn_begin() - do while (iter /= e) - call iter%next() - driver => iter%of() - call driver%run(phase_idx=GENERIC_COUPLER_INVALIDATE, _RC) - end do - end associate - - _RETURN(_SUCCESS) - _UNUSED_DUMMY(unusable) - end subroutine run_export_couplers - - module subroutine clock_advance(this, rc) - class(GriddedComponentDriver), intent(inout) :: this - integer, optional, intent(out) :: rc - - integer :: status - - call ESMF_ClockAdvance(this%clock, _RC) - - _RETURN(_SUCCESS) - end subroutine clock_advance - -end submodule GriddedComponentDriver_run_smod