Skip to content

Commit 5557d66

Browse files
authored
Merge pull request #15 from ekluzek/xlffill8thpy3fixes
Bring in changes for xlf compiler, pio, and python3 update
2 parents a4e75d4 + 455c4bf commit 5557d66

File tree

7 files changed

+235
-154
lines changed

7 files changed

+235
-154
lines changed

cime_config/buildlib

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#!/usr/bin/env python
2-
3-
import os, shutil, sys, glob
2+
"""
3+
Build the mosart component library
4+
"""
5+
#pylint: disable=unused-wildcard-import, wildcard-import, multiple-imports
6+
#pylint: disable=wrong-import-position, invalid-name, too-many-locals
7+
import os, sys
48

59
CIMEROOT = os.environ.get("CIMEROOT")
610
if CIMEROOT is None:
@@ -22,25 +26,25 @@ def _build_mosart():
2226

2327
with Case(caseroot) as case:
2428
casetools = case.get_value("CASETOOLS")
25-
gmake_j = case.get_value("GMAKE_J")
26-
gmake = case.get_value("GMAKE")
29+
gmake_j = case.get_value("GMAKE_J")
30+
gmake = case.get_value("GMAKE")
2731

2832
# create Filepath file
2933
objroot = case.get_value("OBJROOT")
30-
filepath_file = os.path.join(objroot,"rof","obj","Filepath")
34+
filepath_file = os.path.join(objroot, "rof", "obj", "Filepath")
3135
if not os.path.isfile(filepath_file):
3236
srcroot = case.get_value("SRCROOT")
3337
caseroot = case.get_value("CASEROOT")
34-
paths = [ os.path.join(caseroot,"SourceMods","src.mosart"),
35-
os.path.join(srcroot,"components","mosart","src","riverroute"),
36-
os.path.join(srcroot,"components","mosart","src","cpl")]
38+
paths = [os.path.join(caseroot, "SourceMods", "src.mosart"),
39+
os.path.join(srcroot, "components", "mosart", "src", "riverroute"),
40+
os.path.join(srcroot, "components", "mosart", "src", "cpl")]
3741

3842
with open(filepath_file, "w") as filepath:
3943
filepath.write("\n".join(paths))
4044
filepath.write("\n")
4145

4246
# build the library
43-
complib = os.path.join(libroot,"librof.a")
47+
complib = os.path.join(libroot, "librof.a")
4448
makefile = os.path.join(casetools, "Makefile")
4549

4650
cmd = "%s complib -j %d MODEL=mosart COMPLIB=%s -f %s" \
@@ -49,12 +53,9 @@ def _build_mosart():
4953
rc, out, err = run_cmd(cmd, from_dir=bldroot)
5054
expect(rc == 0, "Command %s failed rc=%d\nout=%s\nerr=%s" % (cmd, rc, out, err))
5155

52-
logger.info("Command %s completed with output %s\nerr %s" ,cmd, out, err)
56+
logger.info("Command %s completed with output %s\nerr %s", cmd, out, err)
5357

5458
###############################################################################
5559

5660
if __name__ == "__main__":
5761
_build_mosart()
58-
59-
60-

cime_config/buildnml

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
# Disable these because this is our standard setup
1010
# pylint: disable=wildcard-import,unused-wildcard-import,wrong-import-position
11-
12-
import os, shutil, sys, glob
11+
# pylint: disable=multiple-imports
12+
import os, shutil, sys
1313

1414
CIMEROOT = os.environ.get("CIMEROOT")
1515
if CIMEROOT is None:
@@ -20,13 +20,13 @@ from standard_script_setup import *
2020
from CIME.case import Case
2121
from CIME.nmlgen import NamelistGenerator
2222
from CIME.utils import expect
23-
from CIME.buildnml import create_namelist_infile
23+
from CIME.buildnml import create_namelist_infile, parse_input
2424

2525
logger = logging.getLogger(__name__)
2626

2727
# pylint: disable=too-many-arguments,too-many-locals,too-many-branches,too-many-statements
2828
####################################################################################
29-
def _create_namelists(case, confdir, inst_string, infile, nmlgen):
29+
def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path):
3030
####################################################################################
3131
"""Write out the namelist for this component.
3232
@@ -40,36 +40,29 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen):
4040
#----------------------------------------------------
4141
config = {}
4242
config['mosart_mode'] = case.get_value("MOSART_MODE")
43-
config['mosart_flood_mode'] = case.get_value("MOSART_FLOOD_MODE")
43+
config['mosart_flood_mode'] = case.get_value("MOSART_FLOOD_MODE")
4444
config['clm_accel'] = case.get_value("CLM_ACCELERATED_SPINUP")
4545
config['rof_grid'] = case.get_value("ROF_GRID")
4646
config['lnd_grid'] = case.get_value("LND_GRID")
4747
config['rof_ncpl'] = case.get_value("ROF_NCPL")
4848
config['simyr'] = case.get_value("MOSART_SIM_YEAR")
4949

50-
logger.debug ("River Transport Model (MOSART) mode is %s " %(config['mosart_mode']))
51-
logger.debug (" MOSART lnd grid is %s " %(config['lnd_grid']))
52-
logger.debug (" MOSART rof grid is %s " %(config['rof_grid']))
50+
logger.debug("River Transport Model (MOSART) mode is %s ", config['mosart_mode'])
51+
logger.debug(" MOSART lnd grid is %s ", config['lnd_grid'])
52+
logger.debug(" MOSART rof grid is %s ", config['rof_grid'])
5353

5454
#----------------------------------------------------
5555
# Check for incompatible options.
5656
#----------------------------------------------------
5757

5858
if config["rof_grid"] == "null" and config["mosart_mode"] != "NULL":
59-
expect (False, "ROF_GRID is null MOSART_MODE not NULL")
60-
61-
#----------------------------------------------------
62-
# Clear out old data.
63-
#----------------------------------------------------
64-
data_list_path = os.path.join(case.get_case_root(), "Buildconf", "mosart.input_data_list")
65-
if os.path.exists(data_list_path):
66-
os.remove(data_list_path)
59+
expect(False, "ROF_GRID is null MOSART_MODE not NULL")
6760

6861
#----------------------------------------------------
6962
# Initialize namelist defaults
7063
#----------------------------------------------------
7164
nmlgen.init_defaults(infile, config)
72-
65+
7366
#----------------------------------------------------
7467
# Set values not obtained in the default settings
7568
#----------------------------------------------------
@@ -78,10 +71,10 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen):
7871
if run_type == 'branch' or run_type == 'hybrid':
7972
run_refcase = case.get_value("RUN_REFCASE")
8073
run_refdate = case.get_value("RUN_REFDATE")
81-
run_tod = case.get_value("RUN_REFTOD")
82-
rundir = case.get_value("RUNDIR")
74+
run_tod = case.get_value("RUN_REFTOD")
75+
rundir = case.get_value("RUNDIR")
8376
filename = "%s.mosart%s.r.%s-%s.nc" %(run_refcase, inst_string, run_refdate, run_tod)
84-
if not os.path.exists(os.path.join(rundir, filename ) ):
77+
if not os.path.exists(os.path.join(rundir, filename)):
8578
filename = "%s.mosart.r.%s-%s.nc" %(run_refcase, run_refdate, run_tod)
8679

8780
if run_type == "hybrid":
@@ -95,7 +88,7 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen):
9588
else:
9689
nmlgen.add_default("finidat_rtm")
9790

98-
ncpl_base_period = case.get_value('NCPL_BASE_PERIOD')
91+
ncpl_base_period = case.get_value('NCPL_BASE_PERIOD')
9992
if ncpl_base_period == 'hour':
10093
basedt = 3600
10194
elif ncpl_base_period == 'day':
@@ -118,7 +111,7 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen):
118111

119112
mosart_ncpl = case.get_value("ROF_NCPL")
120113
if basedt % mosart_ncpl != 0:
121-
expect(False, "mosart_ncpl %s doesn't divide evenly into basedt \n"
114+
expect(False, "mosart_ncpl %s doesn't divide evenly into basedt %s\n"
122115
%(mosart_ncpl, basedt))
123116
else:
124117
coupling_period = basedt / mosart_ncpl
@@ -135,26 +128,26 @@ def buildnml(case, caseroot, compname):
135128
###############################################################################
136129
"""Build the mosart namelist """
137130

138-
# Build the component namelist
131+
# Build the component namelist
139132
if compname != "mosart":
140133
raise AttributeError
141134

142-
srcroot = case.get_value("SRCROOT")
135+
srcroot = case.get_value("SRCROOT")
143136
rundir = case.get_value("RUNDIR")
144137
ninst = case.get_value("NINST_ROF")
145138

146139
# Determine configuration directory
147-
confdir = os.path.join(caseroot,"Buildconf","mosartconf")
140+
confdir = os.path.join(caseroot, "Buildconf", "mosartconf")
148141
if not os.path.isdir(confdir):
149142
os.makedirs(confdir)
150143

151144
#----------------------------------------------------
152-
# Construct the namelist generator
145+
# Construct the namelist generator
153146
#----------------------------------------------------
154147
# Determine directory for user modified namelist_definitions.xml and namelist_defaults.xml
155148
user_xml_dir = os.path.join(caseroot, "SourceMods", "src.mosart")
156-
expect (os.path.isdir(user_xml_dir),
157-
"user_xml_dir %s does not exist " %user_xml_dir)
149+
expect(os.path.isdir(user_xml_dir),
150+
"user_xml_dir %s does not exist "%user_xml_dir)
158151

159152
# NOTE: User definition *replaces* existing definition.
160153
namelist_xml_dir = os.path.join(srcroot, "components", "mosart", "cime_config")
@@ -168,6 +161,12 @@ def buildnml(case, caseroot, compname):
168161
# Create the namelist generator object - independent of instance
169162
nmlgen = NamelistGenerator(case, definition_file)
170163

164+
#----------------------------------------------------
165+
# Clear out old data.
166+
#----------------------------------------------------
167+
data_list_path = os.path.join(case.get_case_root(), "Buildconf", "mosart.input_data_list")
168+
if os.path.exists(data_list_path):
169+
os.remove(data_list_path)
171170
#----------------------------------------------------
172171
# Loop over instances
173172
#----------------------------------------------------
@@ -180,9 +179,9 @@ def buildnml(case, caseroot, compname):
180179

181180
# If multi-instance case does not have restart file, use
182181
# single-case restart for each instance
183-
rpointer = "rpointer.rof"
184-
if (os.path.isfile(os.path.join(rundir,rpointer)) and
185-
(not os.path.isfile(os.path.join(rundir,rpointer + inst_string)))):
182+
rpointer = "rpointer.rof"
183+
if (os.path.isfile(os.path.join(rundir, rpointer)) and
184+
(not os.path.isfile(os.path.join(rundir, rpointer + inst_string)))):
186185
shutil.copy(os.path.join(rundir, rpointer),
187186
os.path.join(rundir, rpointer + inst_string))
188187

@@ -199,16 +198,16 @@ def buildnml(case, caseroot, compname):
199198
namelist_infile = [infile]
200199

201200
# create namelist and stream file(s) data component
202-
_create_namelists(case, confdir, inst_string, namelist_infile, nmlgen)
201+
_create_namelists(case, confdir, inst_string, namelist_infile, nmlgen, data_list_path)
203202

204203
# copy namelist files and stream text files, to rundir
205204
if os.path.isdir(rundir):
206-
file_src = os.path.join(confdir, 'mosart_in')
205+
file_src = os.path.join(confdir, 'mosart_in')
207206
file_dest = os.path.join(rundir, 'mosart_in')
208207
if inst_string:
209208
file_dest += inst_string
210209
shutil.copy(file_src, file_dest)
211-
210+
212211
###############################################################################
213212
def _main_func():
214213

cime_config/namelist_definition_mosart.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@
165165
<input_pathname>abs</input_pathname>
166166
<group>mosart_inparm</group>
167167
<values>
168-
<value rof_grid="r05">$DIN_LOC_ROOT/rof/mosart/MOSART_routing_Global_0.5x0.5_c170601.nc</value>
168+
<value rof_grid="r05" >$DIN_LOC_ROOT/rof/mosart/MOSART_routing_Global_0.5x0.5_c170601.nc</value>
169+
<value rof_grid="r8th">$DIN_LOC_ROOT/rof/mosart/MOSART_Global_8th_20160716a.nc</value>
169170
</values>
170171
<desc>
171172
Full pathname of input datafile for RTM.

docs/ChangeLog

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,92 @@
1+
===============================================================
2+
Tag name: release-cesm2.0.01
3+
Originator(s): erik/jedwards4b
4+
Date: Oct 09, 2018
5+
One-line Summary: New r8th routing file, pylint and py3 checking, fill value needed for pio2
6+
7+
Add in 8th degree routine file. Run pylint and check for py3 compatability.
8+
There's explict setting of fill type. And also explicit use of shr_kind_r4 for
9+
kind rather than real(4), which is a better mechanism. Also ncd_getiodesc
10+
will read in PIO_DOUBLE for input xtype= PIO_DOUBLE or PIO_REAL. Most of this
11+
is direct from jedwards4b (other than r8th addition).
12+
13+
MOSART Master Tag This Corresponds To: Identical to mosart1_0_31
14+
15+
Science changes since: release-cesm2.0.00
16+
Added in 8th degree routing file (r8th)
17+
Software changes since: release-cesm2.0.00
18+
Run pylint on python buildlib and buildnml scripts, check for py3 compatibility.
19+
Corrects the integer fill value. Needed for pio2.
20+
21+
Pull Requests that document the changes (include PR ids):
22+
23+
#15 -- Bring in changes for xlf compiler, pio, and python3 update
24+
(#13 and #6 moved to release-cesm2.0)
25+
#14 -- fix type issue with xlf
26+
27+
Testing:
28+
mosart testlist on hobart and cheyenne (PASS)
29+
30+
===============================================================
31+
Tag name: release-cesm2.0.00
32+
Originator(s): erik
33+
Date: May 21, 2018
34+
One-line Summary: First CESM2.0 release tag, identical to mosart1_0_31
35+
36+
MOSART Master Tag This Corresponds To: Identical to mosart1_0_31
37+
38+
Science changes since: mosart1_0_00
39+
40+
* Changes from Sean Swenson to add minimum value to rlen
41+
* Update areas on routing file
42+
* Answer changing improvements to channel storage from HongYi Li for faster spinup.
43+
* Bugfix from Tony Craig to use correct delta time for qgwl flux.
44+
* Treat irrigation as a seperate flux
45+
* bugfix for budget diagnostic output
46+
* bugfix: calculation of qgwl_volume must be multiplied by ar
47+
* Update default routing file.
48+
* New method of handeling runoff terms to avoid negative runoff.
49+
* switch to input dataset MOSART_Global_half_20151130a.nc
50+
* update direct sparse matrix to include non basin points in order
51+
* to pass data from any grid cell directly to the ocean.
52+
* modify the direct term and push all direct water to outlet points
53+
* set all tracer 2 water (frozen water) to be a direct term
54+
* add ability to skip some tracers in the euler solver via euler_calc flag
55+
* add a budget accumulator term
56+
* Fix exact restart in atan slope calc
57+
* Swenson bugfix for mosart direction file
58+
* Swenson river volume normalization bugf
59+
60+
Software changes since: mosart1_0_00
61+
62+
* Add config_archive for mosart
63+
* delete rof_comp_esmf
64+
* add model_doi_url,
65+
* change some instances of RTM/CLM in documentation to MOSART
66+
* Update testlist to version 2 format, remove ys tests
67+
* Upgrade config_component to version 3
68+
* allow output file format to change
69+
* If NINST_ROF > 1, check if instance number in name for REFCASE
70+
* Update testlist and use Clm5 compset names
71+
* Update routing file
72+
* Update to cime5 python namelist infrastructure
73+
* Fix an issue with nag, lower amount of log output
74+
* Add output frequency to history files
75+
* Turn off for CLM_ACCELERATED_SPINUP="on"
76+
* Add new namelist options bypass_routing_option,
77+
* qgwl_runoff_option
78+
* Error checking on max length of history filenames.
79+
* Add testdefs dir, testmods and testlist for integration to cime
80+
* test system.
81+
* remove rofdto from coupler interface fields.
82+
* Changes to get Mosart to build with Nag on Hobart
83+
* merge ACME fixes to decomp and performance
84+
* cime compatible infrastructure
85+
* Add direct to ocean runoff flux
86+
* PIO2 updates
87+
88+
Changes to User Interface since: mo
89+
190
===============================================================
291
Tag name: mosart1_0_31
392
Originator(s): erik

0 commit comments

Comments
 (0)