Skip to content

Commit

Permalink
Merge pull request #3 from gold2718/update_noresm
Browse files Browse the repository at this point in the history
Update NorESM MOSART with the latest changes from ESCOMP.
  • Loading branch information
gold2718 authored Apr 27, 2023
2 parents b13c753 + abd2bc4 commit 7f844f6
Show file tree
Hide file tree
Showing 23 changed files with 390 additions and 218 deletions.
2 changes: 1 addition & 1 deletion cime_config/buildlib
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import os, sys
CIMEROOT = os.environ.get("CIMEROOT")
if CIMEROOT is None:
raise SystemExit("ERROR: must set CIMEROOT environment variable")
sys.path.append(os.path.join(CIMEROOT, "scripts", "Tools"))
sys.path.append(os.path.join(CIMEROOT, "scripts", "CIME", "Tools"))

from standard_script_setup import *
from CIME.case import Case
Expand Down
27 changes: 23 additions & 4 deletions cime_config/buildnml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import os, shutil, sys
CIMEROOT = os.environ.get("CIMEROOT")
if CIMEROOT is None:
raise SystemExit("ERROR: must set CIMEROOT environment variable")
sys.path.append(os.path.join(CIMEROOT, "scripts", "Tools"))
sys.path.append(os.path.join(CIMEROOT, "scripts", "CIME", "Tools"))

from standard_script_setup import *
from CIME.case import Case
Expand All @@ -40,8 +40,19 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path
#----------------------------------------------------
config = {}
config['mosart_mode'] = case.get_value("MOSART_MODE")
config['mosart_flood_mode'] = case.get_value("MOSART_FLOOD_MODE")
config['ignore_warn'] = case.get_value("MOSART_IGNORE_WARNINGS")
config['clm_accel'] = case.get_value("CLM_ACCELERATED_SPINUP")
ignore_msg = "\n (Set MOSART_IGNORE_WARNINGS to TRUE with xmlchange in your case to ignore this message and continue anyway)"
if ( config['clm_accel'] != "off" ):
if ( config['mosart_mode'] != "NULL" ):
message = "CLM_ACCELERATED_SPINUP is not off, but MOSART_MODE is not NULL, " + \
"normally you should switch it off to save computer time"
if ( not config['ignore_warn'] ):
expect(False, message+ignore_msg )
else:
logger.warning( "WARNING::"+message )

config['mosart_flood_mode'] = case.get_value("MOSART_FLOOD_MODE")
config['rof_grid'] = case.get_value("ROF_GRID")
config['lnd_grid'] = case.get_value("LND_GRID")
config['rof_ncpl'] = case.get_value("ROF_NCPL")
Expand Down Expand Up @@ -120,8 +131,16 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path
coupling_period = basedt // mosart_ncpl
nmlgen.set_value("coupling_period", value=coupling_period)

if ( nmlgen.get_value("frivinp_rtm") == "UNSET" ):
raise SystemExit("ERROR: Direction file is NOT set and is required: frivinp_rtm")
if ( nmlgen.get_value("frivinp_rtm") == "UNSET" and config["mosart_mode"] != "NULL" ):
raise SystemExit("ERROR: Direction file is NOT set and is required when MOSART is active: frivinp_rtm")

bypass_routing_option = nmlgen.get_value("bypass_routing_option")
qgwl_runoff_option = nmlgen.get_value("qgwl_runoff_option")
if bypass_routing_option == "none" and qgwl_runoff_option != "all":
raise SystemExit("ERROR: When bypass_routing_option is none, qgwl_runoff_option can only be all")

if bypass_routing_option == "direct_to_outlet" and qgwl_runoff_option == "threshold":
raise SystemExit("ERROR: When bypass_routing_option is direct_to_outlet, qgwl_runoff_option can not be threshold")

#----------------------------------------------------
# Write output file
Expand Down
15 changes: 12 additions & 3 deletions cime_config/config_component.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@
<desc>mode for mosart model, NULL means mosart is turned off</desc>
</entry>

<entry id="MOSART_IGNORE_WARNINGS">
<type>logical</type>
<valid_values>TRUE,FALSE</valid_values>
<default_value>FALSE</default_value>
<group>run_component_mosart</group>
<file>env_run.xml</file>
<desc>If warnings in namelist setttings from buildnml should be ignored or not</desc>
</entry>

<entry id="MOSART_FLOOD_MODE">
<type>char</type>
<valid_values>ACTIVE,NULL</valid_values>
Expand All @@ -47,10 +56,10 @@
<desc>mode for mosart flood feature, NULL means mosart flood is turned off</desc>
</entry>

<entry id="MOSART_SIMYR">
<entry id="MOSART_SIM_YEAR">
<type>char</type>
<valid_values></valid_values>
<default_value>-simyr 2000</default_value>
<default_value>2000</default_value>
<values>
<value compset="1850.*_MOSART">1850</value>
<value compset="HIST.*_MOSART">1850</value>
Expand All @@ -59,7 +68,7 @@
</values>
<group>run_component_mosart</group>
<file>env_run.xml</file>
<desc>MOSART build-namelist options</desc>
<desc>Simulation year to start from -- build-namelist options (currently not used)</desc>
</entry>
<help>
=========================================
Expand Down
25 changes: 3 additions & 22 deletions cime_config/namelist_definition_mosart.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,6 @@
<!-- MOSART Namelist -->
<!-- ======================================================================================== -->

<entry id="do_rtm" >
<type>logical</type>
<category>mosart</category>
<group>mosart_inparm</group>
<desc>
If .true., turn on mosart river routing
If the value of the xml variable ROF GRID in env_build.xml is set to 'null', then
the MOSART build-namelist will set do_mosart to .false.
If do_mosart is set to .false., then MOSART will send a flag of rof_prognostic = .false.
back to the coupler on initialization.
</desc>
<values>
<value>.true.</value>
<value mosart_mode="ACTIVE" clm_accelerated_spinup="off">.true.</value>
<value clm_accelerated_spinup="on">.false.</value>
<value mosart_mode="NULL">.false.</value>
<value rof_grid="null">.false.</value>
</values>
</entry>

<entry id="do_rtmflood" modify_via_xml="MOSART_FLOOD_MODE">
<type>logical</type>
<category>mosart</category>
Expand Down Expand Up @@ -114,7 +94,7 @@
<group>mosart_inparm</group>
<valid_values>direct_in_place,direct_to_outlet,none</valid_values>
<values>
<value>direct_in_place</value>
<value>direct_to_outlet</value>
</values>
<desc>
Method for bypassing routing model.
Expand All @@ -127,10 +107,11 @@
<group>mosart_inparm</group>
<valid_values>all,negative,threshold</valid_values>
<values>
<value>threshold</value>
<value>negative</value>
</values>
<desc>
Method for handling of qgwl runoff inputs.
(threshold is only valid for bypass_routing_option=direct_in_place)
</desc>
</entry>

Expand Down
61 changes: 58 additions & 3 deletions cime_config/testdefs/testlist_mosart.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,40 @@
<option name="comment" >Run a Cold-Start with all machine/compilers</option>
</options>
</test>
<test name="ERS_Ld5" grid="f10_f10_mg37" compset="I2000Clm50BgcCru" testmods="mosart/mosartOff">
<test name="SMS_Lh3" grid="f10_f10_mg37" compset="I2000Clm50BgcCru" testmods="mosart/mosartOff">
<machines>
<machine name="cheyenne" compiler="intel" category="mosart"></machine>
</machines>
<options>
<option name="wallclock">00:20:00</option>
<option name="comment" >Test with MOSART turned off</option>
</options>
</test>
<test name="SMS_Lh3_Vmct" grid="f10_f10_mg37" compset="I2000Clm50BgcCru" testmods="mosart/mosartOff">
<machines>
<machine name="cheyenne" compiler="intel" category="mosart"></machine>
</machines>
<options>
<option name="wallclock">00:20:00</option>
<option name="comment" >Test with MCT and MOSART off</option>
</options>
</test>
<test name="SMS_Lh3" grid="f10_f10_mg37" compset="I2000Clm51Sp" testmods="mosart/clmAccelSpinupIgnoreWarn">
<machines>
<machine name="cheyenne" compiler="gnu" category="mosart"></machine>
</machines>
<options>
<option name="wallclock">00:20:00</option>
<option name="comment" >Test with CLM accelerated spinup, but ignore warnigns so it will send a warning but still run</option>
</options>
</test>
<test name="SMS_Lh3" grid="1x1_brazil" compset="I2000Clm50Sp" testmods="mosart/mosartGridNull">
<machines>
<machine name="cheyenne" compiler="gnu" category="mosart"></machine>
</machines>
<options>
<option name="wallclock">00:20:00</option>
<option name="comment" >Test with grid where ROF is NULL which should turn MOSART off</option>
</options>
</test>
<test name="SMS_D_Ld5" grid="f10_f10_mg37" compset="I1850Clm50Bgc" testmods="mosart/default">
Expand All @@ -48,13 +76,13 @@
<option name="comment" >Smoke test with DEBUG on all machines/compilers</option>
</options>
</test>
<test name="SMS_D_Ld5_Vnuopc" grid="f10_f10_mg37" compset="I2000Clm50BgcCrop" testmods="mosart/default">
<test name="SMS_D_Ld5_Vmct" grid="f10_f10_mg37" compset="I2000Clm50BgcCrop" testmods="mosart/default">
<machines>
<machine name="cheyenne" compiler="intel" category="mosart"></machine>
</machines>
<options>
<option name="wallclock">00:20:00</option>
<option name="comment" >Smoke test with DEBUG and NUOPC driver</option>
<option name="comment" >Smoke test with DEBUG and MCT driver</option>
</options>
</test>
<test name="SMS_D" grid="f10_f10_mg37" compset="I1850Clm50Bgc" testmods="mosart/decompOpts">
Expand All @@ -66,6 +94,15 @@
<option name="comment" >decompOpts are not bit for bit on PE layout change</option>
</options>
</test>
<test name="SMS_D" grid="f10_f10_mg37" compset="I1850Clm50Bgc" testmods="mosart/passChannelDepths">
<machines>
<machine name="cheyenne" compiler="intel" category="mosart"></machine>
</machines>
<options>
<option name="wallclock">00:20:00</option>
<option name="comment" >Pass channel depths needed for hillslope model</option>
</options>
</test>
<test name="ERP_D" grid="f10_f10_mg37" compset="I1850Clm50Bgc" testmods="mosart/qgrwlOpts">
<machines>
<machine name="cheyenne" compiler="intel" category="mosart"></machine>
Expand All @@ -74,4 +111,22 @@
<option name="wallclock">00:20:00</option>
</options>
</test>
<test name="PEM_D" grid="f10_f10_mg37" compset="I1850Clm50Sp" testmods="mosart/inplacethreshold">
<machines>
<machine name="cheyenne" compiler="intel" category="mosart"></machine>
</machines>
<options>
<option name="wallclock">00:20:00</option>
<option name="comment" >Set direct_in_place for threshold negative flow</option>
</options>
</test>
<test name="SMS" grid="f10_f10_mg37" compset="I1850Clm50Sp" testmods="mosart/nobypass">
<machines>
<machine name="cheyenne" compiler="intel" category="mosart"></machine>
</machines>
<options>
<option name="wallclock">00:20:00</option>
<option name="comment" >Run without any bypass option</option>
</options>
</test>
</testlist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
./xmlchange CLM_ACCELERATED_SPINUP=on
./xmlchange MOSART_IGNORE_WARNINGS=TRUE
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
! do_rtm = .true.
! ice_runoff = .true.
rtmhist_ndens = 1,1,1
rtmhist_nhtfrq =-24,-8
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
do_rtm = .true.
ice_runoff = .false.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
qgwl_runoff_option = 'threshold'
bypass_routing_option = 'direct_in_place'
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Test for a case when the MOSART grid is NULL and hence MOSART should be turned off
Since this happens at create_newcase this should be done for a grid where the ROF_GRID
is already NULL, so for example a single point case.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./xmlchange ROF_GRID=null
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./xmlchange MOSART_MODE=null

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
qgwl_runoff_option = 'all'
bypass_routing_option = 'none'
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
flds_r2l_stream_channel_depths = .true.
3 changes: 0 additions & 3 deletions cime_config/user_nl_mosart
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
! namelist_var = new_namelist_value
! NOTE: namelist variable rtm_tstep CAN ONLY be changed by modifying the value
! of the xml variable ROF_NCPL in env_run.xml
! NOTE: if the xml variable ROF GRID in env_build.xml is set to 'null', then
! the RTM build-namelist will set do_rtm to .false. - and will ignore
! any change below
!----------------------------------------------------------------------------------


78 changes: 78 additions & 0 deletions docs/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,81 @@
===============================================================
Tag name: mosart1_0_48
Originator(s): erik
Date: Nov 13, 2022
One-line Summary: Change bypass_routing option to direct_to_outlet

Change the bypass_routing option to negative flow is sent to
the river outlets.

Fixes #58 -- change bypass_routing default

===============================================================
Tag name: mosart1_0_47
Originator(s): erik
Date: Nov 12, 2022
One-line Summary: Some fixes for the direct_to_outlet option

This fixes the balance errors evident in the mosart log file when
the bypass_routing_option='direct_to_outlet' method is used.
Note that these balance errors are warnings and do not stop the model.

Code from @swensosc, PR by @olyson

Fixes #54 -- update cime directory in buildlib/buildnml
Fixes #56 -- Some issues with the direct_to_outlet option

Also don't allow the threshold option to be set with
direct_to_outlet is choosen, as well as any option other
than "all" for "none".

Answers change when direct_to_outlet option is used

===============================================================
Tag name: mosart1_0_46
Originator(s): jedwards
Date: Jun 12, 2022
One-line Summary: PIO ascynchronus changes

Currently mosart initializes and try's to use IO in the advertise phase, but asyncio requires that this is not done until the
realize phase. This PR splits the mosart initialization so that the namelist is still read in the advertise phase but IO waits until
the realize phase. Tested with cesm prealpha tests on cheyenne, a modification was also required in the mct driver to handle the new
initialize subroutine.

===============================================================
Tag name: mosart1_0_45
Originator(s): erik
Date: Nov 12, 2021
One-line Summary: Handle CLM_ACCELERATED_SPINUP option differently

Handle CLM_ACCELERATED_SPINUP option differently so it doesn't change
MOSART_MODE, but dies (unless the new xml variable MOSART_IGNORE_WARNINGS
is set to TRUE). Also only output information about decomposition from all
PE's only if running with DEBUG compiler options set.

Fixes #48 -- Remove setting of MOSART_MODE from buildnml
Fixes #49 -- Reduce MOSART output to cesm.log

===============================================================
Tag name: mosart1_0_44
Originator(s): erik
Date: Nov 02, 2021
One-line Summary: Nuopc now the default driver, pass channel depth fields, remove do_rtm namelist

Assume nuopc is the default driver now, so switch testlist for special driver tests
to be mct rather than nuopc. Pass channel depth fields if flds_r2l_stream_channel_depths
is set in the driver. Remove do_rtm option and trigger MOSART_MODE==NULL instead.

Fixes #47 -- do_rtm not working with NUOPC
Fixes #45 -- frivinp_rtm is still required even if MOSART is turned off
Fixes #44 -- Remove reference to Flrl_rofdto
Fixes #36 -- pass water depths to LND
Fixes #20 -- MOSART_SIMYR not setup correctly

This test fails in the build unless there is an appropriate verison of CMEPS:

SMS_D.f10_f10_mg37.I1850Clm50Bgc.cheyenne_intel.mosart-passChannelDepths
SHARED_BUILD -- FAIL

===============================================================
Tag name: mosart1_0_43
Originator(s): erik
Expand Down
Loading

0 comments on commit 7f844f6

Please sign in to comment.