Skip to content

Commit da40a76

Browse files
committed
Modify AdvCore SetServices to make use of FV_Setup; use IM,JM,LM tokens when AdvCore advection is running
1 parent a044536 commit da40a76

File tree

2 files changed

+31
-57
lines changed

2 files changed

+31
-57
lines changed

AdvCore_GridCompMod.F90

Lines changed: 15 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ module AdvCore_GridCompMod
6666
use fv_grid_utils_mod, only: g_sum
6767

6868
USE FV_StateMod, only: AdvCoreTracers => T_TRACERS
69-
USE FV_StateMod, only: FV_Atm
69+
USE FV_StateMod, only: FV_Atm, FV_setup
7070
use CubeGridPrototype, only: register_grid_and_regridders
7171

7272
implicit none
@@ -129,6 +129,7 @@ subroutine SetServices(GC, rc)
129129
type(ESMF_VM) :: VM
130130
integer :: comm, ndt
131131
integer :: p_split=1
132+
character(len=ESMF_MAXSTR) :: LAYOUT_FILE
132133

133134
!=============================================================================
134135

@@ -253,75 +254,34 @@ subroutine SetServices(GC, rc)
253254
call MAPL_GridCompSetEntryPoint ( gc, ESMF_METHOD_FINALIZE, Finalize, RC=status)
254255
VERIFY_(STATUS)
255256

256-
! Check if AdvCore is running without FV3_DynCoreIsRunning, if yes then setup the MAPL Grid
257-
! ----------------------------------------------------------------------------
257+
! Check if AdvCore is running without FV3_DynCoreIsRunning, if yes then setup the MAPL Grid
258+
! ----------------------------------------------------------------------------
258259
call MAPL_GetObjectFromGC (GC, MAPL, RC=STATUS )
259260
VERIFY_(STATUS)
260261
call MAPL_GetResource(MAPL, DYCORE, 'DYCORE:', default="", RC=STATUS )
261262
VERIFY_(STATUS)
262263
call MAPL_GetResource(MAPL, AdvCore_Advection , label='AdvCore_Advection:', &
263264
default=AdvCore_Advection, RC=STATUS )
264265
VERIFY_(STATUS)
265-
if(adjustl(DYCORE)=="FV3") FV3_DynCoreIsRunning = .true.
266-
if(adjustl(DYCORE)=="FV3+ADV") FV3_DynCoreIsRunning = .true.
267266

268-
! Start up FMS/MPP
269-
!-------------------------------------------
270-
call ESMF_VMGet(VM,mpiCommunicator=comm,rc=STATUS)
271-
VERIFY_(STATUS)
272-
call fms_init(comm)
267+
! Setup FMS/FV3
268+
!--------------
269+
call MAPL_GetResource ( MAPL, LAYOUT_FILE, 'LAYOUT:', default='fvcore_layout.rc', rc=status )
273270
VERIFY_(STATUS)
271+
call FV_Setup(GC, LAYOUT_FILE)
274272

275-
if (.NOT. FV3_DynCoreIsRunning) then
276-
! Make sure FV3 is setup
277-
! -----------------------
278-
call register_grid_and_regridders()
279-
call fv_init1(FV_Atm, dt, grids_on_my_pe, p_split)
280-
! Get Domain decomposition
281-
!-------------------------
282-
call MAPL_GetResource( MAPL, nx, 'NX:', default=0, RC=STATUS )
283-
VERIFY_(STATUS)
284-
FV_Atm(1)%layout(1) = nx
285-
call MAPL_GetResource( MAPL, ny, 'NY:', default=0, RC=STATUS )
286-
VERIFY_(STATUS)
287-
if (FV_Atm(1)%flagstruct%grid_type == 4) then
288-
FV_Atm(1)%layout(2) = ny
289-
else
290-
FV_Atm(1)%layout(2) = ny / 6
291-
end if
292-
! Get Resolution Information
293-
!---------------------------
294-
! FV grid dimensions setup from MAPL
295-
call MAPL_GetResource( MAPL, FV_Atm(1)%flagstruct%npx, 'IM:', default= 32, RC=STATUS )
296-
VERIFY_(STATUS)
297-
call MAPL_GetResource( MAPL, FV_Atm(1)%flagstruct%npy, 'JM:', default=192, RC=STATUS )
298-
VERIFY_(STATUS)
299-
call MAPL_GetResource( MAPL, FV_Atm(1)%flagstruct%npz, 'LM:', default= 72, RC=STATUS )
300-
VERIFY_(STATUS)
301-
! FV likes npx;npy in terms of cell vertices
302-
if (FV_Atm(1)%flagstruct%npy == 6*FV_Atm(1)%flagstruct%npx) then
303-
FV_Atm(1)%flagstruct%ntiles = 6
304-
FV_Atm(1)%flagstruct%npy = FV_Atm(1)%flagstruct%npx+1
305-
FV_Atm(1)%flagstruct%npx = FV_Atm(1)%flagstruct%npx+1
306-
else
307-
FV_Atm(1)%flagstruct%ntiles = 1
308-
FV_Atm(1)%flagstruct%npy = FV_Atm(1)%flagstruct%npy+1
309-
FV_Atm(1)%flagstruct%npx = FV_Atm(1)%flagstruct%npx+1
310-
endif
311-
endif
273+
! Register prototype of cubed sphere grid and associated regridders
274+
!------------------------------------------------------------------
275+
call register_grid_and_regridders()
312276

277+
! Read DT in case it is ever used by offline_tracer_advection
278+
!------------------------------------------------------------
313279
call MAPL_GetResource( MAPL, ndt, 'RUN_DT:', default=0, RC=STATUS )
314280
VERIFY_(STATUS)
315281
DT = ndt
316282

317-
! Start up FV if AdvCore is running without FV3_DynCoreIsRunning
318-
!--------------------------------------------------
319-
if (.NOT. FV3_DynCoreIsRunning) then
320-
call fv_init2(FV_Atm, dt, grids_on_my_pe, p_split)
321-
end if
322-
323-
! Ending with a Generic SetServices call is a MAPL requirement
324-
!-------------------------------------------------------------
283+
! Ending with a Generic SetServices call is a MAPL requirement
284+
!-------------------------------------------------------------
325285
call MAPL_GenericSetServices ( GC, rc=STATUS)
326286
VERIFY_(STATUS)
327287

FV_StateMod.F90

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,13 +358,27 @@ subroutine FV_Setup(GC,LAYOUT_FILE, RC)
358358
if (FV_Atm(1)%flagstruct%npz == 1) SW_DYNAMICS = .true.
359359

360360

361+
call MAPL_GetResource( MAPL, AdvCore_Advection, label='AdvCore_Advection:', default=AdvCore_Advection, rc=status )
362+
VERIFY_(STATUS)
363+
361364
! FV grid dimensions setup from MAPL
365+
! Advect core expects to find IM/JM/LM in the resource file not AGCM_IM/AGCM_JM/AGCM_LM
366+
if (AdvCore_Advection == 1) then
367+
call MAPL_GetResource( MAPL, FV_Atm(1)%flagstruct%npx, 'IM:', default= 32, RC=STATUS )
368+
VERIFY_(STATUS)
369+
call MAPL_GetResource( MAPL, FV_Atm(1)%flagstruct%npy, 'JM:', default=192, RC=STATUS )
370+
VERIFY_(STATUS)
371+
call MAPL_GetResource( MAPL, FV_Atm(1)%flagstruct%npz, 'LM:', default= 72, RC=STATUS )
372+
VERIFY_(STATUS)
373+
else
362374
call MAPL_GetResource( MAPL, FV_Atm(1)%flagstruct%npx, 'AGCM_IM:', default= 32, RC=STATUS )
363375
VERIFY_(STATUS)
364376
call MAPL_GetResource( MAPL, FV_Atm(1)%flagstruct%npy, 'AGCM_JM:', default=192, RC=STATUS )
365377
VERIFY_(STATUS)
366378
call MAPL_GetResource( MAPL, FV_Atm(1)%flagstruct%npz, 'AGCM_LM:', default= 72, RC=STATUS )
367379
VERIFY_(STATUS)
380+
endif
381+
368382
! FV likes npx;npy in terms of cell vertices
369383
if (FV_Atm(1)%flagstruct%npy == 6*FV_Atm(1)%flagstruct%npx) then
370384
FV_Atm(1)%flagstruct%ntiles = 6
@@ -397,8 +411,8 @@ subroutine FV_Setup(GC,LAYOUT_FILE, RC)
397411
VERIFY_(STATUS)
398412
DT = ndt
399413

400-
! Advect tracers within DynCore(AdvCore_Advection=.false.)
401-
! or within AdvCore(AdvCore_Advection=.true.)
414+
! Advect tracers within DynCore(AdvCore_Advection=0)
415+
! or within AdvCore(AdvCore_Advection=1)
402416
call MAPL_GetResource( MAPL, AdvCore_Advection, label='AdvCore_Advection:', default=AdvCore_Advection, rc=status )
403417
VERIFY_(STATUS)
404418

0 commit comments

Comments
 (0)