Skip to content

Commit 91fe0ab

Browse files
Merge branch 'develop' into feature/borescan_edit_tile_name
2 parents 4a9a2a4 + f65854b commit 91fe0ab

File tree

2 files changed

+80
-6
lines changed

2 files changed

+80
-6
lines changed

GEOSogcm_GridComp/GEOSseaice_GridComp/CICE_GEOSPlug/CICE_GEOSPlug.F90

Lines changed: 79 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ module CICE_GEOSPlugMod
2323
use CICE_FinalMod
2424
use CICE_RunMod
2525
use ice_import_export
26+
use ice_record_mod
2627

2728

2829
implicit none
@@ -33,6 +34,7 @@ module CICE_GEOSPlugMod
3334

3435
integer :: NUM_ICE_CATEGORIES
3536
logical, private :: ice_grid_init2
37+
logical, private :: running_regular_replay
3638

3739
contains
3840

@@ -80,6 +82,7 @@ subroutine SetServices ( GC, RC )
8082
Iam = trim(COMP_NAME) // Iam
8183

8284
ice_grid_init2 = .false.
85+
running_regular_replay = .false.
8386

8487
call ESMF_ConfigGetAttribute(CF, NUM_ICE_CATEGORIES, Label="CICE_N_ICE_CATEGORIES:" , RC=STATUS)
8588
VERIFY_(STATUS)
@@ -91,6 +94,7 @@ subroutine SetServices ( GC, RC )
9194
call MAPL_GridCompSetEntryPoint ( GC, ESMF_METHOD_RUN, Run, _RC)
9295
call MAPL_GridCompSetEntryPoint ( GC, ESMF_METHOD_FINALIZE, Finalize, _RC)
9396
call MAPL_GridCompSetEntryPoint ( GC, ESMF_METHOD_WRITERESTART, Record, _RC)
97+
call MAPL_GridCompSetEntryPoint ( GC, ESMF_METHOD_READRESTART, Refresh, _RC)
9498

9599
! Set the state variable specs.
96100
! -----------------------------
@@ -435,6 +439,7 @@ subroutine Initialize ( GC, IMPORT, EXPORT, CLOCK, RC )
435439
integer :: OGCM_NX, OGCM_NY
436440
integer :: BLK_NX, BLK_NY
437441
integer :: counts(7)
442+
character(len=ESMF_MAXSTR) :: ReplayMode
438443

439444
! Locals with ESMF and MAPL types
440445

@@ -499,6 +504,7 @@ subroutine Initialize ( GC, IMPORT, EXPORT, CLOCK, RC )
499504

500505
call MAPL_GetResource(MAPL,DT_SEAICE, Label="RUN_DT:", _RC) ! Get AGCM Heartbeat
501506
call MAPL_GetResource(MAPL,DT_SEAICE, Label="OCEAN_DT:", DEFAULT=DT_SEAICE, _RC) ! set Default OCEAN_DT to AGCM Heartbeat
507+
call MAPL_GetResource(MAPL, ReplayMode, 'REPLAY_MODE:', default="NoReplay", _RC)
502508

503509
! Set the time for CICE
504510
!---------------------
@@ -574,6 +580,10 @@ subroutine Initialize ( GC, IMPORT, EXPORT, CLOCK, RC )
574580
!=====================================================================================
575581

576582

583+
if(adjustl(ReplayMode)=="Regular") then
584+
running_regular_replay = .true.
585+
call alloc_record_state
586+
endif
577587

578588
call MAPL_TimerOff(MAPL,"TOTAL" )
579589

@@ -943,18 +953,15 @@ subroutine Record ( GC, IMPORT, EXPORT, CLOCK, RC )
943953

944954
call MAPL_GetObjectFromGC ( GC, MAPL, _RC)
945955

946-
! Profilers
947-
!----------
948-
949956
call MAPL_TimerOn(MAPL,"TOTAL")
950957

958+
call MAPL_GenericRecord (GC, IMPORT, EXPORT, CLOCK, _RC)
959+
960+
951961
doRecord = MAPL_RecordAlarmIsRinging(MAPL, MODE=MAPL_Write2Disk, _RC)
952962

953963
if (doRecord) then
954964

955-
! Get the private internal state
956-
!--------------------------------
957-
958965

959966
call MAPL_DateStampGet(clock, timeStamp, _RC)
960967

@@ -965,11 +972,74 @@ subroutine Record ( GC, IMPORT, EXPORT, CLOCK, RC )
965972

966973
end if
967974

975+
doRecord = MAPL_RecordAlarmIsRinging(MAPL, MODE=MAPL_Write2Ram, _RC)
976+
977+
if (doRecord) then
978+
979+
! Save thermo states for replay corrector
980+
!-----------------
981+
982+
call save_record_state
983+
984+
end if
985+
968986
call MAPL_TimerOff(MAPL,"TOTAL")
969987
RETURN_(ESMF_SUCCESS)
970988

971989
end subroutine Record
972990

991+
! !IROUTINE: Refresh -- Refresh method (regular replay)
992+
993+
! !INTERFACE:
994+
995+
subroutine Refresh ( GC, IMPORT, EXPORT, CLOCK, RC )
996+
997+
! !ARGUMENTS:
998+
999+
type(ESMF_GridComp), intent(INOUT) :: GC ! Gridded component
1000+
type(ESMF_State), intent(INOUT) :: IMPORT ! Import state
1001+
type(ESMF_State), intent(INOUT) :: EXPORT ! Export state
1002+
type(ESMF_Clock), intent(INOUT) :: CLOCK ! The supervisor clock
1003+
integer, optional, intent( OUT) :: RC ! Error code
1004+
1005+
!EOP
1006+
1007+
type(MAPL_MetaComp), pointer :: MAPL
1008+
1009+
! ErrLog Variables
1010+
1011+
character(len=ESMF_MAXSTR) :: COMP_NAME
1012+
1013+
! Locals
1014+
character(len=14) :: timeStamp
1015+
logical :: doRecord
1016+
1017+
__Iam__('Restore')
1018+
1019+
! Get the target components name and set-up traceback handle.
1020+
! -----------------------------------------------------------
1021+
1022+
call ESMF_GridCompGet( GC, NAME=COMP_NAME, _RC)
1023+
Iam = trim(COMP_NAME)//'::'//Iam
1024+
1025+
! Get my internal MAPL_Generic state
1026+
!-----------------------------------
1027+
1028+
call MAPL_GetObjectFromGC ( GC, MAPL, _RC)
1029+
1030+
call MAPL_TimerOn(MAPL,"TOTAL")
1031+
1032+
! Restore thermo states for replay corrector
1033+
!-----------------
1034+
1035+
call restore_record_state
1036+
1037+
1038+
call MAPL_TimerOff(MAPL,"TOTAL")
1039+
RETURN_(ESMF_SUCCESS)
1040+
1041+
end subroutine Refresh
1042+
9731043
!====================================================================
9741044

9751045
! !IROUTINE: Finalize -- Finalize method for CICE wrapper
@@ -1077,6 +1147,9 @@ subroutine thermo_coupling(state, rc)
10771147
call ice_import_grid(FRO, rc=STATUS)
10781148
VERIFY_(STATUS)
10791149
call cice_init2
1150+
if (running_regular_replay) then
1151+
call save_record_state
1152+
endif
10801153
ice_grid_init2 = .TRUE.
10811154
endif
10821155

GEOSogcm_GridComp/GEOSseaice_GridComp/CICE_GEOSPlug/cice6_cmake/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ list( APPEND CICE6_SRCS
106106
cicecore/drivers/mapl/geos/ice_import_export.F90
107107
cicecore/drivers/mapl/geos/ice_shr_methods.F90
108108
cicecore/drivers/mapl/geos/ice_prescribed_mod.F90
109+
cicecore/drivers/mapl/geos/ice_record_mod.F90
109110
)
110111

111112

0 commit comments

Comments
 (0)