Skip to content

Commit

Permalink
Merge pull request #2837 from GEOS-ESM/MAPL-v3/smods/generic3g/v3
Browse files Browse the repository at this point in the history
Submodule files for GriddedComponentDriver.F90
  • Loading branch information
tclune committed May 21, 2024
2 parents d872d15 + 998f9a8 commit 44dfddf
Show file tree
Hide file tree
Showing 12 changed files with 274 additions and 165 deletions.
2 changes: 1 addition & 1 deletion generic3g/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ set(srcs
ComponentDriver.F90
ComponentDriverVector.F90
GriddedComponentDriver.F90
GriddedComponentDriver_smod.F90
GriddedComponentDriverMap.F90

MultiState.F90
Expand Down Expand Up @@ -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
$<BUILD_INTERFACE:${MAPL_SOURCE_DIR}/include>)
Expand Down
13 changes: 13 additions & 0 deletions generic3g/GriddedComponentDriver/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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

)
23 changes: 23 additions & 0 deletions generic3g/GriddedComponentDriver/clock_advance.F90
Original file line number Diff line number Diff line change
@@ -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
36 changes: 36 additions & 0 deletions generic3g/GriddedComponentDriver/finalize.F90
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions generic3g/GriddedComponentDriver/get_clock.F90
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions generic3g/GriddedComponentDriver/get_states.F90
Original file line number Diff line number Diff line change
@@ -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
35 changes: 35 additions & 0 deletions generic3g/GriddedComponentDriver/initialize.F90
Original file line number Diff line number Diff line change
@@ -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
41 changes: 41 additions & 0 deletions generic3g/GriddedComponentDriver/run.F90
Original file line number Diff line number Diff line change
@@ -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
35 changes: 35 additions & 0 deletions generic3g/GriddedComponentDriver/run_export_couplers.F90
Original file line number Diff line number Diff line change
@@ -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
32 changes: 32 additions & 0 deletions generic3g/GriddedComponentDriver/run_import_couplers.F90
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions generic3g/GriddedComponentDriver/set_clock.F90
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit 44dfddf

Please sign in to comment.