Skip to content

Commit

Permalink
Merge pull request #391 from ekluzek/fixfornagonizumi
Browse files Browse the repository at this point in the history
Some fixes so can run on izumi
  • Loading branch information
nmizukami authored Jul 19, 2023
2 parents f7d7bfc + 030479e commit 55da196
Show file tree
Hide file tree
Showing 37 changed files with 402 additions and 201 deletions.
2 changes: 1 addition & 1 deletion cime_config/buildlib
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def _main_func():
complib = os.path.join(libroot,"librof.a")
makefile = os.path.join(casetools, "Makefile")

cmd = "{} complib -j {} MODEL=mizuRoute COMPLIB={} -f {} {}" \
cmd = "{} complib -j {} COMP_NAME=mizuRoute COMPLIB={} -f {} {}" \
.format(gmake, gmake_j, complib, makefile, get_standard_makefile_args(case))

rc, out, err = run_cmd(cmd)
Expand Down
38 changes: 20 additions & 18 deletions cime_config/buildnml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ 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"))
_LIBDIR = os.path.join(CIMEROOT, "CIME", "Tools")
sys.path.append(_LIBDIR)
# Path for mizuRoute/route/settings for both a mizuRoute standalone checkout as well as a CESM checkout
sys.path.append(os.path.join(CIMEROOT, "..", "route", "settings"))
sys.path.append(os.path.join(CIMEROOT, "..", "components", "mizuRoute", "route", "settings"))

from standard_script_setup import *
from CIME.case import Case
from CIME.nmlgen import NamelistGenerator
from CIME.XML.files import Files
from CIME.utils import expect, safe_copy
from CIME.buildnml import create_namelist_infile, parse_input
from mizuRoute_control import mizuRoute_control
Expand All @@ -30,7 +32,7 @@ logger = logging.getLogger(__name__)

# pylint: disable=too-many-arguments,too-many-locals,too-many-branches,too-many-statements
####################################################################################
def _create_control_files(case, caseroot, srcroot, confdir, inst_string, infile, nmlgen, ctl, data_list_path):
def _create_control_files(case, caseroot, srcroot, confdir, inst_string, infile, nmlgen, ctl):
####################################################################################
"""Write out the input configuration file for mizuRoute
Expand Down Expand Up @@ -124,7 +126,7 @@ def _create_control_files(case, caseroot, srcroot, confdir, inst_string, infile,
varname_downSegId = "Tosegment"
varname_pfafCode = "pfaf"
elif ( config['rof_grid'] == "USGS_GFmz" ):
fname_ntopOld = "ntopo_USGS-GFmz_Conus_cdf5_c20201008.nc"
fname_ntopOld = "ntopo_USGS-GFmz_Conus_cdf5_c20230602.nc"
varname_area = "Basin_Area"
varname_length = "Length"
varname_slope = "Slope"
Expand Down Expand Up @@ -180,7 +182,7 @@ def _create_control_files(case, caseroot, srcroot, confdir, inst_string, infile,
#----------------------------------------------------
# Initialize namelist defaults
#----------------------------------------------------
nmlgen.init_defaults(infile, config)
nmlgen.init_defaults(infile, config, skip_default_for_groups="data_files",)

#----------------------------------------------------
# Check for incompatible options.
Expand All @@ -202,6 +204,7 @@ def _create_control_files(case, caseroot, srcroot, confdir, inst_string, infile,
ctl.set( "input_dir", rundir+"/" )
ctl.set( "ancil_dir", ancil_dir )
ctl.set( "fname_ntopOld", fname_ntopOld )
nmlgen.set_value( "fname_ntopold", value=os.path.join( ancil_dir, fname_ntopOld ) )
ctl.set( "dt_qsim", str(dt_qsim) )
ctl.set( "dname_sseg", dname_sseg )
ctl.set( "dname_nhru", dname_nhru )
Expand Down Expand Up @@ -239,6 +242,8 @@ def _create_control_files(case, caseroot, srcroot, confdir, inst_string, infile,
fname_state_in = "empty"

ctl.set( "fname_state_in", fname_state_in )
if fname_state_in is not "empty":
nmlgen.set_value( "fname_state_in", value=os.path.join( ancil_dir, fname_ntopOld ) )

# Read in the user control file for the case and change settings to it
file_src = "user_nl_mizuroute_control"
Expand All @@ -257,17 +262,18 @@ def _create_control_files(case, caseroot, srcroot, confdir, inst_string, infile,
#----------------------------------------------------
control_file = os.path.join(confdir, "mizuRoute.control")
nml_file = os.path.join(confdir, "mizuRoute_in")
write_nml_in_file(case, nmlgen, confdir, nml_file)
write_nml_in_file(case, nmlgen, confdir, nml_file )
ctl.write( control_file )

###############################################################################
def write_nml_in_file(case, nmlgen, confdir, nml_file):
###############################################################################
data_list_path = os.path.join(case.get_case_root(), "Buildconf", "rof.input_data_list")
data_list_path = os.path.join(case.get_case_root(), "Buildconf", "mizuroute.input_data_list")
if os.path.exists(data_list_path):
os.remove(data_list_path)

namelist_file = os.path.join(confdir, nml_file)
nmlgen.write_output_file(namelist_file, data_list_path )
nmlgen.write_output_file(namelist_file, data_list_path=data_list_path, groups=["HSLOPE", "IRF_UH", "KWT"])

###############################################################################
def buildnml(case, caseroot, compname):
Expand All @@ -294,13 +300,6 @@ def buildnml(case, caseroot, compname):
ctl = mizuRoute_control()
ctl.read( sampleFile )

#----------------------------------------------------
# Clear out old data.
#----------------------------------------------------
data_list_path = os.path.join(case.get_case_root(), "Buildconf", "mizuRoute.input_data_list")
if os.path.exists(data_list_path):
os.remove(data_list_path)

#----------------------------------------------------
# Do some checking
#----------------------------------------------------
Expand All @@ -322,12 +321,15 @@ def buildnml(case, caseroot, compname):
create_namelist_infile(case, user_nl_file, infile)
control_infile = [infile]

# NOTE: User definition *replaces* existing definition.
files = Files(comp_interface="nuopc")

# Create the namelist generator object - independent of instance
definition_files = [srcroot + "/cime_config/namelist_definition_mizuRoute.xml"]
nmlgen = NamelistGenerator(case, definition_files)
definition_files = [os.path.join( srcroot, "cime_config/namelist_definition_mizuRoute.xml") ]
nmlgen = NamelistGenerator(case, definition_files, files=files)

# create control files
_create_control_files(case, caseroot, srcroot, confdir, inst_string, control_infile, nmlgen, ctl, data_list_path)
_create_control_files(case, caseroot, srcroot, confdir, inst_string, control_infile, nmlgen, ctl)

# copy control files to rundir
if os.path.isdir(rundir):
Expand All @@ -343,7 +345,7 @@ def buildnml(case, caseroot, compname):
def _main_func():

caseroot = parse_input(sys.argv)
with Case(caseroot) as case:
with Case(case_root=caseroot) as case:
buildnml(case, caseroot, "mizuRoute")

if __name__ == "__main__":
Expand Down
3 changes: 2 additions & 1 deletion cime_config/config_archive.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
<comp_archive_spec compname="mizuroute" compclass="rof">
<rest_file_extension>r</rest_file_extension>
<hist_file_extension>h.*\.nc$</hist_file_extension>
<rest_history_varname>unset</rest_history_varname>
<hist_file_extension>h_gauge.*\.nc$</hist_file_extension>
<rest_history_varname>history_file</rest_history_varname>
<rpointer>
<rpointer_file>rpointer.rof</rpointer_file>
<rpointer_content>./$CASE.mizuroute.r.$DATENAME.nc</rpointer_content>
Expand Down
23 changes: 23 additions & 0 deletions cime_config/namelist_definition_mizuRoute.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,27 @@
</entry>


<!-- =========================== -->
<!-- group DATA -->
<!-- =========================== -->
<entry id="fname_ntopold">
<type>char</type>
<category>datasets</category>
<input_pathname>abs</input_pathname>
<group>data_files</group>
<desc>
River network description file
</desc>
</entry>

<entry id="fname_state_in">
<type>char</type>
<category>datasets</category>
<input_pathname>abs</input_pathname>
<group>data_files</group>
<desc>
Initial conditions file
</desc>
</entry>

</entry_id>
19 changes: 14 additions & 5 deletions cime_config/test/env_case.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@
<entry id="CONFIG_ROF_FILE" value="$COMP_ROOT_DIR_ROF/cime_config/config_component.xml">
<type>char</type>
<desc>file containing specification of component specific definitions and values(for documentation only - DO NOT EDIT)</desc>
<schema version="2.0">$CIMEROOT/config/xml_schemas/entry_id.xsd</schema>
<schema version="3.0">$CIMEROOT/config/xml_schemas/entry_id_version3.xsd</schema>
<schema version="2.0">$CIMEROOT/CIME/data/config/xml_schemas/entry_id.xsd</schema>
<schema version="3.0">$CIMEROOT/CIME/data/config/xml_schemas/entry_id_version3.xsd</schema>
</entry>

<entry id="COMPSET" value="1850_DATM%GSWP3v1_CLM50%BGC-CROP_SICE_SOCN_MIZUROUTE_CISM2%NOEVOLVE_SWAV_SIAC_SESP">
<type>char</type>
<desc>Component set long name (for documentation only - DO NOT EDIT)</desc>
</entry>

<entry id="COMP_ROOT_DIR_ROF" value="$SRCROOT">
<entry id="COMP_ROOT_DIR_ROF" value="$SRCROOT/components/mizuRoute/">
<type>char</type>
<desc>Root directory of the case river runoff model component </desc>
<schema>$CIMEROOT/config/xml_schemas/config_compsets.xsd</schema>
<schema>$CIMEROOT/CIME/data/config/xml_schemas/config_compsets.xsd</schema>
</entry>

<entry id="COMP_ROF" value="mizuRoute">
Expand All @@ -34,11 +34,20 @@
<desc>Name of river component</desc>
</entry>

<entry id="SRCROOT" value="$ENV{PWD}/../..">
<entry id="SRCROOT" value="$ENV{PWD}/../../../..">
<type>char</type>
<desc>full pathname of source root directory</desc>
</entry>

<entry id="MACH" value="cheyenne">
<type>char</type>
<desc>Machine name</desc>
</entry>
<entry id="MACHDIR" value="$SRCROOT/ccs_config/machines">
<type>char</type>
<desc>Machines directory location</desc>
</entry>

<entry id="CASE" value="CASENAME">
<type>char</type>
<desc>case name</desc>
Expand Down
2 changes: 1 addition & 1 deletion cime_config/test/env_run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Sample env_run.xml file that allows buildnml to be run for testing in this direc
-->
<group>
<entry id="DIN_LOC_ROOT" value="MYDINLOCROOT" />
<entry id="DIN_LOC_ROOT" value="/MYDINLOCROOT" />

<entry id="CASESTR" value="test">
</entry>
Expand Down
9 changes: 7 additions & 2 deletions cime_config/test/runbuildnml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#!/bin/bash
cd ../../cime >& /dev/null
# Run the buildnmal for mizuRoute, assing it's under a CTSM or CESM checkout
cd ../../../../cime >& /dev/null
if [ $? != 0 ]; then
cd ../../../../cime
echo "cime directory does not exist where expected"
exit -1
fi
export CIMEROOT=`pwd`
echo "CIMEROOT = $CIMEROOT"

cd -
cp ../user_nl_* .
Expand All @@ -22,6 +25,8 @@ if [ $? != 0 ] ; then
else
echo "Cat the results...."
cat Buildconf/mizurouteconf/mizuRoute*
echo "input_data_list..."
cat Buildconf/mizuroute.input_data_list
fi
rm -rf user_* run/* Buildconf/mizurouteconf/* Buildconf/* CaseDocs
echo "Successfully ran test"
34 changes: 31 additions & 3 deletions cime_config/testdefs/ExpectedTestFails.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,42 @@
<issue>#390</issue>
</phase>
</test>
<test name="ERI.nldas2_nldas2_rHDMA_mnldas2.I2000Clm50SpMizGs.cheyenne_intel.mizuroute-default">
<test name="ERS_D_Mmpi-serial.5x5_amazon_r05.I2000Clm50SpMizGs.izumi_nag.mizuroute-default"
<phase name="COMPARE_base_rest">
<status>FAIL</status>
<issue>#390</issue>
</phase>
</test>
<test name="ERI_Mmpi-serial.5x5_amazon_r05.I2000Clm50SpMizGs.cheyenne_intel.mizuroute-default">
<phase name="COMPARE_base_rest">
<status>FAIL</status>
<issue>#390</issue>
</phase>
<phase name="COMPARE_base_hybrid">
<status>FAIL</status>
<issue>#390</issue>
</phase>
</test>
<test name="ERI_Mmpi-serial.5x5_amazon_r05.I2000Clm50SpMizGs.izumi_gnu.mizuroute-default">
<phase name="COMPARE_base_rest">
<status>FAIL</status>
<issue>#390</issue>
</phase>
<phase name="COMPARE_base_hybrid">
<status>FAIL</status>
<issue>#388</issue>
<issue>#390</issue>
</phase>
</test>
<test name="ERS_D_Mmpi-serial_P1x25.5x5_amazon_r05.I2000Clm50SpMizGs.cheyenne_intel.mizuroute-default">
<phase name="COMPARE_base_rest">
<status>FAIL</status>
<issue>#388</issue>
<issue>#390</issue>
</phase>
</test>
<test name="ERP_D_Mmpi-serial_P1x25.5x5_amazon_r05.I2000Clm50SpMizGs.cheyenne_intel.mizuroute-default">
<phase name="COMPARE_base_rest">
<status>FAIL</status>
<issue>#390</issue>
</phase>
</test>

Expand Down
Loading

0 comments on commit 55da196

Please sign in to comment.