Skip to content

Commit 32a1fc1

Browse files
committed
Updating to new MAPL3
1 parent a41a330 commit 32a1fc1

File tree

2 files changed

+117
-117
lines changed

2 files changed

+117
-117
lines changed

GEOS_GcmGridComp.F90

Lines changed: 109 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ module GEOS_GcmGridCompMod
2626

2727
use GEOS_OgcmGridCompMod, only: OGCM_SetServices => SetServices
2828
use GEOS_WgcmGridCompMod, only: WGCM_SetServices => SetServices
29-
use MAPL_HistoryGridCompMod, only: Hist_SetServices => SetServices
30-
use MAPL_HistoryGridCompMod, only: HISTORY_ExchangeListWrap
3129
use iso_fortran_env
3230

3331
implicit none
@@ -89,7 +87,6 @@ module GEOS_GcmGridCompMod
8987
logical :: checkpointRequested = .false.
9088
character(len=ESMF_MAXSTR) :: checkpointFilename = ''
9189
character(len=ESMF_MAXSTR) :: checkpointFileType = ''
92-
type(ESMF_GridComp) :: history_parent
9390
logical :: run_history = .false.
9491

9592
! coupling to wave model
@@ -150,8 +147,8 @@ subroutine SetServices ( GC, RC )
150147

151148
type (T_GCM_STATE), pointer :: gcm_internal_state => null()
152149
type (GCM_wrap) :: wrap
153-
type (T_EXTDATA_STATE), pointer :: extdata_internal_state
154-
type (EXTDATA_wrap) :: ExtDataWrap
150+
!# type (T_EXTDATA_STATE), pointer :: extdata_internal_state
151+
!# type (EXTDATA_wrap) :: ExtDataWrap
155152
type (MAPL_MetaComp), pointer :: MAPL
156153
character(len=ESMF_MAXSTR) :: ReplayMode
157154
character(len=ESMF_MAXSTR) :: CONVPAR_OPTION
@@ -669,13 +666,13 @@ subroutine SetServices ( GC, RC )
669666
! If doing regular replay make state to "borrow" gc and import to ExtData
670667
! -----------------------------------------------------------------------
671668
if (rplRegular) then
672-
allocate( extdata_internal_state, stat=status)
673-
VERIFY_(STATUS)
674-
ExtDataWrap%ptr => extdata_internal_state
675-
call ESMF_UserCompSetInternalState( GC, 'ExtData_state',ExtDataWrap,status)
676-
VERIFY_(STATUS)
669+
!# allocate( extdata_internal_state, stat=status)
670+
!# VERIFY_(STATUS)
671+
!# ExtDataWrap%ptr => extdata_internal_state
672+
!# call ESMF_UserCompSetInternalState( GC, 'ExtData_state',ExtDataWrap,status)
673+
!# VERIFY_(STATUS)
677674

678-
call history_setservice(_RC)
675+
!# call history_setservice(_RC)
679676
end if
680677

681678
! Save pointer to the wrapped internal state in the GC
@@ -716,37 +713,37 @@ subroutine SetServices ( GC, RC )
716713

717714
contains
718715

719-
subroutine history_setservice(rc)
720-
integer, intent(out), optional :: rc
721-
722-
integer :: status
723-
type(ESMF_Config) :: hist_cf, gcm_cf
724-
type(MAPL_MetaComp), pointer :: history_metaobj
725-
type(StubComponent) :: stub_component
726-
integer :: run_dt
727-
character(len=ESMF_MAXSTR) :: replay_history
728-
logical :: is_present
729-
730-
call ESMF_GridCompGet(gc,config=gcm_cf,_RC)
731-
call ESMF_ConfigFindLabel(gcm_cf,"REPLAY_HISTORY_RC:",isPresent=is_present,_RC)
732-
733-
if (is_present) then
734-
gcm_internal_state%run_history = .true.
735-
call MAPL_GetResource(MAPL,replay_history,"REPLAY_HISTORY_RC:",_RC)
736-
hist_cf = ESMF_ConfigCreate(_RC)
737-
call ESMF_ConfigLoadFile(hist_cf,trim(replay_history),_RC)
738-
call MAPL_GetResource(MAPL,run_dt,"RUN_DT:",_RC)
739-
call MAPL_ConfigSetAttribute(hist_cf,value=run_dt,label="RUN_DT:",_RC)
740-
call MAPL_ConfigSetAttribute(hist_cf,value=replay_history,label="HIST_CF:",_RC)
741-
gcm_internal_state%history_parent = ESMF_GridCompCreate(name="History_GCM_parent",config=hist_cf,_RC)
742-
history_metaobj => null()
743-
call MAPL_InternalStateCreate(gcm_internal_state%history_parent,history_metaobj,_RC)
744-
call MAPL_Set(history_metaobj,cf=hist_cf,name="History_GCM_parent",component=stub_component,_RC)
745-
hist = MAPL_AddChild(history_metaobj,name="History_GCM",ss=hist_setservices,_RC)
746-
end if
747-
_RETURN(_SUCCESS)
748-
end subroutine history_setservice
749-
716+
!# subroutine history_setservice(rc)
717+
!# integer, intent(out), optional :: rc
718+
!#
719+
!# integer :: status
720+
!# type(ESMF_Config) :: hist_cf, gcm_cf
721+
!# type(MAPL_MetaComp), pointer :: history_metaobj
722+
!# type(StubComponent) :: stub_component
723+
!# integer :: run_dt
724+
!# character(len=ESMF_MAXSTR) :: replay_history
725+
!# logical :: is_present
726+
!#
727+
!# call ESMF_GridCompGet(gc,config=gcm_cf,_RC)
728+
!# call ESMF_ConfigFindLabel(gcm_cf,"REPLAY_HISTORY_RC:",isPresent=is_present,_RC)
729+
!#
730+
!# if (is_present) then
731+
!# gcm_internal_state%run_history = .true.
732+
!# call MAPL_GetResource(MAPL,replay_history,"REPLAY_HISTORY_RC:",_RC)
733+
!# hist_cf = ESMF_ConfigCreate(_RC)
734+
!# call ESMF_ConfigLoadFile(hist_cf,trim(replay_history),_RC)
735+
!# call MAPL_GetResource(MAPL,run_dt,"RUN_DT:",_RC)
736+
!# call MAPL_ConfigSetAttribute(hist_cf,value=run_dt,label="RUN_DT:",_RC)
737+
!# call MAPL_ConfigSetAttribute(hist_cf,value=replay_history,label="HIST_CF:",_RC)
738+
!# gcm_internal_state%history_parent = ESMF_GridCompCreate(name="History_GCM_parent",config=hist_cf,_RC)
739+
!# history_metaobj => null()
740+
!# call MAPL_InternalStateCreate(gcm_internal_state%history_parent,history_metaobj,_RC)
741+
!# call MAPL_Set(history_metaobj,cf=hist_cf,name="History_GCM_parent",component=stub_component,_RC)
742+
!# hist = MAPL_AddChild(history_metaobj,name="History_GCM",ss=hist_setservices,_RC)
743+
!# end if
744+
!# _RETURN(_SUCCESS)
745+
!# end subroutine history_setservice
746+
!#
750747
subroutine OBIO_TerminateImports(DO_DATA_ATM4OCN, RC)
751748

752749
logical, intent(IN ) :: DO_DATA_ATM4OCN
@@ -1486,9 +1483,9 @@ subroutine Initialize ( GC, IMPORT, EXPORT, CLOCK, RC )
14861483
if ( MAPL_am_I_root() ) call ESMF_StatePrint ( EXPORT, rc=STATUS )
14871484
#endif
14881485

1489-
if(gcm_internal_state%rplRegular .and. gcm_internal_state%run_history) then
1490-
call initialize_history(_RC)
1491-
end if
1486+
!# if(gcm_internal_state%rplRegular .and. gcm_internal_state%run_history) then
1487+
!# call initialize_history(_RC)
1488+
!# end if
14921489

14931490
call MAPL_TimerOff(MAPL,"TOTAL")
14941491
call MAPL_TimerOff(MAPL,"INITIALIZE")
@@ -1497,41 +1494,41 @@ subroutine Initialize ( GC, IMPORT, EXPORT, CLOCK, RC )
14971494

14981495
contains
14991496

1500-
subroutine initialize_history(rc)
1501-
integer, optional, intent(Out) :: rc
1502-
1503-
integer :: status,user_status
1504-
type(ESMF_State), allocatable :: gcm_exports(:),hist_imports(:),hist_exports(:)
1505-
type(ESMF_GridComp), allocatable :: hist_gcs(:)
1506-
type(ESMF_GridComp), allocatable :: gcm_gcs(:)
1507-
type(MAPL_MetaComp), pointer :: history_metaobj
1508-
type(HISTORY_ExchangeListWrap) :: lswrap
1509-
integer(kind=INT64), pointer :: LSADDR(:) => null()
1510-
1511-
call MAPL_GetObjectFromGC ( gcm_internal_state%history_parent, history_metaobj, _RC)
1512-
1513-
call MAPL_Get(mapl,childrens_export_states = gcm_exports, childrens_gridcomps = gcm_gcs, _RC)
1514-
1515-
call MAPL_Get(history_metaobj, &
1516-
childrens_export_states = hist_exports, &
1517-
childrens_import_states = hist_imports, &
1518-
childrens_gridcomps = hist_gcs, _RC)
1519-
1520-
allocate(lswrap%ptr, stat = status)
1521-
_VERIFY(STATUS)
1522-
call ESMF_UserCompSetInternalState(hist_gcs(hist), 'MAPL_LocStreamList', &
1523-
lswrap, _RC)
1524-
call MAPL_GetAllExchangeGrids(gcm_gcs(agcm), LSADDR, _RC)
1525-
lswrap%ptr%LSADDR_PTR => LSADDR
1526-
1527-
call ESMF_StateAdd(hist_imports(hist),[gcm_exports(agcm)],_RC)
1528-
call ESMF_GridCompInitialize(hist_gcs(hist),importState=hist_imports(hist),&
1529-
exportState=hist_exports(hist),&
1530-
clock=clock,userRC=user_status,_RC)
1531-
1532-
_RETURN(_SUCCESS)
1533-
end subroutine initialize_history
1534-
1497+
!# subroutine initialize_history(rc)
1498+
!# integer, optional, intent(Out) :: rc
1499+
!#
1500+
!# integer :: status,user_status
1501+
!# type(ESMF_State), allocatable :: gcm_exports(:),hist_imports(:),hist_exports(:)
1502+
!# type(ESMF_GridComp), allocatable :: hist_gcs(:)
1503+
!# type(ESMF_GridComp), allocatable :: gcm_gcs(:)
1504+
!# type(MAPL_MetaComp), pointer :: history_metaobj
1505+
!# type(HISTORY_ExchangeListWrap) :: lswrap
1506+
!# integer(kind=INT64), pointer :: LSADDR(:) => null()
1507+
!#
1508+
!# call MAPL_GetObjectFromGC ( gcm_internal_state%history_parent, history_metaobj, _RC)
1509+
!#
1510+
!# call MAPL_Get(mapl,childrens_export_states = gcm_exports, childrens_gridcomps = gcm_gcs, _RC)
1511+
!#
1512+
!# call MAPL_Get(history_metaobj, &
1513+
!# childrens_export_states = hist_exports, &
1514+
!# childrens_import_states = hist_imports, &
1515+
!# childrens_gridcomps = hist_gcs, _RC)
1516+
!#
1517+
!# allocate(lswrap%ptr, stat = status)
1518+
!# _VERIFY(STATUS)
1519+
!# call ESMF_UserCompSetInternalState(hist_gcs(hist), 'MAPL_LocStreamList', &
1520+
!# lswrap, _RC)
1521+
!# call MAPL_GetAllExchangeGrids(gcm_gcs(agcm), LSADDR, _RC)
1522+
!# lswrap%ptr%LSADDR_PTR => LSADDR
1523+
!#
1524+
!# call ESMF_StateAdd(hist_imports(hist),[gcm_exports(agcm)],_RC)
1525+
!# call ESMF_GridCompInitialize(hist_gcs(hist),importState=hist_imports(hist),&
1526+
!# exportState=hist_exports(hist),&
1527+
!# clock=clock,userRC=user_status,_RC)
1528+
!#
1529+
!# _RETURN(_SUCCESS)
1530+
!# end subroutine initialize_history
1531+
!#
15351532
subroutine AllocateExports(STATE, NAMES, RC)
15361533
type(ESMF_State) , intent(INOUT) :: STATE
15371534
character(len=*) , intent(IN ) :: NAMES(:)
@@ -1656,8 +1653,8 @@ subroutine Run ( GC, IMPORT, EXPORT, CLOCK, RC )
16561653

16571654
type (T_GCM_STATE), pointer :: gcm_internal_state => null()
16581655
type (GCM_wrap) :: wrap
1659-
type (T_ExtData_STATE), pointer :: ExtData_internal_state => null()
1660-
type (ExtData_wrap) :: ExtDatawrap
1656+
!# type (T_ExtData_STATE), pointer :: ExtData_internal_state => null()
1657+
!# type (ExtData_wrap) :: ExtDatawrap
16611658
type (ESMF_State) :: Dummy
16621659

16631660
type(ESMF_Alarm) :: alarm
@@ -1744,9 +1741,9 @@ subroutine Run ( GC, IMPORT, EXPORT, CLOCK, RC )
17441741

17451742
call MAPL_TimerON(MAPL,"--REPLAY" )
17461743

1747-
call ESMF_UserCompGetInternalState(gc, 'ExtData_state', ExtDatawrap, status)
1748-
VERIFY_(STATUS)
1749-
ExtData_internal_state => ExtDatawrap%ptr
1744+
!# call ESMF_UserCompGetInternalState(gc, 'ExtData_state', ExtDatawrap, status)
1745+
!# VERIFY_(STATUS)
1746+
!# ExtData_internal_state => ExtDatawrap%ptr
17501747

17511748
shutoffRpl = ESMF_AlarmIsRinging(GCM_INTERNAL_STATE%replayShutoffAlarm, RC=STATUS)
17521749
VERIFY_(STATUS)
@@ -1843,8 +1840,8 @@ subroutine Run ( GC, IMPORT, EXPORT, CLOCK, RC )
18431840
PREDICTOR_TIME_LOOP: do
18441841
! Run the ExtData Gridded Component
18451842
! ---------------------------------
1846-
call ESMF_GridCompRun ( ExtData_internal_state%gc, importState=dummy, exportState=ExtData_internal_state%ExpState, clock=clock, userRC=status )
1847-
VERIFY_(STATUS)
1843+
!# call ESMF_GridCompRun ( ExtData_internal_state%gc, importState=dummy, exportState=ExtData_internal_state%ExpState, clock=clock, userRC=status )
1844+
!# VERIFY_(STATUS)
18481845

18491846
! Run the AGCM Gridded Component
18501847
! ------------------------------
@@ -1927,7 +1924,7 @@ subroutine Run ( GC, IMPORT, EXPORT, CLOCK, RC )
19271924
VERIFY_(STATUS)
19281925

19291926
if (gcm_internal_state%run_history) then
1930-
call run_history(_RC)
1927+
!# call run_history(_RC)
19311928
end if
19321929

19331930
DONE = ESMF_AlarmIsRinging(GCM_INTERNAL_STATE%replayStopAlarm, RC=STATUS)
@@ -1984,9 +1981,9 @@ subroutine Run ( GC, IMPORT, EXPORT, CLOCK, RC )
19841981
VERIFY_(STATUS)
19851982
endif
19861983

1987-
call ESMF_GridCompRun ( ExtData_internal_state%gc, importState=dummy, &
1988-
exportState=ExtData_internal_state%ExpState, clock=clock, userRC=status )
1989-
VERIFY_(STATUS)
1984+
!# call ESMF_GridCompRun ( ExtData_internal_state%gc, importState=dummy, &
1985+
!# exportState=ExtData_internal_state%ExpState, clock=clock, userRC=status )
1986+
!# VERIFY_(STATUS)
19901987

19911988
end if
19921989

@@ -2078,27 +2075,27 @@ subroutine Run ( GC, IMPORT, EXPORT, CLOCK, RC )
20782075
RETURN_(ESMF_SUCCESS)
20792076
contains
20802077

2081-
subroutine run_history(rc)
2082-
integer, optional, intent(out) :: rc
2083-
2084-
integer :: user_status,status
2085-
type(ESMF_State), allocatable :: gcm_exports(:),hist_imports(:),hist_exports(:)
2086-
type(ESMF_GridComp), allocatable :: hist_gcs(:)
2087-
type(MAPL_MetaComp), pointer :: history_metaobj
2088-
2089-
call MAPL_GetObjectFromGC ( gcm_internal_state%history_parent, history_metaobj, _RC)
2090-
2091-
call MAPL_Get(history_metaobj, &
2092-
childrens_export_states = hist_exports, &
2093-
childrens_import_states = hist_imports, &
2094-
childrens_gridcomps = hist_gcs, _RC)
2095-
2096-
call ESMF_GridCompRun(hist_gcs(hist),importState=hist_imports(hist),&
2097-
exportState=hist_exports(hist),&
2098-
clock=clock,userRC=user_status,_RC)
2099-
_RETURN(_SUCCESS)
2100-
2101-
end subroutine run_history
2078+
!# subroutine run_history(rc)
2079+
!# integer, optional, intent(out) :: rc
2080+
!#
2081+
!# integer :: user_status,status
2082+
!# type(ESMF_State), allocatable :: gcm_exports(:),hist_imports(:),hist_exports(:)
2083+
!# type(ESMF_GridComp), allocatable :: hist_gcs(:)
2084+
!# type(MAPL_MetaComp), pointer :: history_metaobj
2085+
!#
2086+
!# call MAPL_GetObjectFromGC ( gcm_internal_state%history_parent, history_metaobj, _RC)
2087+
!#
2088+
!# call MAPL_Get(history_metaobj, &
2089+
!# childrens_export_states = hist_exports, &
2090+
!# childrens_import_states = hist_imports, &
2091+
!# childrens_gridcomps = hist_gcs, _RC)
2092+
!#
2093+
!# call ESMF_GridCompRun(hist_gcs(hist),importState=hist_imports(hist),&
2094+
!# exportState=hist_exports(hist),&
2095+
!# clock=clock,userRC=user_status,_RC)
2096+
!# _RETURN(_SUCCESS)
2097+
!#
2098+
!# end subroutine run_history
21022099

21032100
subroutine RUN_OCEAN(phase, rc)
21042101
integer, optional, intent(IN) :: phase

GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSgwd_GridComp/GEOS_GwdGridComp.F90

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ module GEOS_GwdGridCompMod
4848
use mapl3g_RestartModes, only: MAPL_RESTART_SKIP
4949
use mapl3g_VerticalStaggerLoc, only: VERTICAL_STAGGER_NONE, VERTICAL_STAGGER_CENTER, VERTICAL_STAGGER_EDGE
5050
use mapl3g_UngriddedDims, only: UngriddedDims
51-
use mapl3g_Geom_API, only: MAPL_GridGet
51+
use mapl3g_Geom_API, only: MAPL_GridGet, MAPL_GridGetCoordinates
5252
use mapl3g_State_API, only: MAPL_StateGetPointer
5353
use mapl3g_UngriddedDim, only: UngriddedDim
5454

@@ -226,7 +226,8 @@ subroutine Initialize ( GC, IMPORT, EXPORT, CLOCK, RC )
226226

227227
type(ESMF_Grid) :: grid
228228
integer :: IM, JM !, dims_(3)
229-
real, pointer, dimension(:,:) :: LATS
229+
real, allocatable, dimension(:,:) :: LONS
230+
real, allocatable, dimension(:,:) :: LATS
230231

231232
character(len=:), allocatable :: GRIDNAME
232233
character(len=4) :: imchar
@@ -284,7 +285,8 @@ subroutine Initialize ( GC, IMPORT, EXPORT, CLOCK, RC )
284285

285286
! Grid info
286287
call MAPL_GridCompGet(gc, grid=grid, num_levels=LM, _RC)
287-
call MAPL_GridGet(grid, im=IM, jm=JM, latitudes=lats, _RC)
288+
call MAPL_GridGet(grid, im=IM, jm=JM, _RC)
289+
call MAPL_GridGetCoordinates(grid, longitudes=lons, latitudes=lats, _RC)
288290

289291
! Get grid name to determine IMSIZE
290292
call MAPL_GridCompGetResource(gc, 'AGCM.GRIDNAME', GRIDNAME, _RC)
@@ -461,7 +463,8 @@ subroutine RUN ( GC, IMPORT, EXPORT, CLOCK, RC )
461463
!real :: effgworo, effgwbkg
462464
!real :: CDMBGWD1, CDMBGWD2
463465
!real :: bgstressmax
464-
real, pointer, dimension(:,:) :: LATS
466+
real, allocatable, dimension(:,:) :: LONS
467+
real, allocatable, dimension(:,:) :: LATS
465468
! Rayleigh friction parameters
466469

467470
REAL :: H0, HH, Z1, TAU1
@@ -499,7 +502,7 @@ subroutine RUN ( GC, IMPORT, EXPORT, CLOCK, RC )
499502

500503
! Grid info
501504
call MAPL_GridCompGet(gc, grid=grid, num_levels=LM, _RC)
502-
call MAPL_GridGet(grid, im=IM, jm=JM, latitudes=lats, _RC)
505+
call MAPL_GridGetCoordinates(grid, longitudes=lons, latitudes=lats, _RC)
503506

504507
! call ESMF_ClockGetAlarm(clock,
505508

0 commit comments

Comments
 (0)