Skip to content

Commit

Permalink
new ability to set separate of fluxes to mediator as option
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariana Vertenstein committed Jun 6, 2024
1 parent b8f3aef commit d729df9
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 29 deletions.
16 changes: 15 additions & 1 deletion cime_config/namelist_definition_mosart.xml
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,24 @@
<value>-24</value>
</values>
<desc>
Frequency to perform budget check. Similar to nhtfrq,
Frequency to perform budget check. Similar to nhtfrq,
positive means in time steps, 0=monthly, negative means hours
(i.e. 24 means every 24 time-steps and -24 means every day
</desc>
</entry>

<entry id="separate_glc2ocn_fluxes">
<type>logical</type>
<category>mosart</category>
<group>mosart_inparm</group>
<values>
<value>.false.</value>
</values>
<desc>
Default: .false.
If .true., glc2ocn fluxes that are passed through mosart will be sent
as a separate fields to the mediator.
</desc>
</entry>

</entry_id>
33 changes: 28 additions & 5 deletions src/cpl/nuopc/rof_import_export.F90
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module rof_import_export
use NUOPC_Model , only : NUOPC_ModelGet
use shr_kind_mod , only : r8 => shr_kind_r8
use shr_sys_mod , only : shr_sys_abort
use mosart_vars , only : iulog, mainproc, mpicom_rof, ice_runoff
use mosart_vars , only : iulog, mainproc, mpicom_rof, ice_runoff, separate_glc2ocn_fluxes
use mosart_data , only : ctl, TRunoff, TUnit
use mosart_timemanager , only : get_nstep
use nuopc_shr_methods , only : chkerr
Expand Down Expand Up @@ -82,9 +82,14 @@ subroutine advertise_fields(gcomp, flds_scalar_name, rc)
isPresent=isPresent, isSet=isSet, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
if (isPresent .and. isSet) read(cvalue,*) flds_r2l_stream_channel_depths

call fldlist_add(fldsFrRof_num, fldsFrRof, trim(flds_scalar_name))
call fldlist_add(fldsFrRof_num, fldsFrRof, 'Forr_rofl')
call fldlist_add(fldsFrRof_num, fldsFrRof, 'Forr_rofi')
if (separate_glc2ocn_fluxes) then
call fldlist_add(fldsFrRof_num, fldsFrRof, 'Forr_rofl_glc')
call fldlist_add(fldsFrRof_num, fldsFrRof, 'Forr_rofi_glc')
end if
call fldlist_add(fldsFrRof_num, fldsFrRof, 'Flrr_flood')
call fldlist_add(fldsFrRof_num, fldsFrRof, 'Flrr_volr')
call fldlist_add(fldsFrRof_num, fldsFrRof, 'Flrr_volrmch')
Expand Down Expand Up @@ -309,6 +314,8 @@ subroutine export_fields (gcomp, begr, endr, rc)
integer :: nliq, nice
real(r8) :: rofl(begr:endr)
real(r8) :: rofi(begr:endr)
real(r8) :: rofl_glc(begr:endr)
real(r8) :: rofi_glc(begr:endr)
real(r8) :: flood(begr:endr)
real(r8) :: volr(begr:endr)
real(r8) :: volrmch(begr:endr)
Expand Down Expand Up @@ -361,10 +368,18 @@ subroutine export_fields (gcomp, begr, endr, rc)
rofi(n) = 0._r8
end do
end if
do n = begr,endr
rofl(n) = rofl(n) + ctl%direct_glc(n,nliq) / (ctl%area(n)*0.001_r8)
rofi(n) = rofl(n) + ctl%direct_glc(n,nice) / (ctl%area(n)*0.001_r8)
end do

if (separate_glc2ocn_fluxes) then
do n = begr,endr
rofl_glc(n) = ctl%direct_glc(n,nliq) / (ctl%area(n)*0.001_r8)
rofi_glc(n) = ctl%direct_glc(n,nice) / (ctl%area(n)*0.001_r8)
end do
else
do n = begr,endr
rofl(n) = rofl(n) + ctl%direct_glc(n,nliq) / (ctl%area(n)*0.001_r8)
rofi(n) = rofi(n) + ctl%direct_glc(n,nice) / (ctl%area(n)*0.001_r8)
end do
end if

! Flooding back to land, sign convention is positive in land->rof direction
! so if water is sent from rof to land, the flux must be negative.
Expand All @@ -388,6 +403,14 @@ subroutine export_fields (gcomp, begr, endr, rc)
call state_setexport(exportState, 'Forr_rofi', begr, endr, input=rofi, do_area_correction=.true., rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

if (separate_glc2ocn_fluxes) then
call state_setexport(exportState, 'Forr_rofl_glc', begr, endr, input=rofl_glc, do_area_correction=.true., rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

call state_setexport(exportState, 'Forr_rofi_glc', begr, endr, input=rofi_glc, do_area_correction=.true., rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
end if

call state_setexport(exportState, 'Flrr_flood', begr, endr, input=flood, do_area_correction=.true., rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

Expand Down
39 changes: 22 additions & 17 deletions src/riverroute/mosart_driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ module mosart_driver
frivinp, nsrContinue, nsrBranch, nsrStartup, nsrest, &
inst_index, inst_suffix, inst_name, decomp_option, &
bypass_routing_option, qgwl_runoff_option, barrier_timers, &
mainproc, npes, iam, mpicom_rof, budget_frq, isecspday
mainproc, npes, iam, mpicom_rof, budget_frq, isecspday, &
separate_glc2ocn_fluxes
use mosart_data , only : ctl, Tctl, Tunit, TRunoff, Tpara
use mosart_budget_type , only : budget_type
use mosart_fileutils , only : getfil
Expand Down Expand Up @@ -42,11 +43,11 @@ module mosart_driver
public :: mosart_run ! River routing model

! mosart namelists
integer :: coupling_period ! mosart coupling period
integer :: delt_mosart ! mosart internal timestep (->nsub)
logical :: use_halo_option ! enable halo capability using ESMF
character(len=CS) :: mosart_tracers ! colon delimited string of tracer names
character(len=CS) :: mosart_euler_calc ! colon delimited string of logicals for using Euler algorithm
integer :: coupling_period ! mosart coupling period
integer :: delt_mosart ! mosart internal timestep (->nsub)
logical :: use_halo_option ! enable halo capability using ESMF
character(len=CS) :: mosart_tracers ! colon delimited string of tracer names
character(len=CS) :: mosart_euler_calc ! colon delimited string of logicals for using Euler algorithm

! subcycling
integer :: nsub_save ! previous nsub
Expand Down Expand Up @@ -91,7 +92,8 @@ subroutine mosart_read_namelist()
namelist /mosart_inparm / frivinp, finidat, nrevsn, coupling_period, ice_runoff, &
ndens, mfilt, nhtfrq, fincl1, fincl2, fincl3, fexcl1, fexcl2, fexcl3, &
avgflag_pertape, decomp_option, bypass_routing_option, qgwl_runoff_option, &
use_halo_option, delt_mosart, mosart_tracers, mosart_euler_calc, budget_frq
use_halo_option, delt_mosart, mosart_tracers, mosart_euler_calc, budget_frq, &
separate_glc2ocn_fluxes

! Preset values
ice_runoff = .true.
Expand All @@ -105,6 +107,7 @@ subroutine mosart_read_namelist()
use_halo_option = .false.
mosart_tracers = 'LIQ:ICE'
mosart_euler_calc = 'T:F'
separate_glc2ocn_fluxes = .false.

nlfilename_rof = "mosart_in" // trim(inst_suffix)
inquire (file = trim(nlfilename_rof), exist = lexist)
Expand Down Expand Up @@ -148,6 +151,7 @@ subroutine mosart_read_namelist()
call mpi_bcast (mosart_tracers, CS, MPI_CHARACTER, 0, mpicom_rof, ier)
call mpi_bcast (mosart_euler_calc, CS, MPI_CHARACTER, 0, mpicom_rof, ier)
call mpi_bcast (budget_frq,1,MPI_INTEGER,0,mpicom_rof,ier)
call mpi_bcast (separate_glc2ocn_fluxes, 1, MPI_LOGICAL, 0, mpicom_rof, ier)

! Determine number of tracers and array of tracer names and initialize module variables
call ctl%init_tracer_names(mosart_tracers)
Expand All @@ -161,17 +165,18 @@ subroutine mosart_read_namelist()

if (mainproc) then
write(iulog,*) 'define run:'
write(iulog,'(a)' ) ' run type = '//trim(runtyp(nsrest+1))
write(iulog,'(a,i8)') ' coupling_period = ',coupling_period
write(iulog,'(a,i8)') ' delt_mosart = ',delt_mosart
write(iulog,'(a)' ) ' decomp option = '//trim(decomp_option)
write(iulog,'(a,l1)') ' use_halo_option = ',use_halo_option
write(iulog,'(a)' ) ' bypass_routing option = '//trim(bypass_routing_option)
write(iulog,'(a)' ) ' qgwl runoff option = '//trim(qgwl_runoff_option)
write(iulog,'(a)' ) ' mosart tracers = '//trim(mosart_tracers)
write(iulog,'(a)' ) ' mosart euler calc = '//trim(mosart_euler_calc)
write(iulog,'(a)' ) ' run type = '//trim(runtyp(nsrest+1))
write(iulog,'(a,i8)') ' coupling_period = ',coupling_period
write(iulog,'(a,i8)') ' delt_mosart = ',delt_mosart
write(iulog,'(a)' ) ' decomp option = '//trim(decomp_option)
write(iulog,'(a,l1)') ' use_halo_option = ',use_halo_option
write(iulog,'(a)' ) ' bypass_routing option = '//trim(bypass_routing_option)
write(iulog,'(a)' ) ' qgwl runoff option = '//trim(qgwl_runoff_option)
write(iulog,'(a)' ) ' mosart tracers = '//trim(mosart_tracers)
write(iulog,'(a)' ) ' mosart euler calc = '//trim(mosart_euler_calc)
write(iulog,'(a,l1)') ' separate_glc2ocn_fluxes = ',separate_glc2ocn_fluxes
if (nsrest == nsrStartup .and. finidat /= ' ') then
write(iulog,'(a)') ' mosart initial data = '//trim(finidat)
write(iulog,'(a)') ' mosart initial data = '//trim(finidat)
end if
endif

Expand Down
13 changes: 7 additions & 6 deletions src/riverroute/mosart_vars.F90
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ module mosart_vars
integer :: nsrest = iundef ! Type of run

! Namelist variables
character(len=CL) :: frivinp ! MOSART input data file name
logical :: ice_runoff ! true => runoff is split into liquid and ice, otherwise just liquid
character(len=CS) :: decomp_option ! decomp option
character(len=CS) :: bypass_routing_option ! bypass routing model method
character(len=CS) :: qgwl_runoff_option ! method for handling qgwl runoff
integer :: budget_frq = -24 ! budget check frequency
character(len=CL) :: frivinp ! MOSART input data file name
logical :: ice_runoff ! true => runoff is split into liquid and ice, otherwise just liquid
character(len=CS) :: decomp_option ! decomp option
character(len=CS) :: bypass_routing_option ! bypass routing model method
character(len=CS) :: qgwl_runoff_option ! method for handling qgwl runoff
integer :: budget_frq = -24 ! budget check frequency
logical :: separate_glc2cn_fluxes ! true => send fluxes from glc through mozart separately to mediator

! Metadata variables used in history and restart generation
character(len=CL) :: caseid = ' ' ! case id
Expand Down

0 comments on commit d729df9

Please sign in to comment.