Skip to content
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
1eab35c
glc errors on moab driver
iulian787 May 31, 2025
6e58067
more changes for glc_nzoc
iulian787 Jun 1, 2025
ee4c56d
when no ocn or ice, land fractions are copied in
iulian787 Mar 29, 2025
9e34876
more get global ids from gs map
iulian787 Mar 30, 2025
2d3419e
need the gsmap retrieve of dof for rof fractions too
iulian787 Mar 30, 2025
b9eea56
more uses of mct_gsMap_orderedPoints
iulian787 Mar 30, 2025
159bb01
ocean and ice fractions
iulian787 Mar 30, 2025
51420d9
need to save the dof for setting the fractions tag
iulian787 Mar 30, 2025
b752d91
one more conversion to gsmap
iulian787 Mar 31, 2025
21230ce
more debug info on moab exchanges
iulian787 Apr 4, 2025
7bca3de
more exchange contexts
iulian787 Apr 4, 2025
0dd8dd8
report area factors computed by moab
iulian787 Apr 4, 2025
aed22d4
copy area to aream in some cases
iulian787 Apr 4, 2025
f4f08d6
add more info about time steps (moab count)
iulian787 Apr 8, 2025
9fafff8
reinstate debug writing for r2x_ox
iulian787 Apr 9, 2025
70df4aa
write ocn instance before r2o projection
iulian787 Apr 9, 2025
4f5e5c2
restore migrate map mesh for r2o map
iulian787 Apr 9, 2025
0fd5328
use rmapid context to send
iulian787 Apr 9, 2025
e61e703
simplify the map migrate workflow
iulian787 Apr 10, 2025
dd9caa9
gustiness needs to be added to moab driver too
iulian787 Apr 16, 2025
5c23697
remove imoab compute coverage
iulian787 Apr 18, 2025
c9ce3a2
some logic related to sediflag missing from rof_import_moab
iulian787 Apr 18, 2025
df1cae2
more debug file after rof2lnd mapping
iulian787 Apr 18, 2025
a9dd519
more info about files read by moab driver
iulian787 Apr 24, 2025
e33a480
forgot one removal of (1,1) in tag storage access
iulian787 Apr 28, 2025
8136ab0
write in debug mode on proper comm
iulian787 May 22, 2025
6679a71
debug writes on proper comm
May 22, 2025
2606304
typo
iulian787 May 22, 2025
2a50888
use river global size for land restart when samegrid_lr
iulian787 Jun 6, 2025
71439fd
more debugging for fractions
iulian787 Jun 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions components/elm/src/cpl/lnd_comp_mct.F90
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,11 @@ subroutine lnd_init_mct( EClock, cdata_l, x2l_l, l2x_l, NLFilename )
! write out the mesh file to disk, in parallel
outfile = 'wholeLnd.h5m'//C_NULL_CHAR
wopts = 'PARALLEL=WRITE_PART'//C_NULL_CHAR
ierr = iMOAB_WriteMesh(mlnid, outfile, wopts)
if (ierr > 0 ) &
call endrun('Error: fail to write the land mesh file')
if (mlnid >= 0) then
ierr = iMOAB_WriteMesh(mlnid, outfile, wopts)
if (ierr > 0 ) &
call endrun('Error: fail to write the land mesh file')
endif
#endif

end subroutine lnd_init_mct
Expand Down Expand Up @@ -1076,6 +1078,7 @@ subroutine lnd_export_moab(EClock, bounds, lnd2atm_vars, lnd2glc_vars)
l2x_lm(i,index_l2x_Sl_tref) = lnd2atm_vars%t_ref2m_grc(g)
l2x_lm(i,index_l2x_Sl_qref) = lnd2atm_vars%q_ref2m_grc(g)
l2x_lm(i,index_l2x_Sl_u10) = lnd2atm_vars%u_ref10m_grc(g)
l2x_lm(i,index_l2x_Sl_u10withgusts)=lnd2atm_vars%u_ref10m_with_gusts_grc(g) ! see commit 5813d4103
l2x_lm(i,index_l2x_Fall_taux) = -lnd2atm_vars%taux_grc(g)
l2x_lm(i,index_l2x_Fall_tauy) = -lnd2atm_vars%tauy_grc(g)
l2x_lm(i,index_l2x_Fall_lat) = -lnd2atm_vars%eflx_lh_tot_grc(g)
Expand Down Expand Up @@ -1339,7 +1342,7 @@ subroutine lnd_import_moab(EClock, bounds, atm2lnd_vars, glc2lnd_vars)
#endif
tagname=trim(seq_flds_x2l_fields)//C_NULL_CHAR
ent_type = 0 ! vertices
ierr = iMOAB_GetDoubleTagStorage ( mlnid, tagname, totalmblsimp , ent_type, x2l_lm(1,1) )
ierr = iMOAB_GetDoubleTagStorage ( mlnid, tagname, totalmblsimp , ent_type, x2l_lm )
if ( ierr > 0) then
call endrun('Error: fail to get seq_flds_x2l_fields for land moab instance on component')
endif
Expand Down
53 changes: 46 additions & 7 deletions components/mosart/src/cpl/rof_comp_mct.F90
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,11 @@ subroutine rof_init_mct( EClock, cdata_r, x2r_r, r2x_r, NLFilename)
! write out the mesh file to disk, in parallel
outfile = 'wholeRof.h5m'//C_NULL_CHAR
wopts = 'PARALLEL=WRITE_PART'//C_NULL_CHAR
ierr = iMOAB_WriteMesh(mrofid, outfile, wopts)
if (ierr > 0 ) &
call shr_sys_abort( sub//' Error: fail to write the moab runoff mesh file')
if (mrofid >= 0) then
ierr = iMOAB_WriteMesh(mrofid, outfile, wopts)
if (ierr > 0 ) &
call shr_sys_abort( sub//' Error: fail to write the moab runoff mesh file')
endif
#endif

end subroutine rof_init_mct
Expand Down Expand Up @@ -1260,7 +1262,7 @@ subroutine rof_import_moab( EClock )

!
! LOCAL VARIABLES
integer :: n2, n, nt, begr, endr, nliq, nfrz
integer :: n2, n, nt, begr, endr, nliq, nfrz, nmud, nsan
real(R8) :: tmp1, tmp2
real(R8) :: shum
character(CXX) :: tagname !
Expand All @@ -1287,24 +1289,44 @@ subroutine rof_import_moab( EClock )
! populate the array x2r_rm with data from MOAB tags
tagname=trim(seq_flds_x2r_fields)//C_NULL_CHAR
ent_type = 0 ! vertices, point cloud
ierr = iMOAB_GetDoubleTagStorage ( mrofid, tagname, totalmbls_r , ent_type, x2r_rm(1,1) )
ierr = iMOAB_GetDoubleTagStorage ( mrofid, tagname, totalmbls_r , ent_type, x2r_rm )
if ( ierr > 0) then
call shr_sys_abort(sub//'Error: fail to get seq_flds_a2x_fields for atm physgrid moab mesh')
endif

! Note that ***runin are fluxes
nliq = 0
nfrz = 0
nmud = 0
nsan = 0
do nt = 1,nt_rtm
if (trim(rtm_tracers(nt)) == 'LIQ') then
nliq = nt
endif
if (trim(rtm_tracers(nt)) == 'ICE') then
nfrz = nt
endif
if (trim(rtm_tracers(nt)) == 'MUD') then
nmud = nt
endif
if (trim(rtm_tracers(nt)) == 'SAN') then
nsan = nt
endif
enddo
if (nliq == 0 .or. nfrz == 0) then
write(iulog,*) trim(sub),': ERROR in rtm_tracers LIQ ICE ',nliq,nfrz,rtm_tracers
if (nliq == 0) then
write(iulog,*) trim(sub),': ERROR in rtm_tracers LIQ',nliq,rtm_tracers
call shr_sys_abort()
endif
if (nfrz == 0) then
write(iulog,*) trim(sub),': ERROR in rtm_tracers ICE',nfrz,rtm_tracers
call shr_sys_abort()
endif
if (nmud == 0) then
write(iulog,*) trim(sub),': ERROR in rtm_tracers MUD',nmud,rtm_tracers
call shr_sys_abort()
endif
if (nsan == 0) then
write(iulog,*) trim(sub),': ERROR in rtm_tracers SAN',nsan,rtm_tracers
call shr_sys_abort()
endif

Expand Down Expand Up @@ -1351,8 +1373,25 @@ subroutine rof_import_moab( EClock )
THeat%forc_vp(n) = shum * THeat%forc_pbot(n) / (0.622_r8 + 0.378_r8 * shum)
THeat%coszen(n) = x2r_rm(n2,index_x2r_coszen_str)
end if


rtmCTL%qsur(n,nmud) = 0.0_r8
rtmCTL%qsur(n,nsan) = 0.0_r8

if (index_x2r_Flrl_inundinf > 0) then
rtmCTL%inundinf(n) = x2r_rm(n2,index_x2r_Flrl_inundinf) * (rtmCTL%area(n)*0.001_r8)
endif

enddo

if(sediflag) then
do n = begr,endr
n2 = n - begr + 1
rtmCTL%qsur(n,nmud) = x2r_rm(n2,index_x2r_Flrl_rofmud) * (rtmCTL%area(n)) ! kg/m2/s --> kg/s for sediment
rtmCTL%qsur(n,nsan) = 0.0_r8
enddo
end if

end subroutine rof_import_moab


Expand Down
2 changes: 1 addition & 1 deletion components/mpas-ocean/driver/ocn_comp_mct.F
Original file line number Diff line number Diff line change
Expand Up @@ -3692,7 +3692,7 @@ subroutine ocn_import_moab(Eclock, errorCode)!{{{
ent_type = 1 ! cells
! get all tags in one method
tagname = trim(seq_flds_x2o_fields)//C_NULL_CHAR
ierr = iMOAB_GetDoubleTagStorage ( MPOID, tagname, totalmbls_r , ent_type, x2o_om(1, 1) )
ierr = iMOAB_GetDoubleTagStorage ( MPOID, tagname, totalmbls_r , ent_type, x2o_om )
if ( ierr /= 0 ) then
write(ocnLogUnit,*) 'Fail to get MOAB fields '
endif
Expand Down
3 changes: 2 additions & 1 deletion components/mpas-seaice/driver/ice_comp_mct.F
Original file line number Diff line number Diff line change
Expand Up @@ -3550,6 +3550,7 @@ subroutine ice_export_moab(EClock)
i2x_im(n, index_i2x_Si_t) = Tsrf
i2x_im(n, index_i2x_Si_bpress) = basalPressure
i2x_im(n, index_i2x_Si_u10) = atmosReferenceSpeed10m(i)
i2x_im(n, index_i2x_Si_u10withgusts) = atmosReferenceSpeed10m(i) ! see commit 5813d4103
i2x_im(n, index_i2x_Si_tref) = atmosReferenceTemperature2m(i)
i2x_im(n, index_i2x_Si_qref) = atmosReferenceHumidity2m(i)
i2x_im(n, index_i2x_Si_snowh) = snowVolumeCell(i) / ailohi
Expand Down Expand Up @@ -3887,7 +3888,7 @@ subroutine ice_import_moab(Eclock)!{{{
ent_type = 1 ! cells
! set all tags in one method
tagname = trim(seq_flds_x2i_fields)//C_NULL_CHAR
ierr = iMOAB_GetDoubleTagStorage ( MPSIID, tagname, totalmblr , ent_type, x2i_im(1, 1) )
ierr = iMOAB_GetDoubleTagStorage ( MPSIID, tagname, totalmblr , ent_type, x2i_im )
if ( ierr /= 0 ) then
write(iceLogUnit,*) 'Fail to get seq_flds_x2i_fields '
endif
Expand Down
15 changes: 15 additions & 0 deletions driver-moab/cime_config/buildnml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def _create_drv_namelists(case, infile, confdir, nmlgen, files):
config['CPL_EPBAL'] = case.get_value('CPL_EPBAL')
config['FLDS_WISO'] = case.get_value('FLDS_WISO')
config['FLDS_POLAR'] = case.get_value('FLDS_POLAR')
config['FLDS_TF'] = case.get_value('FLDS_TF')
config['BUDGETS'] = case.get_value('BUDGETS')
config['MACH'] = case.get_value('MACH')
config['MPILIB'] = case.get_value('MPILIB')
Expand Down Expand Up @@ -69,6 +70,20 @@ def _create_drv_namelists(case, infile, confdir, nmlgen, files):
elif case.get_value('RUN_TYPE') == 'branch':
config['run_type'] = 'branch'

# ---------------------------------------------------
# set wave coupling settings based on compset:
# ---------------------------------------------------
if case.get_value('COMP_WAV') == 'ww3':
config['WAVSPEC'] = case.get_value('WAV_SPEC')
if case.get_value('COMP_OCN') == 'mpaso':
config['WAV_OCN_COUP'] = 'twoway'
elif case.get_value('COMP_OCN') == 'docn':
config['WAV_OCN_COUP'] = 'oneway'
elif case.get_value('COMP_WAV') == 'dwav':
config['WAVSPEC'] = 'sp36x36'
else:
config['WAVSPEC'] = 'none'

#----------------------------------------------------
# Initialize namelist defaults
#----------------------------------------------------
Expand Down
24 changes: 24 additions & 0 deletions driver-moab/cime_config/namelist_definition_drv.xml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,18 @@
</values>
</entry>

<entry id="flds_tf">
<type>logical</type>
<category>seq_flds</category>
<group>seq_cplflds_inparm</group>
<desc>
If set to .true. thermal forcing fields will be passed from the ocean to the coupler.
</desc>
<values>
<value>$FLDS_TF</value>
</values>
</entry>

<entry id="flds_polar">
<type>logical</type>
<category>seq_flds</category>
Expand Down Expand Up @@ -302,6 +314,18 @@
<value>.false.</value>
</values>
</entry>

<entry id="wav_ocn_coup">
<type>char</type>
<category>seq_flds</category>
<group>seq_cplflds_inparm</group>
<desc>One- or Two-way coupling between Wave and Ocn.</desc>
<values>
<value>none</value>
<value WAV_OCN_COUP="oneway">oneway</value>
<value WAV_OCN_COUP="twoway">twoway</value>
</values>
</entry>

<!-- =========================== -->
<!-- -group seq_cplflds_custom -->
Expand Down
7 changes: 6 additions & 1 deletion driver-moab/main/cime_comp_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,8 @@ module cime_comp_mod
logical :: lnd_c2_glc ! .true. => lnd to glc coupling on
logical :: ocn_c2_atm ! .true. => ocn to atm coupling on
logical :: ocn_c2_ice ! .true. => ocn to ice coupling on
logical :: ocn_c2_glctf ! .true. => ocn to glc thermal forcing coupling on
integer :: glc_nzoc ! number of z-levels for ocn/glc TF coupling
logical :: ocn_c2_glcshelf ! .true. => ocn to glc ice shelf coupling on
logical :: ocn_c2_wav ! .true. => ocn to wav coupling on
logical :: ocn_c2_rof ! .true. => ocn to rof coupling on
Expand Down Expand Up @@ -569,7 +571,7 @@ module cime_comp_mod
'Sa_u:Sa_v'

character(CL) :: hist_a2x3hr_flds = &
'Sa_z:Sa_u:Sa_v:Sa_tbot:Sa_ptem:Sa_shum:Sa_dens:Sa_pbot:Sa_pslv:Faxa_lwdn:&
'Sa_z:Sa_topo:Sa_u:Sa_v:Sa_tbot:Sa_ptem:Sa_shum:Sa_dens:Sa_pbot:Sa_pslv:Faxa_lwdn:&
&Faxa_rainc:Faxa_rainl:Faxa_snowc:Faxa_snowl:&
&Faxa_swndr:Faxa_swvdr:Faxa_swndf:Faxa_swvdf:&
&Sa_co2diag:Sa_co2prog'
Expand Down Expand Up @@ -1705,6 +1707,8 @@ subroutine cime_init()
ocn_prognostic=ocn_prognostic, &
ocnrof_prognostic=ocnrof_prognostic, &
ocn_c2_glcshelf=ocn_c2_glcshelf, &
ocn_c2_glctf=ocn_c2_glctf, &
glc_nzoc=glc_nzoc, &
glc_prognostic=glc_prognostic, &
rof_prognostic=rof_prognostic, &
rofocn_prognostic=rofocn_prognostic, &
Expand Down Expand Up @@ -1801,6 +1805,7 @@ subroutine cime_init()
if (atm_prognostic) ocn_c2_atm = .true.
if (atm_present ) ocn_c2_atm = .true. ! needed for aoflux calc if aoflux=atm
if (ice_prognostic) ocn_c2_ice = .true.
if (glc_prognostic .and. (glc_nzoc > 0)) ocn_c2_glctf = .true.
if (wav_prognostic) ocn_c2_wav = .true.
if (rofocn_prognostic) ocn_c2_rof = .true.

Expand Down
74 changes: 59 additions & 15 deletions driver-moab/main/component_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ subroutine component_init_aream(infodata, rof_c2_ocn, samegrid_ao, samegrid_al,
use iso_c_binding
! character(1024) :: domain_file ! file containing domain info (set my input)
use seq_comm_mct, only: mboxid ! iMOAB id for MPAS ocean migrated mesh to coupler pes
use seq_comm_mct, only: mblxid ! iMOAB id for lnd migrated mesh to coupler pes
use seq_comm_mct, only: mbaxid ! iMOAB id for atm migrated mesh to coupler pes
use seq_comm_mct, only: mbrxid ! iMOAB id for rof migrated mesh to coupler pes
#endif
Expand Down Expand Up @@ -551,18 +552,6 @@ subroutine component_init_aream(infodata, rof_c2_ocn, samegrid_ao, samegrid_al,
! project now aream on ocean (from atm)
#endif
call seq_map_map(mapper_Fa2o, av_s=dom_s%data, av_d=dom_d%data, fldlist='aream')

#ifdef HAVE_MOAB
#ifdef MOABDEBUG
ierr = iMOAB_WriteMesh(mboxid, trim('recMeshOcnWithArea.h5m'//C_NULL_CHAR), &
trim(';PARALLEL=WRITE_PART'//C_NULL_CHAR))
if (ierr .ne. 0) then
write(logunit,*) subname,' error in writing ocean mesh coupler '
call shr_sys_abort(subname//' ERROR in writing ocean mesh coupler ')
endif
#endif
#endif


else
gsmap_s => component_get_gsmap_cx(ocn(1)) ! gsmap_ox
Expand Down Expand Up @@ -644,6 +633,40 @@ subroutine component_init_aream(infodata, rof_c2_ocn, samegrid_ao, samegrid_al,

endif
endif
#ifdef MOABDEBUG
if(mbaxid >=0 ) then
ierr = iMOAB_WriteMesh(mbaxid, trim('cplAtmWithAream.h5m'//C_NULL_CHAR), &
trim(';PARALLEL=WRITE_PART'//C_NULL_CHAR))
if (ierr .ne. 0) then
write(logunit,*) subname,' error in writing atm mesh coupler '
call shr_sys_abort(subname//' ERROR in writing atm mesh coupler ')
endif
endif
if(mblxid >=0 ) then
ierr = iMOAB_WriteMesh(mblxid, trim('cplLndWithAream.h5m'//C_NULL_CHAR), &
trim(';PARALLEL=WRITE_PART'//C_NULL_CHAR))
if (ierr .ne. 0) then
write(logunit,*) subname,' error in writing lnd mesh coupler '
call shr_sys_abort(subname//' ERROR in writing lnd mesh coupler ')
endif
endif
if(mboxid >=0 ) then
ierr = iMOAB_WriteMesh(mboxid, trim('cplOcnWithAream.h5m'//C_NULL_CHAR), &
trim(';PARALLEL=WRITE_PART'//C_NULL_CHAR))
if (ierr .ne. 0) then
write(logunit,*) subname,' error in writing ocn mesh coupler '
call shr_sys_abort(subname//' ERROR in writing ocn mesh coupler ')
endif
endif
if(mbrxid >=0 ) then
ierr = iMOAB_WriteMesh(mbrxid, trim('cplRofWithAream.h5m'//C_NULL_CHAR), &
trim(';PARALLEL=WRITE_PART'//C_NULL_CHAR))
if (ierr .ne. 0) then
write(logunit,*) subname,' error in writing rof mesh coupler '
call shr_sys_abort(subname//' ERROR in writing rof mesh coupler ')
endif
endif
#endif

end subroutine component_init_aream

Expand Down Expand Up @@ -734,18 +757,22 @@ subroutine component_init_areacor_moab (comp, mbccid, mbcxid, seq_flds_c2x_fluxe
integer :: mpi_tag
character(*), parameter :: subname = '(component_init_areacor_moab)'
character(CXX) :: tagname
character(CXX) :: comment
integer :: tagtype, numco, tagindex, lsize, i, j, arrsize, ierr, nfields
real (kind=r8) , allocatable :: areas (:,:), factors(:,:), vals(:,:) ! 2 tags values, area, aream,
real (kind=r8) :: rarea, raream, rmask, fact
real (kind=r8) :: rarea, raream, rmask, fact, rmin1, rmax1, rmin, rmax
integer nvert(3), nvise(3), nbl(3), nsurf(3), nvisBC(3)
type(mct_list) :: temp_list ! used to count number of fields
integer :: mpicom
logical :: iamroot
character(len=*),parameter :: F0R = "(2A,2g23.15,A )"
!---------------------------------------------------------------

if (comp(1)%iamin_cplcompid) then
tagname='aream'//C_NULL_CHAR
! bring on the comp side the aream from maps
! (it is either computed by mapping routine or read from mapping files)
call component_exch_moab(comp(1), mbcxid, mbccid, 1, tagname)
call component_exch_moab(comp(1), mbcxid, mbccid, 1, tagname, context_exch='aream')

! For only component pes
if (comp(1)%iamin_compid) then
Expand Down Expand Up @@ -795,6 +822,23 @@ subroutine component_init_areacor_moab (comp, mbccid, mbcxid, seq_flds_c2x_fluxe
call shr_sys_abort(subname//' cannot set correction area factors ')
endif

! print the computed values for area factors
rmin1 = minval(factors(:,1))
rmax1 = maxval(factors(:,1))
mpicom = comp(1)%mpicom_compid
iamroot= comp(1)%iamroot_compid
call shr_mpi_min(rmin1,rmin,mpicom)
call shr_mpi_max(rmax1,rmax,mpicom)
comment = 'areafact_'//trim(comp(1)%name)
if (iamroot) write(logunit,F0R) trim(subname),' : min/max mdl2drv ',rmin,rmax,trim(comment)

rmin1 = minval(factors(:,2))
rmax1 = maxval(factors(:,2))
call shr_mpi_min(rmin1,rmin,mpicom)
call shr_mpi_max(rmax1,rmax,mpicom)
if (iamroot) write(logunit,F0R) trim(subname),' : min/max drv2mdl ',rmin,rmax,trim(comment)
if (iamroot) call shr_sys_flush(logunit)

! Area correct component initialization output fields
! need to multiply fluxes (correct them) with mdl2drv (factors(i,1))
! so get all fluxes (tags) multiply with factor(i,1), according to mask
Expand Down Expand Up @@ -836,7 +880,7 @@ subroutine component_init_areacor_moab (comp, mbccid, mbcxid, seq_flds_c2x_fluxe

endif
! send data to coupler exchange ? everything, not only fluxes ?
call component_exch_moab(comp(1), mbccid, mbcxid, 0, seq_flds_c2x_fields)
call component_exch_moab(comp(1), mbccid, mbcxid, 0, seq_flds_c2x_fields, context_exch='areacor')
endif

end subroutine component_init_areacor_moab
Expand Down
Loading