Skip to content

Commit

Permalink
Merge pull request #15 from ekluzek/xlffill8thpy3fixes
Browse files Browse the repository at this point in the history
Bring in changes for xlf compiler, pio, and python3 update
  • Loading branch information
ekluzek authored Oct 9, 2018
2 parents a4e75d4 + 455c4bf commit 5557d66
Show file tree
Hide file tree
Showing 7 changed files with 235 additions and 154 deletions.
27 changes: 14 additions & 13 deletions cime_config/buildlib
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/usr/bin/env python

import os, shutil, sys, glob
"""
Build the mosart component library
"""
#pylint: disable=unused-wildcard-import, wildcard-import, multiple-imports
#pylint: disable=wrong-import-position, invalid-name, too-many-locals
import os, sys

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

with Case(caseroot) as case:
casetools = case.get_value("CASETOOLS")
gmake_j = case.get_value("GMAKE_J")
gmake = case.get_value("GMAKE")
gmake_j = case.get_value("GMAKE_J")
gmake = case.get_value("GMAKE")

# create Filepath file
objroot = case.get_value("OBJROOT")
filepath_file = os.path.join(objroot,"rof","obj","Filepath")
filepath_file = os.path.join(objroot, "rof", "obj", "Filepath")
if not os.path.isfile(filepath_file):
srcroot = case.get_value("SRCROOT")
caseroot = case.get_value("CASEROOT")
paths = [ os.path.join(caseroot,"SourceMods","src.mosart"),
os.path.join(srcroot,"components","mosart","src","riverroute"),
os.path.join(srcroot,"components","mosart","src","cpl")]
paths = [os.path.join(caseroot, "SourceMods", "src.mosart"),
os.path.join(srcroot, "components", "mosart", "src", "riverroute"),
os.path.join(srcroot, "components", "mosart", "src", "cpl")]

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

# build the library
complib = os.path.join(libroot,"librof.a")
complib = os.path.join(libroot, "librof.a")
makefile = os.path.join(casetools, "Makefile")

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

logger.info("Command %s completed with output %s\nerr %s" ,cmd, out, err)
logger.info("Command %s completed with output %s\nerr %s", cmd, out, err)

###############################################################################

if __name__ == "__main__":
_build_mosart()



67 changes: 33 additions & 34 deletions cime_config/buildnml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

# Disable these because this is our standard setup
# pylint: disable=wildcard-import,unused-wildcard-import,wrong-import-position

import os, shutil, sys, glob
# pylint: disable=multiple-imports
import os, shutil, sys

CIMEROOT = os.environ.get("CIMEROOT")
if CIMEROOT is None:
Expand All @@ -20,13 +20,13 @@ from standard_script_setup import *
from CIME.case import Case
from CIME.nmlgen import NamelistGenerator
from CIME.utils import expect
from CIME.buildnml import create_namelist_infile
from CIME.buildnml import create_namelist_infile, parse_input

logger = logging.getLogger(__name__)

# pylint: disable=too-many-arguments,too-many-locals,too-many-branches,too-many-statements
####################################################################################
def _create_namelists(case, confdir, inst_string, infile, nmlgen):
def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path):
####################################################################################
"""Write out the namelist for this component.
Expand All @@ -40,36 +40,29 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen):
#----------------------------------------------------
config = {}
config['mosart_mode'] = case.get_value("MOSART_MODE")
config['mosart_flood_mode'] = case.get_value("MOSART_FLOOD_MODE")
config['mosart_flood_mode'] = case.get_value("MOSART_FLOOD_MODE")
config['clm_accel'] = case.get_value("CLM_ACCELERATED_SPINUP")
config['rof_grid'] = case.get_value("ROF_GRID")
config['lnd_grid'] = case.get_value("LND_GRID")
config['rof_ncpl'] = case.get_value("ROF_NCPL")
config['simyr'] = case.get_value("MOSART_SIM_YEAR")

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

#----------------------------------------------------
# Check for incompatible options.
#----------------------------------------------------

if config["rof_grid"] == "null" and config["mosart_mode"] != "NULL":
expect (False, "ROF_GRID is null MOSART_MODE not NULL")

#----------------------------------------------------
# Clear out old data.
#----------------------------------------------------
data_list_path = os.path.join(case.get_case_root(), "Buildconf", "mosart.input_data_list")
if os.path.exists(data_list_path):
os.remove(data_list_path)
expect(False, "ROF_GRID is null MOSART_MODE not NULL")

#----------------------------------------------------
# Initialize namelist defaults
#----------------------------------------------------
nmlgen.init_defaults(infile, config)

#----------------------------------------------------
# Set values not obtained in the default settings
#----------------------------------------------------
Expand All @@ -78,10 +71,10 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen):
if run_type == 'branch' or run_type == 'hybrid':
run_refcase = case.get_value("RUN_REFCASE")
run_refdate = case.get_value("RUN_REFDATE")
run_tod = case.get_value("RUN_REFTOD")
rundir = case.get_value("RUNDIR")
run_tod = case.get_value("RUN_REFTOD")
rundir = case.get_value("RUNDIR")
filename = "%s.mosart%s.r.%s-%s.nc" %(run_refcase, inst_string, run_refdate, run_tod)
if not os.path.exists(os.path.join(rundir, filename ) ):
if not os.path.exists(os.path.join(rundir, filename)):
filename = "%s.mosart.r.%s-%s.nc" %(run_refcase, run_refdate, run_tod)

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

ncpl_base_period = case.get_value('NCPL_BASE_PERIOD')
ncpl_base_period = case.get_value('NCPL_BASE_PERIOD')
if ncpl_base_period == 'hour':
basedt = 3600
elif ncpl_base_period == 'day':
Expand All @@ -118,7 +111,7 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen):

mosart_ncpl = case.get_value("ROF_NCPL")
if basedt % mosart_ncpl != 0:
expect(False, "mosart_ncpl %s doesn't divide evenly into basedt \n"
expect(False, "mosart_ncpl %s doesn't divide evenly into basedt %s\n"
%(mosart_ncpl, basedt))
else:
coupling_period = basedt / mosart_ncpl
Expand All @@ -135,26 +128,26 @@ def buildnml(case, caseroot, compname):
###############################################################################
"""Build the mosart namelist """

# Build the component namelist
# Build the component namelist
if compname != "mosart":
raise AttributeError

srcroot = case.get_value("SRCROOT")
srcroot = case.get_value("SRCROOT")
rundir = case.get_value("RUNDIR")
ninst = case.get_value("NINST_ROF")

# Determine configuration directory
confdir = os.path.join(caseroot,"Buildconf","mosartconf")
confdir = os.path.join(caseroot, "Buildconf", "mosartconf")
if not os.path.isdir(confdir):
os.makedirs(confdir)

#----------------------------------------------------
# Construct the namelist generator
# Construct the namelist generator
#----------------------------------------------------
# Determine directory for user modified namelist_definitions.xml and namelist_defaults.xml
user_xml_dir = os.path.join(caseroot, "SourceMods", "src.mosart")
expect (os.path.isdir(user_xml_dir),
"user_xml_dir %s does not exist " %user_xml_dir)
expect(os.path.isdir(user_xml_dir),
"user_xml_dir %s does not exist "%user_xml_dir)

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

#----------------------------------------------------
# Clear out old data.
#----------------------------------------------------
data_list_path = os.path.join(case.get_case_root(), "Buildconf", "mosart.input_data_list")
if os.path.exists(data_list_path):
os.remove(data_list_path)
#----------------------------------------------------
# Loop over instances
#----------------------------------------------------
Expand All @@ -180,9 +179,9 @@ def buildnml(case, caseroot, compname):

# If multi-instance case does not have restart file, use
# single-case restart for each instance
rpointer = "rpointer.rof"
if (os.path.isfile(os.path.join(rundir,rpointer)) and
(not os.path.isfile(os.path.join(rundir,rpointer + inst_string)))):
rpointer = "rpointer.rof"
if (os.path.isfile(os.path.join(rundir, rpointer)) and
(not os.path.isfile(os.path.join(rundir, rpointer + inst_string)))):
shutil.copy(os.path.join(rundir, rpointer),
os.path.join(rundir, rpointer + inst_string))

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

# create namelist and stream file(s) data component
_create_namelists(case, confdir, inst_string, namelist_infile, nmlgen)
_create_namelists(case, confdir, inst_string, namelist_infile, nmlgen, data_list_path)

# copy namelist files and stream text files, to rundir
if os.path.isdir(rundir):
file_src = os.path.join(confdir, 'mosart_in')
file_src = os.path.join(confdir, 'mosart_in')
file_dest = os.path.join(rundir, 'mosart_in')
if inst_string:
file_dest += inst_string
shutil.copy(file_src, file_dest)

###############################################################################
def _main_func():

Expand Down
3 changes: 2 additions & 1 deletion cime_config/namelist_definition_mosart.xml
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@
<input_pathname>abs</input_pathname>
<group>mosart_inparm</group>
<values>
<value rof_grid="r05">$DIN_LOC_ROOT/rof/mosart/MOSART_routing_Global_0.5x0.5_c170601.nc</value>
<value rof_grid="r05" >$DIN_LOC_ROOT/rof/mosart/MOSART_routing_Global_0.5x0.5_c170601.nc</value>
<value rof_grid="r8th">$DIN_LOC_ROOT/rof/mosart/MOSART_Global_8th_20160716a.nc</value>
</values>
<desc>
Full pathname of input datafile for RTM.
Expand Down
89 changes: 89 additions & 0 deletions docs/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,92 @@
===============================================================
Tag name: release-cesm2.0.01
Originator(s): erik/jedwards4b
Date: Oct 09, 2018
One-line Summary: New r8th routing file, pylint and py3 checking, fill value needed for pio2

Add in 8th degree routine file. Run pylint and check for py3 compatability.
There's explict setting of fill type. And also explicit use of shr_kind_r4 for
kind rather than real(4), which is a better mechanism. Also ncd_getiodesc
will read in PIO_DOUBLE for input xtype= PIO_DOUBLE or PIO_REAL. Most of this
is direct from jedwards4b (other than r8th addition).

MOSART Master Tag This Corresponds To: Identical to mosart1_0_31

Science changes since: release-cesm2.0.00
Added in 8th degree routing file (r8th)
Software changes since: release-cesm2.0.00
Run pylint on python buildlib and buildnml scripts, check for py3 compatibility.
Corrects the integer fill value. Needed for pio2.

Pull Requests that document the changes (include PR ids):

#15 -- Bring in changes for xlf compiler, pio, and python3 update
(#13 and #6 moved to release-cesm2.0)
#14 -- fix type issue with xlf

Testing:
mosart testlist on hobart and cheyenne (PASS)

===============================================================
Tag name: release-cesm2.0.00
Originator(s): erik
Date: May 21, 2018
One-line Summary: First CESM2.0 release tag, identical to mosart1_0_31

MOSART Master Tag This Corresponds To: Identical to mosart1_0_31

Science changes since: mosart1_0_00

* Changes from Sean Swenson to add minimum value to rlen
* Update areas on routing file
* Answer changing improvements to channel storage from HongYi Li for faster spinup.
* Bugfix from Tony Craig to use correct delta time for qgwl flux.
* Treat irrigation as a seperate flux
* bugfix for budget diagnostic output
* bugfix: calculation of qgwl_volume must be multiplied by ar
* Update default routing file.
* New method of handeling runoff terms to avoid negative runoff.
* switch to input dataset MOSART_Global_half_20151130a.nc
* update direct sparse matrix to include non basin points in order
* to pass data from any grid cell directly to the ocean.
* modify the direct term and push all direct water to outlet points
* set all tracer 2 water (frozen water) to be a direct term
* add ability to skip some tracers in the euler solver via euler_calc flag
* add a budget accumulator term
* Fix exact restart in atan slope calc
* Swenson bugfix for mosart direction file
* Swenson river volume normalization bugf

Software changes since: mosart1_0_00

* Add config_archive for mosart
* delete rof_comp_esmf
* add model_doi_url,
* change some instances of RTM/CLM in documentation to MOSART
* Update testlist to version 2 format, remove ys tests
* Upgrade config_component to version 3
* allow output file format to change
* If NINST_ROF > 1, check if instance number in name for REFCASE
* Update testlist and use Clm5 compset names
* Update routing file
* Update to cime5 python namelist infrastructure
* Fix an issue with nag, lower amount of log output
* Add output frequency to history files
* Turn off for CLM_ACCELERATED_SPINUP="on"
* Add new namelist options bypass_routing_option,
* qgwl_runoff_option
* Error checking on max length of history filenames.
* Add testdefs dir, testmods and testlist for integration to cime
* test system.
* remove rofdto from coupler interface fields.
* Changes to get Mosart to build with Nag on Hobart
* merge ACME fixes to decomp and performance
* cime compatible infrastructure
* Add direct to ocean runoff flux
* PIO2 updates

Changes to User Interface since: mo

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

0 comments on commit 5557d66

Please sign in to comment.