Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for CICE6(or others) to rewind #2982

Merged
merged 6 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add ability to use an `ESMF_CONFIG_FILE` environment variable to specify name of file to pass in pre-`ESMF_Initialize` options to ESMF (see [ESMF Docs](https://earthsystemmodeling.org/docs/release/latest/ESMF_refdoc/node4.html#SECTION04024000000000000000) for allowed flags.
- Allow lat-lon grid factory to detect and use CF compliant lat-lon bounds in a file when making a grid
- PFIO/Variable class, new procedures to retrieve string/reals/int attributes from a variable
- Added a call in GenericRefresh to allow GC's refresh method to be called; in support
of CICE6 rewind

### Changed

Expand Down
42 changes: 41 additions & 1 deletion generic/MAPL_Generic.F90
Original file line number Diff line number Diff line change
Expand Up @@ -351,11 +351,32 @@ module MAPL_GenericMod
module procedure MAPL_AddAttributeToFields_I4
end interface

interface
subroutine i_Run(gc, import_state, export_state, clock, rc)
use mapl_KeywordEnforcerMod
use ESMF
implicit none
type(ESMF_GridComp) :: gc
type(ESMF_State):: import_state
type(ESMF_State) :: export_state
type(ESMF_Clock) :: clock
integer, intent(out) :: rc
end subroutine i_Run
end interface

! =======================================================================


integer, parameter :: LAST_ALARM = 99

! The next variable is the lesser of two evils: we need a flag the represents MAPL_CustomRefresh
! In PR 28xx the assuption was that we could use ESMF_ReadRestart, which has other issues
! Here we intention us ESMF_Method_None, since it is very unlikely someone in the GEOS/MAPL
! community will use that flag

type (ESMF_Method_Flag), public :: MAPL_Method_Refresh = ESMF_Method_None
integer, parameter, public :: MAPL_CustomRefreshPhase = 99

type MAPL_GenericWrap
type(MAPL_MetaComp ), pointer :: MAPLOBJ
end type MAPL_GenericWrap
Expand Down Expand Up @@ -425,7 +446,9 @@ module MAPL_GenericMod
integer , pointer :: phase_final(:) => null()
integer , pointer :: phase_record(:) => null()
integer , pointer :: phase_coldstart(:)=> null()

integer , pointer :: phase_refresh(:)=> null()
procedure(i_run), public, nopass, pointer :: customRefresh => null()

! Make accessors?
type(ESMF_GridComp) :: RootGC
type(ESMF_GridComp) , pointer :: parentGC => null()
Expand Down Expand Up @@ -2753,6 +2776,7 @@ recursive subroutine MAPL_GenericRefresh ( GC, IMPORT, EXPORT, CLOCK, RC )
character(len=ESMF_MAXSTR) :: CHILD_NAME
character(len=14) :: datestamp ! YYYYMMDD_HHMMz
integer :: status
integer :: UserRC
integer :: I
type (MAPL_MetaComp), pointer :: STATE
character(len=1) :: separator
Expand Down Expand Up @@ -2857,6 +2881,16 @@ recursive subroutine MAPL_GenericRefresh ( GC, IMPORT, EXPORT, CLOCK, RC )
! call the actual record method
call MAPL_StateRefresh (GC, IMPORT, EXPORT, CLOCK, RC=status )
_VERIFY(status)

! I_Run
if (associated(STATE%customRefresh)) then
call ESMF_GridCompInitialize(GC, importState=import, &
exportState=export, clock=CLOCK, &
phase=MAPL_CustomRefreshPhase, &
userRC=userRC, _RC)
_VERIFY(userRC)
endif

endif
call MAPL_TimerOff(STATE,"GenRefreshMine",_RC)
call MAPL_TimerOff(STATE,"GenRefreshTot",_RC)
Expand Down Expand Up @@ -3982,6 +4016,12 @@ subroutine MAPL_GridCompSetEntryPoint(GC, registeredMethod, usersRoutine, RC)
phase = MAPL_AddMethod(META%phase_record, RC=status)
else if (registeredMethod == ESMF_METHOD_READRESTART) then
phase = MAPL_AddMethod(META%phase_coldstart, RC=status)
else if (registeredMethod == MAPL_METHOD_REFRESH) then
phase = MAPL_AddMethod(META%phase_refresh, RC=status)
meta%customRefresh => usersRoutine
call ESMF_GridCompSetEntryPoint(GC, ESMF_METHOD_INITIALIZE, &
usersRoutine, phase=MAPL_CustomRefreshPhase, _RC)
_RETURN(ESMF_SUCCESS)
else
_RETURN(ESMF_FAILURE)
endif
Expand Down
Loading