Skip to content

Commit 24ec260

Browse files
authored
Merge branch 'jacob/cpl/moab-restart-lfrac-nx' (PR #8541)
Use atm_pg_active to choose between the global element count (pg2/FV cell meshes) and the global vertex count (np4 point clouds) when determining nx_lnd from iMOAB_GetGlobalInfo for samegrid_al. Previously the code always used the elem count, which was incorrect for vertex-based atmosphere grids such as ne4_ne4 and ne30_ne30. The rof mesh path is also corrected to use the element count consistently. [BFB] Fixes #8540
2 parents b500e39 + 7ea129c commit 24ec260

1 file changed

Lines changed: 60 additions & 20 deletions

File tree

driver-moab/main/seq_rest_mod.F90

Lines changed: 60 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,9 @@ module seq_rest_mod
164164
subroutine seq_rest_mb_read(rest_file, infodata, samegrid_al, samegrid_lr)
165165

166166
use seq_comm_mct, only: mbaxid, mbixid, mboxid, mblxid, mbrxid, mbofxid ! coupler side instances
167-
use iMOAB, only: iMOAB_GetGlobalInfo
168167
use seq_comm_mct , only: num_moab_exports ! it is used only as a counter for moab h5m files
168+
use seq_comm_mct, only: atm_pg_active ! whether the atm/lnd mesh is cells (pg2/FV) or a point cloud (np4)
169+
use iMOAB, only: iMOAB_GetGlobalInfo
169170

170171
implicit none
171172

@@ -185,7 +186,8 @@ subroutine seq_rest_mb_read(rest_file, infodata, samegrid_al, samegrid_lr)
185186

186187
integer (in), pointer :: l2racc_lm_cnt
187188
integer (in) :: nx_lnd ! will be used if land and atm are on same grid
188-
integer (in) :: ierr, ngv
189+
integer (in) :: ngv, nge ! global num vertices / elements from iMOAB_GetGlobalInfo
190+
integer (in) :: ierr
189191

190192
real(r8), dimension(:,:), pointer :: p_x2oacc_om
191193
real(r8), dimension(:,:), pointer :: p_o2racc_om
@@ -245,13 +247,22 @@ subroutine seq_rest_mb_read(rest_file, infodata, samegrid_al, samegrid_lr)
245247
endif
246248
if (lnd_present) then
247249
if(samegrid_al) then
248-
! nx for land will be from global nb atmosphere
249-
ierr = iMOAB_GetGlobalInfo(mbaxid, ngv, nx_lnd) ! max id for land will come from atm
250+
! land is on the atm mesh; max global land id comes from atm.
251+
! Point-cloud atm (np4) stores land on vertices; cell atm
252+
! (pg2/FV) stores it on elements. Pick the matching count.
253+
ierr = iMOAB_GetGlobalInfo(mbaxid, ngv, nge)
254+
if (atm_pg_active) then
255+
nx_lnd = nge ! atm mesh is cells
256+
else
257+
nx_lnd = ngv ! atm mesh is a point cloud
258+
endif
250259
call seq_io_read(moab_rest_file, mblxid, 'fractions_lx', &
251260
'afrac:lfrac:lfrin', nx=nx_lnd)
252261
else if(samegrid_lr) then
253-
! nx for land will be from global nb rof
254-
ierr = iMOAB_GetGlobalInfo(mbrxid, ngv, nx_lnd) ! max id for land will come from rof
262+
! land is on the rof mesh; max global land id comes from rof.
263+
! The rof mesh is cell-based, so use the global element count.
264+
ierr = iMOAB_GetGlobalInfo(mbrxid, ngv, nge)
265+
nx_lnd = nge
255266
call seq_io_read(moab_rest_file, mblxid, 'fractions_lx', &
256267
'afrac:lfrac:lfrin', nx=nx_lnd)
257268
else ! is this ever true ?
@@ -264,14 +275,23 @@ subroutine seq_rest_mb_read(rest_file, infodata, samegrid_al, samegrid_lr)
264275
l2racc_lm_cnt => prep_rof_get_l2racc_lm_cnt()
265276
p_l2racc_lm => prep_rof_get_l2racc_lm()
266277
if(samegrid_al) then
267-
! nx for land will be from global nb atmosphere
268-
ierr = iMOAB_GetGlobalInfo(mbaxid, ngv, nx_lnd) ! max id for land will come from atm
278+
! land is on the atm mesh; max global land id comes from atm.
279+
! Point-cloud atm (np4) stores land on vertices; cell atm
280+
! (pg2/FV) stores it on elements. Pick the matching count.
281+
ierr = iMOAB_GetGlobalInfo(mbaxid, ngv, nge)
282+
if (atm_pg_active) then
283+
nx_lnd = nge ! atm mesh is cells
284+
else
285+
nx_lnd = ngv ! atm mesh is a point cloud
286+
endif
269287
call seq_io_read(moab_rest_file, mblxid, 'l2racc_lx', &
270288
trim(tagname), &
271289
matrix = p_l2racc_lm, nx=nx_lnd)
272290
else if(samegrid_lr) then
273-
! nx for land will be from global nb rof
274-
ierr = iMOAB_GetGlobalInfo(mbrxid, ngv, nx_lnd) ! max id for land will come from rof
291+
! land is on the rof mesh; max global land id comes from rof.
292+
! The rof mesh is cell-based, so use the global element count.
293+
ierr = iMOAB_GetGlobalInfo(mbrxid, ngv, nge)
294+
nx_lnd = nge
275295
call seq_io_read(moab_rest_file, mblxid, 'l2racc_lx', &
276296
trim(tagname), &
277297
matrix = p_l2racc_lm, nx=nx_lnd)
@@ -406,8 +426,9 @@ subroutine seq_rest_mb_write(EClock_d, seq_SyncClock, infodata, &
406426
tag, samegrid_al, samegrid_lr, rest_file)
407427

408428
use seq_comm_mct, only: mbaxid, mbixid, mboxid, mblxid, mbrxid, mbofxid ! coupler side instances
409-
use iMOAB, only: iMOAB_GetGlobalInfo
410429
use seq_comm_mct , only: num_moab_exports ! it is used only as a counter for moab h5m files
430+
use seq_comm_mct, only: atm_pg_active ! whether the atm/lnd mesh is cells (pg2/FV) or a point cloud (np4)
431+
use iMOAB, only: iMOAB_GetGlobalInfo
411432

412433
implicit none
413434

@@ -455,7 +476,8 @@ subroutine seq_rest_mb_write(EClock_d, seq_SyncClock, infodata, &
455476

456477
integer (in), pointer :: l2racc_lm_cnt
457478
integer (in) :: nx_lnd ! will be used if land and atm are on same grid
458-
integer (in) :: ierr, ngv
479+
integer (in) :: ngv, nge ! global num vertices / elements from iMOAB_GetGlobalInfo
480+
integer (in) :: ierr
459481

460482
real(r8), dimension(:,:), pointer :: p_x2oacc_om
461483
real(r8), dimension(:,:), pointer :: p_o2racc_om
@@ -624,14 +646,23 @@ subroutine seq_rest_mb_write(EClock_d, seq_SyncClock, infodata, &
624646

625647
if (lnd_present) then
626648
if(samegrid_al) then
627-
! nx for land will be from global nb atmosphere
628-
ierr = iMOAB_GetGlobalInfo(mbaxid, ngv, nx_lnd) ! max id for land will come from atm
649+
! land is on the atm mesh; max global land id comes from atm.
650+
! Point-cloud atm (np4) stores land on vertices; cell atm
651+
! (pg2/FV) stores it on elements. Pick the matching count.
652+
ierr = iMOAB_GetGlobalInfo(mbaxid, ngv, nge)
653+
if (atm_pg_active) then
654+
nx_lnd = nge ! atm mesh is cells
655+
else
656+
nx_lnd = ngv ! atm mesh is a point cloud
657+
endif
629658
call seq_io_write(rest_file, mblxid, 'fractions_lx', &
630659
'afrac:lfrac:lfrin', & ! seq_frac_mod: character(*),parameter :: fraclist_l = 'afrac:lfrac:lfrin'
631660
whead=whead, wdata=wdata, nx=nx_lnd)
632661
else if(samegrid_lr) then
633-
! nx for land will be from global nb atmosphere
634-
ierr = iMOAB_GetGlobalInfo(mbrxid, ngv, nx_lnd) ! max id for land will come from rof
662+
! land is on the rof mesh; max global land id comes from rof.
663+
! The rof mesh is cell-based, so use the global element count.
664+
ierr = iMOAB_GetGlobalInfo(mbrxid, ngv, nge)
665+
nx_lnd = nge
635666
call seq_io_write(rest_file, mblxid, 'fractions_lx', &
636667
'afrac:lfrac:lfrin', & ! seq_frac_mod: character(*),parameter :: fraclist_l = 'afrac:lfrac:lfrin'
637668
whead=whead, wdata=wdata, nx=nx_lnd)
@@ -646,14 +677,23 @@ subroutine seq_rest_mb_write(EClock_d, seq_SyncClock, infodata, &
646677
l2racc_lm_cnt => prep_rof_get_l2racc_lm_cnt()
647678
p_l2racc_lm => prep_rof_get_l2racc_lm()
648679
if(samegrid_al) then
649-
! nx for land will be from global nb atmosphere
650-
ierr = iMOAB_GetGlobalInfo(mbaxid, ngv, nx_lnd) ! max id for land will come from atm
680+
! land is on the atm mesh; max global land id comes from atm.
681+
! Point-cloud atm (np4) stores land on vertices; cell atm
682+
! (pg2/FV) stores it on elements. Pick the matching count.
683+
ierr = iMOAB_GetGlobalInfo(mbaxid, ngv, nge)
684+
if (atm_pg_active) then
685+
nx_lnd = nge ! atm mesh is cells
686+
else
687+
nx_lnd = ngv ! atm mesh is a point cloud
688+
endif
651689
call seq_io_write(rest_file, mblxid, 'l2racc_lx', &
652690
trim(tagname), &
653691
whead=whead, wdata=wdata, matrix = p_l2racc_lm, nx=nx_lnd)
654692
else if(samegrid_lr) then
655-
! nx for land will be from global nb atmosphere
656-
ierr = iMOAB_GetGlobalInfo(mbrxid, ngv, nx_lnd) ! max id for land will come from rof
693+
! land is on the rof mesh; max global land id comes from rof.
694+
! The rof mesh is cell-based, so use the global element count.
695+
ierr = iMOAB_GetGlobalInfo(mbrxid, ngv, nge)
696+
nx_lnd = nge
657697
call seq_io_write(rest_file, mblxid, 'l2racc_lx', &
658698
trim(tagname), &
659699
whead=whead, wdata=wdata, matrix = p_l2racc_lm, nx=nx_lnd)

0 commit comments

Comments
 (0)