Skip to content

Commit 347235b

Browse files
committed
Merge branch 'rljacob/mbcpl/fix-srof' into next (PR #7444)
When rof_present is false, as in a case with SROF, be sure to zero out the river fluxes sent to the land model. These tags are still present and acted on by the land model. Also only add them in ocean merge if rof_c2_ocn is true. [BFB]
2 parents a8ec0d6 + 93e0eb5 commit 347235b

File tree

4 files changed

+62
-26
lines changed

4 files changed

+62
-26
lines changed

components/mosart/src/cpl/rof_comp_mct.F90

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,9 @@ subroutine rof_final_mct( EClock, cdata_r, x2r_r, r2x_r)
532532
! DESCRIPTION:
533533
! Finalize rof surface model
534534
!
535+
#ifdef HAVE_MOAB
536+
use seq_comm_mct, only : mrofid ! id of moab rof app
537+
#endif
535538
! ARGUMENTS:
536539
implicit none
537540
type(ESMF_Clock) , intent(inout) :: EClock ! Input synchronization clock from driver
@@ -543,7 +546,9 @@ subroutine rof_final_mct( EClock, cdata_r, x2r_r, r2x_r)
543546
! fill this in
544547
#ifdef HAVE_MOAB
545548
! deallocate moab fields array
549+
if (mrofid > 0) then
546550
deallocate (r2x_rm)
551+
endif
547552
#endif
548553
end subroutine rof_final_mct
549554

driver-moab/main/cplcomp_exchange_mod.F90

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module cplcomp_exchange_mod
1515
use seq_flds_mod, only: seq_flds_x2o_fields ! needed for MOAB init of ocean fields x2o to be able to transfer from coupler
1616
use seq_flds_mod, only: seq_flds_i2x_fields, seq_flds_x2i_fields ! needed for MOAB init of ice fields x2o on coupler side, to save them
1717
use seq_flds_mod, only: seq_flds_l2x_fields, seq_flds_x2l_fields !
18-
use seq_flds_mod, only: seq_flds_r2x_fields, seq_flds_x2r_fields !
18+
use seq_flds_mod, only: seq_flds_r2x_fields, seq_flds_x2r_fields, seq_flds_r2x_fluxes
1919
use seq_comm_mct, only: cplid, logunit
2020
use seq_comm_mct, only: seq_comm_getinfo => seq_comm_setptrs, seq_comm_iamin
2121
use seq_diag_mct
@@ -1020,7 +1020,7 @@ subroutine cplcomp_moab_Init(infodata,comp)
10201020
!-----------------------------------------------------
10211021
!
10221022
use iMOAB, only: iMOAB_RegisterApplication, iMOAB_ReceiveMesh, iMOAB_SendMesh, &
1023-
iMOAB_WriteMesh, iMOAB_DefineTagStorage, iMOAB_GetMeshInfo, &
1023+
iMOAB_WriteMesh, iMOAB_DefineTagStorage, iMOAB_GetMeshInfo, iMOAB_SetDoubleTagStorage, &
10241024
iMOAB_FreeSenderBuffers, iMOAB_ComputeCommGraph, iMOAB_LoadMesh
10251025
!
10261026
use seq_infodata_mod
@@ -1056,11 +1056,13 @@ subroutine cplcomp_moab_Init(infodata,comp)
10561056
integer :: typeA, typeB, ATM_PHYS_CID ! used to compute par graph between atm phys
10571057
! and atm spectral on coupler
10581058
character(CXX) :: tagname
1059+
character(CXX) :: newlist
10591060
integer nvert(3), nvise(3), nbl(3), nsurf(3), nvisBC(3)
1061+
logical :: rof_present
10601062
real(r8), allocatable :: tagValues(:) ! used for setting aream tags for atm domain read case
1061-
integer :: arrSize ! for the size of tagValues
1062-
! type(mct_list) :: temp_list
1063-
! integer :: nfields, arrsize
1063+
integer :: arrsize ! for the size of tagValues
1064+
type(mct_list) :: temp_list
1065+
integer :: nfields
10641066
! real(R8), allocatable, target :: values(:)
10651067

10661068

@@ -1497,6 +1499,7 @@ subroutine cplcomp_moab_Init(infodata,comp)
14971499
if (comp%oneletterid == 'l' .and. maxMLID /= -1) then
14981500
call seq_comm_getinfo(cplid ,mpigrp=mpigrp_cplid) ! receiver group
14991501
call seq_comm_getinfo(id_old,mpigrp=mpigrp_old) ! component group pes
1502+
call seq_infodata_GetData(infodata,rof_present=rof_present)
15001503

15011504
! use land full mesh
15021505
if (MPI_COMM_NULL /= mpicom_new ) then ! we are on the coupler pes
@@ -1550,6 +1553,26 @@ subroutine cplcomp_moab_Init(infodata,comp)
15501553
call shr_sys_abort(subname//' ERROR in defining tags x2l on coupler land')
15511554
endif
15521555

1556+
if (.not.rof_present) then ! need to zero out some Flrr fields
1557+
call shr_string_listIntersect(seq_flds_x2l_fields,seq_flds_r2x_fluxes,newlist)
1558+
call mct_list_init(temp_list, newlist)
1559+
nfields=mct_list_nitem (temp_list)
1560+
if (nfields > 0) then
1561+
ierr = iMOAB_GetMeshInfo ( mblxid, nvert, nvise, nbl, nsurf, nvisBC )
1562+
arrsize = nvise(1)*nfields
1563+
allocate(tagValues(arrsize))
1564+
tagname = trim(newlist)//C_NULL_CHAR
1565+
tagValues = 0.0_r8
1566+
ent_type = 1 ! cells
1567+
ierr = iMOAB_SetDoubleTagStorage ( mblxid, tagname, arrsize , ent_type, tagValues)
1568+
if (ierr .ne. 0) then
1569+
write(logunit,*) subname,' error in zeroing Flrr tags on land', ierr
1570+
call shr_sys_abort(subname//' ERROR in zeroing Flrr tags land')
1571+
endif
1572+
endif
1573+
endif
1574+
1575+
15531576
!add the normalization tag
15541577
tagname = trim(seq_flds_dom_fields)//":norm8wt"//C_NULL_CHAR
15551578
ierr = iMOAB_DefineTagStorage(mblxid, tagname, tagtype, numco, tagindex )

driver-moab/main/prep_lnd_mod.F90

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ subroutine prep_lnd_init(infodata, atm_c2_lnd, rof_c2_lnd, glc_c2_lnd, iac_c2_ln
284284
mapper_Fr2l%tgt_mbid = mblxid
285285
mapper_Fr2l%src_context = rof(1)%cplcompid
286286
mapper_Fr2l%intx_context = lnd(1)%cplcompid
287-
else
287+
else ! samegrid_lr is false. Bi-grid case
288288
if (compute_maps_online_r2l) then
289289
ierr = iMOAB_ComputeMeshIntersectionOnSphere( mbrxid, mblxid, mbintxrl )
290290
if (ierr .ne. 0) then
@@ -318,7 +318,7 @@ subroutine prep_lnd_init(infodata, atm_c2_lnd, rof_c2_lnd, glc_c2_lnd, iac_c2_ln
318318
write(logunit,*) subname,' error in computing comm graph for second hop, lnd-rof'
319319
call shr_sys_abort(subname//' ERROR in computing comm graph for second hop, lnd-rof')
320320
endif
321-
endif
321+
endif ! (compute_maps_online_r2l)
322322
! now take care of the mapper
323323
if ( mapper_Fr2l%src_mbid .gt. -1 ) then
324324
if (iamroot_CPLID) then
@@ -334,8 +334,6 @@ subroutine prep_lnd_init(infodata, atm_c2_lnd, rof_c2_lnd, glc_c2_lnd, iac_c2_ln
334334
mapper_Fr2l%weight_identifier = wgtIdr2l
335335
mapper_Fr2l%mbname = 'mapper_Fr2l'
336336

337-
! because we will project fields from rof to lnd grid, we need to define
338-
! the r2x fields to lnd grid on coupler side
339337
if (compute_maps_online_r2l) then
340338
volumetric = 0 ! can be 1 only for FV->DGLL or FV->CGLL;
341339
dm1 = "fv"//C_NULL_CHAR
@@ -367,7 +365,7 @@ subroutine prep_lnd_init(infodata, atm_c2_lnd, rof_c2_lnd, glc_c2_lnd, iac_c2_ln
367365
write(logunit,*) subname,' error in computing rl weights '
368366
call shr_sys_abort(subname//' ERROR in computing rl weights ')
369367
endif
370-
else
368+
else ! read maps
371369
type1 = 3 ! this is type of grid, maybe should be saved on imoab app ?
372370
call moab_map_init_rcfile( mbrxid, mblxid, mbintxrl, type1, &
373371
'seq_maps.rc', 'rof2lnd_fmapname:', 'rof2lnd_fmaptype:',samegrid_lr, &
@@ -380,9 +378,11 @@ subroutine prep_lnd_init(infodata, atm_c2_lnd, rof_c2_lnd, glc_c2_lnd, iac_c2_ln
380378
write(logunit,*) subname,' error in migrating rof mesh for map rof c2 lnd '
381379
call shr_sys_abort(subname//' ERROR in migrating rof mesh for map rof c2 lnd')
382380
endif
383-
endif
381+
endif ! compute or read mape
384382

385-
endif
383+
endif ! samegrid_lr or not
384+
! because we will project fields from rof to lnd grid, we need to define
385+
! the r2x fields to lnd grid on coupler side
386386
tagname = trim(seq_flds_r2x_fields)//C_NULL_CHAR
387387
tagtype = 1 ! dense
388388
numco = 1 !
@@ -414,10 +414,10 @@ subroutine prep_lnd_init(infodata, atm_c2_lnd, rof_c2_lnd, glc_c2_lnd, iac_c2_ln
414414
endif
415415
deallocate (tmparray)
416416

417-
end if ! if ((mbrxid .ge. 0) .and. (mblxid .ge. 0))
417+
end if !((mbrxid .ge. 0) .and. (mblxid .ge. 0))
418418
! endif HAVE_MOAB
419419
#endif
420-
end if
420+
end if ! rof_c2_lnd
421421
call shr_sys_flush(logunit)
422422

423423
if (atm_c2_lnd) then

driver-moab/main/prep_ocn_mod.F90

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ module prep_ocn_mod
140140
integer , target :: x2oacc_om_cnt ! x2oacc_ox: number of time samples accumulated, in moab array
141141
integer :: arrSize_x2o_om ! this will be a module variable, size moabLocal_size * nof
142142

143+
! flag that saves rof_c2_ocn value from init routine, to be used for merge routine
144+
logical :: rof_c2_ocn_saved
145+
143146
! other module variables
144147
integer :: mpicom_CPLID ! MPI cpl communicator
145148
logical :: iamroot_CPLID ! .true. => CPLID masterproc
@@ -716,6 +719,7 @@ subroutine prep_ocn_init(infodata, atm_c2_ocn, atm_c2_ice, ice_c2_ocn, rof_c2_oc
716719
endif ! if (ice_present)
717720
call shr_sys_flush(logunit)
718721

722+
rof_c2_ocn_saved = rof_c2_ocn ! save the value, and use it for merge, later
719723
if (rof_c2_ocn) then
720724
if (iamroot_CPLID) then
721725
write(logunit,*) ' '
@@ -1341,8 +1345,10 @@ subroutine prep_ocn_mrg_moab(infodata, xao_ox)
13411345
endif
13421346
allocate(a2x_om (lsize, naflds))
13431347
allocate(i2x_om (lsize, niflds))
1344-
allocate(r2x_om (lsize, nrflds))
1345-
r2x_om = 0._R8 ! should we zero out all of them ?
1348+
if (rof_c2_ocn_saved) then
1349+
allocate(r2x_om (lsize, nrflds))
1350+
r2x_om = 0._R8 ! should we zero out all of them ?
1351+
endif
13461352
allocate(xao_om (lsize, nxflds))
13471353
! allocate fractions too
13481354
! use the fraclist fraclist_o = 'afrac:ifrac:ofrac:ifrad:ofrad'
@@ -1745,13 +1751,14 @@ subroutine prep_ocn_mrg_moab(infodata, xao_ox)
17451751
call shr_sys_abort(subname//' error in getting i2x_om array ')
17461752
endif
17471753

1748-
tagname = trim(seq_flds_r2x_fields)//C_NULL_CHAR
1749-
arrsize = nrflds * lsize ! allocate (r2x_om (lsize, nrflds))
1750-
ierr = iMOAB_GetDoubleTagStorage ( mboxid, tagname, arrsize , ent_type, r2x_om)
1751-
if (ierr .ne. 0) then
1752-
call shr_sys_abort(subname//' error in getting r2x_om array ')
1754+
if (rof_c2_ocn_saved) then
1755+
tagname = trim(seq_flds_r2x_fields)//C_NULL_CHAR
1756+
arrsize = nrflds * lsize ! allocate (r2x_om (lsize, nrflds))
1757+
ierr = iMOAB_GetDoubleTagStorage ( mboxid, tagname, arrsize , ent_type, r2x_om)
1758+
if (ierr .ne. 0) then
1759+
call shr_sys_abort(subname//' error in getting r2x_om array ')
1760+
endif
17531761
endif
1754-
17551762
tagname = trim(seq_flds_xao_fields)//C_NULL_CHAR
17561763
arrsize = nxflds * lsize ! allocate (xao_om (lsize, nxflds))
17571764
ierr = iMOAB_GetDoubleTagStorage ( mbofxid, tagname, arrsize , ent_type, xao_om)
@@ -1810,14 +1817,15 @@ subroutine prep_ocn_mrg_moab(infodata, xao_ox)
18101817
x2o_om(n,index_x2o_Faxa_prec ) = x2o_om(n,index_x2o_Faxa_rain ) + &
18111818
x2o_om(n,index_x2o_Faxa_snow )
18121819

1813-
x2o_om(n,index_x2o_Foxx_rofl) = (r2x_om(n,index_r2x_Forr_rofl ) + &
1820+
if (rof_c2_ocn_saved) then
1821+
x2o_om(n,index_x2o_Foxx_rofl) = (r2x_om(n,index_r2x_Forr_rofl ) + &
18141822
r2x_om(n,index_r2x_Flrr_flood) )
18151823
! g2x_om(n,index_g2x_Fogg_rofl )) * flux_epbalfact
1816-
x2o_om(n,index_x2o_Foxx_rofi) = (r2x_om(n,index_r2x_Forr_rofi ) ) * flux_epbalfact
1824+
x2o_om(n,index_x2o_Foxx_rofi) = (r2x_om(n,index_r2x_Forr_rofi ) ) * flux_epbalfact
18171825
! g2x_om(n,index_g2x_Fogg_rofi )) * flux_epbalfact
1826+
endif
18181827

1819-
1820-
if ( index_x2o_Foxx_rofl_16O /= 0 ) then
1828+
if ( index_x2o_Foxx_rofl_16O /= 0 .and. rof_c2_ocn_saved ) then
18211829
x2o_om(n,index_x2o_Foxx_rofl_16O) = (r2x_om(n,index_r2x_Forr_rofl_16O) + &
18221830
r2x_om(n,index_r2x_Flrr_flood) ) * flux_epbalfact
18231831
! g2x_om(n,index_g2x_Fogg_rofl )) * flux_epbalfact

0 commit comments

Comments
 (0)