Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions cime_config/buildnml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path
different instances. The `confdir` argument is used to specify the directory
in which output files will be placed.
"""
mosart_debug = case.get_value('MOSART_DEBUG')

#----------------------------------------------------
# Create config dictionary
#----------------------------------------------------
Expand All @@ -57,6 +59,7 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path
config['lnd_grid'] = case.get_value("LND_GRID")
config['rof_ncpl'] = case.get_value("ROF_NCPL")
config['simyr'] = case.get_value("MOSART_SIM_YEAR")
config['mosart_debug'] = "yes" if (mosart_debug == 'TRUE') else "no"

logger.debug("River Transport Model (MOSART) mode is %s ", config['mosart_mode'])
logger.debug(" MOSART lnd grid is %s ", config['lnd_grid'])
Expand Down
13 changes: 12 additions & 1 deletion cime_config/config_component.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<desc option="FLOOD">MOSART model with flood:</desc>
</description>

<entry id="COMP_ROF">
<entry id="COMP_ROF">
<type>char</type>
<valid_values>mosart</valid_values>
<default_value>mosart</default_value>
Expand Down Expand Up @@ -70,6 +70,17 @@
<file>env_run.xml</file>
<desc>Simulation year to start from -- build-namelist options (currently not used)</desc>
</entry>

<entry id="MOSART_DEBUG">
<type>char</type>
<valid_values>TRUE,FALSE</valid_values>
<default_value>FALSE</default_value>
<group>run_component_mosart</group>
<file>env_run.xml</file>
<desc>Debug mosart code</desc>
</entry>


<help>
=========================================
MOSART naming conventions
Expand Down
15 changes: 15 additions & 0 deletions cime_config/namelist_definition_mosart.xml
Original file line number Diff line number Diff line change
Expand Up @@ -269,4 +269,19 @@
</desc>
</entry>

<entry id="debug_mosart" modify_via_xml="MOSART_DEBUG" >
<type>logical</type>
<category>mosart</category>
<group>mosart_inparm</group>
<values>
<value>.false.</value>
<value mosart_debug="yes">.true.</value>
<value mosart_debug="no">.false.</value>
</values>
<desc>
Default: .false.
This flag turned on will write out warnings, when strange values appear (i.e. negative water storage)
</desc>
</entry>

</entry_id>
6 changes: 3 additions & 3 deletions src/riverroute/mosart_control_type.F90
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,6 @@ subroutine init_tracer_names(this, lnd2rof_tracers)
this%nt_liq = 1 ! liquid water
this%nt_ice = 2 ! ice

this%tracer_names(this%nt_liq) = 'LIQ'
this%tracer_names(this%nt_ice) = 'ICE'

! Determine number of tracers and array of tracer names
if (lnd2rof_tracers /= ' ') then
this%ntracers_nonh2o = shr_string_listGetNum(lnd2rof_tracers)
Expand All @@ -166,6 +163,9 @@ subroutine init_tracer_names(this, lnd2rof_tracers)
this%ntracers_tot = this%nt_ice + this%ntracers_nonh2o ! liquid water and ice + nonH2O tracers

allocate(this%tracer_names(this%ntracers_tot))

this%tracer_names(this%nt_liq) = 'LIQ'
this%tracer_names(this%nt_ice) = 'ICE'

! names of non-water liquid tracers
do nt = 1,this%ntracers_nonh2o
Expand Down
6 changes: 4 additions & 2 deletions src/riverroute/mosart_driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,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, &
debug_mosart
use mosart_data , only : ctl, Tctl, Tunit, TRunoff, Tpara
use mosart_budget_type , only : budget_type
use mosart_fileutils , only : getfil
Expand All @@ -36,6 +37,7 @@ module mosart_driver
implicit none
private


! public member functions:
public :: mosart_read_namelist ! Read in mosart namelist
public :: mosart_init1 ! Initialize mosart grid
Expand Down Expand Up @@ -90,7 +92,7 @@ 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, budget_frq
use_halo_option, delt_mosart, budget_frq,debug_mosart

! Preset values
ice_runoff = .true.
Expand Down
59 changes: 33 additions & 26 deletions src/riverroute/mosart_physics.F90
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ module mosart_physics
use shr_kind_mod , only : r8 => shr_kind_r8
use shr_const_mod , only : SHR_CONST_REARTH, SHR_CONST_PI
use shr_sys_mod , only : shr_sys_abort
use mosart_vars , only : iulog, barrier_timers, mpicom_rof, bypass_routing_option
use mosart_vars , only : iulog, barrier_timers, mpicom_rof, bypass_routing_option, &
debug_mosart
use mosart_data , only : Tctl, TUnit, TRunoff, TPara, ctl
use perf_mod , only : t_startf, t_stopf
use nuopc_shr_methods , only : chkerr
Expand Down Expand Up @@ -268,11 +269,13 @@ subroutine Euler(rc)
erin(nr,nt), erout(nr,nt), vr(nr,nt), dwr(nr,nt)) ! output
wr(nr,nt) = wr(nr,nt) + dwr(nr,nt) * localDeltaT

! check for negative channel storage
! if(wr(nr,1) < -1.e-10) then
! write(iulog,*) 'Negative channel storage! ', nr, wr(nr,1)
! call shr_sys_abort('mosart: negative channel storage')
! end if
if (debug_mosart) then
! check for negative channel storage
if(wr(nr,1) < -1.e-10) then
write(iulog,*) 'DEBUG: Negative channel storage! ', nr, wr(nr,1)
!call shr_sys_abort('mosart: negative channel storage')
end if
end if

call UpdateState_mainchannel(nr, wr(nr,nt), & ! input
mr(nr,nt), yr(nr,nt), pr(nr,nt), rr(nr,nt)) ! output
Expand All @@ -292,10 +295,12 @@ subroutine Euler(rc)
call t_stopf('mosartr_chanroute')
end do

! check for negative channel storage
if (negchan < -1.e-10) then
write(iulog,*) 'Warning: Negative channel storage found! ',negchan
! call shr_sys_abort('mosart: negative channel storage')
if (debug_mosart) then
! check for negative channel storage
if (negchan < -1.e-10) then
write(iulog,*) 'DEBUG: Warning: Negative channel storage found! ',negchan
! call shr_sys_abort('mosart: negative channel storage')
endif
endif
flow = flow / DLevelH2R
erout_prev = erout_prev / DLevelH2R
Expand Down Expand Up @@ -358,10 +363,12 @@ subroutine subnetworkRouting(nr, DeltaT, rt, mt, wt, etin, etout, vt, dwt)
end if
dwt = etin + etout

if (debug_mosart) then
! check stability
! if(vt < -TINYVALUE .or. vt > 30) then
! write(iulog,*) "Numerical error in subnetworkRouting, ", nr,vt
! end if
if(vt < -TINYVALUE .or. vt > 30) then
write(iulog,*) "DEBUG: Numerical error in subnetworkRouting, ", nr,vt
end if
endif

end subroutine subnetworkRouting

Expand Down Expand Up @@ -428,23 +435,23 @@ subroutine mainchannelRouting(nr, DeltaT, eroutUp, erlateral, wr, mr, rr, qgwl,
dwr = erlateral + erin + erout + temp_gwl

if ((wr/DeltaT + dwr) < -TINYVALUE .and. (trim(bypass_routing_option)/='none') ) then
write(iulog,*) 'mosart: ERROR main channel going negative: ', nr
write(iulog,*) 'DEBUG: mosart: ERROR main channel going negative: ', nr
write(iulog,*) DeltaT, wr, wr/DeltaT, dwr, temp_gwl
write(iulog,*) ' '
endif

! check for stability
! if(vr < -TINYVALUE .or. vr > 30) then
! write(iulog,*) "Numerical error inRouting_KW, ", nr,vr
! end if

! check for negative wr
! if(wr > 1._r8 .and. &
! (wr/DeltaT + dwr)/wr < -TINYVALUE) then
! write(iulog,*) 'negative wr!', wr, dwr, temp_gwl, DeltaT
! stop
! end if

if (debug_mosart) then
! check for stability
if(vr < -TINYVALUE .or. vr > 30) then
write(iulog,*) "DEBUG: Numerical error inRouting_KW, ", nr,vr
end if

! check for negative wr
if(wr > 1._r8 .and. (wr/DeltaT + dwr)/wr < -TINYVALUE) then
write(iulog,*) 'DEBUG: negative wr!', wr, dwr, temp_gwl, DeltaT
! stop
end if
endif
end associate
end subroutine MainchannelRouting

Expand Down
2 changes: 2 additions & 0 deletions src/riverroute/mosart_vars.F90
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ module mosart_vars
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
! debugging
logical :: debug_mosart = .false.

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