diff --git a/cime_config/buildnml b/cime_config/buildnml index 68dbebc..6dd7ea4 100755 --- a/cime_config/buildnml +++ b/cime_config/buildnml @@ -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 #---------------------------------------------------- @@ -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']) diff --git a/cime_config/config_component.xml b/cime_config/config_component.xml index 84b4619..154a399 100644 --- a/cime_config/config_component.xml +++ b/cime_config/config_component.xml @@ -14,7 +14,7 @@ MOSART model with flood: - + char mosart mosart @@ -70,6 +70,17 @@ env_run.xml Simulation year to start from -- build-namelist options (currently not used) + + + char + TRUE,FALSE + FALSE + run_component_mosart + env_run.xml + Debug mosart code + + + ========================================= MOSART naming conventions diff --git a/cime_config/namelist_definition_mosart.xml b/cime_config/namelist_definition_mosart.xml index f1a9e36..3d1c7f2 100644 --- a/cime_config/namelist_definition_mosart.xml +++ b/cime_config/namelist_definition_mosart.xml @@ -269,4 +269,19 @@ + + logical + mosart + mosart_inparm + + .false. + .true. + .false. + + + Default: .false. + This flag turned on will write out warnings, when strange values appear (i.e. negative water storage) + + + diff --git a/src/riverroute/mosart_control_type.F90 b/src/riverroute/mosart_control_type.F90 index 04d0c08..161f203 100644 --- a/src/riverroute/mosart_control_type.F90 +++ b/src/riverroute/mosart_control_type.F90 @@ -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) @@ -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 diff --git a/src/riverroute/mosart_driver.F90 b/src/riverroute/mosart_driver.F90 index 6fc480c..869e676 100644 --- a/src/riverroute/mosart_driver.F90 +++ b/src/riverroute/mosart_driver.F90 @@ -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 @@ -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 @@ -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. diff --git a/src/riverroute/mosart_physics.F90 b/src/riverroute/mosart_physics.F90 index eac173d..c5f2cbe 100644 --- a/src/riverroute/mosart_physics.F90 +++ b/src/riverroute/mosart_physics.F90 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/src/riverroute/mosart_vars.F90 b/src/riverroute/mosart_vars.F90 index 02d427b..7d29912 100644 --- a/src/riverroute/mosart_vars.F90 +++ b/src/riverroute/mosart_vars.F90 @@ -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