Skip to content

Commit

Permalink
Merge pull request #9 from ekluzek/fixfillpylint
Browse files Browse the repository at this point in the history
Same changes on mosart fill-value and pylint cleanup on rtm
  • Loading branch information
ekluzek authored Oct 12, 2018
2 parents a1ac6a6 + 81815e9 commit 48e5252
Show file tree
Hide file tree
Showing 6 changed files with 209 additions and 131 deletions.
28 changes: 14 additions & 14 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_rtm():

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.rtm"),
os.path.join(srcroot,"components","rtm","src","riverroute"),
os.path.join(srcroot,"components","rtm","src","cpl")]
paths = [os.path.join(caseroot, "SourceMods", "src.rtm"),
os.path.join(srcroot, "components", "rtm", "src", "riverroute"),
os.path.join(srcroot, "components", "rtm", "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=rtm COMPLIB=%s -f %s" \
Expand All @@ -49,13 +53,9 @@ def _build_rtm():
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_rtm()




56 changes: 31 additions & 25 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_namelist(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,7 +40,7 @@ def _create_namelist(case, confdir, inst_string, infile, nmlgen):
#----------------------------------------------------
config = {}
config['rtm_mode'] = case.get_value("RTM_MODE")
config['rtm_flood_mode'] = case.get_value("RTM_FLOOD_MODE")
config['rtm_flood_mode'] = case.get_value("RTM_FLOOD_MODE")
config['clm_accelerated_spinup'] = case.get_value("CLM_ACCELERATED_SPINUP")
config['rof_grid'] = case.get_value("ROF_GRID")
config['lnd_grid'] = case.get_value("LND_GRID")
Expand All @@ -52,7 +52,7 @@ def _create_namelist(case, confdir, inst_string, infile, nmlgen):
# Check for incompatible options.
#----------------------------------------------------
if config["rof_grid"] == "null" and config["rtm_mode"] != "NULL":
expect (False, "ROF_GRID is null RTM_MODE not NULL")
expect(False, "ROF_GRID is null RTM_MODE not NULL")

#----------------------------------------------------
# Clear out old data.
Expand All @@ -74,10 +74,10 @@ def _create_namelist(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")
run_tod = case.get_value("RUN_REFTOD")
filename = "%s.rtm%s.r.%s-%s.nc" %(run_refcase, inst_string, run_refdate, run_tod)
rundir = case.get_value("RUNDIR")
if not os.path.exists(os.path.join(rundir, filename ) ):
if not os.path.exists(os.path.join(rundir, filename)):
filename = "%s.rtm.r.%s-%s.nc" %(run_refcase, run_refdate, run_tod)

if run_type == "hybrid":
Expand All @@ -90,7 +90,7 @@ def _create_namelist(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 @@ -113,10 +113,10 @@ def _create_namelist(case, confdir, inst_string, infile, nmlgen):

rof_ncpl = case.get_value("ROF_NCPL")
if basedt % rof_ncpl != 0:
expect(False, "rof_ncpl %s doesn't divide evenly into basedt \n"
expect(False, "rof_ncpl %s doesn't divide evenly into basedt %s\n"
%(rof_ncpl, basedt))
else:
rtm_tstep = basedt / rof_ncpl
rtm_tstep = basedt // rof_ncpl
nmlgen.set_value("rtm_tstep", value=rtm_tstep)

#----------------------------------------------------
Expand All @@ -130,26 +130,26 @@ def buildnml(case, caseroot, compname):
###############################################################################
"""Build the namelist """

# Build the component namelist
# Build the component namelist
if compname != "rtm":
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","rtmconf")
confdir = os.path.join(caseroot, "Buildconf", "rtmconf")
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.rtm")
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", "rtm", "cime_config")
Expand All @@ -163,6 +163,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 @@ -175,9 +181,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 @@ -193,20 +199,20 @@ def buildnml(case, caseroot, compname):
create_namelist_infile(case, user_nl_file, infile)
namelist_infile = [infile]

# create namelist
_create_namelist(case, confdir, inst_string, namelist_infile, nmlgen)
# create namelist
_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, 'rof_in')
file_src = os.path.join(confdir, 'rof_in')
file_dest = os.path.join(rundir, 'rof_in')
if inst_string:
file_dest += inst_string
shutil.copy(file_src, file_dest)

for txtfile in glob.glob(os.path.join(confdir, "*txt*")):
shutil.copy(txtfile, rundir)

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

Expand Down
72 changes: 72 additions & 0 deletions docs/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,75 @@
===============================================================
Tag name: release-cesm2.0.01
Originator(s): erik
Date: Oct 10, 2018
One-line Summary: pylint cleanup, and fill value changes for pio2

Changes ported from mosart/#15 to rtm. Run pylint through buildlib/buildnml,
changes for fill value needed for pio2. Also use the floor operator
for a specific integer divide as python3 turns it into reals.

Purpose:

Software Changes since last release: release-cesm2.0.00
* pylint on buildlib/buildnml
* fill value changes needed for pio2 from the mosart changes
* Use floor operator in buildnml for an integer division

Science Changes since last release: release-cesm2.0.00
* None

Changes to User Interface since: release-cesm2.0.00
* None

Pull Requests that document the changes (include PR ids):
#9 -- Same changes on mosart fill-value and pylint cleanup on rtm enhancement

Testing:
rtm 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 version, identical to rtm1_0_66

Purpose:

First RTM version for the CESM2.0 release. This tag is identical to rtm1_0_66

Software Changes since last release: rtm1_0_30

* Add in model_doi_url read in from infodata from coupler.
* RTM own's version of config_archive.xml
* Remove old rof_comp_esmf
* Remove revision_id from output files
* Convert testlist format to version 2, and use new Clm5 compset names.
* Remove yellowstone tests.
* Update config_component.xml to version 3 format.
* if NINST_RTM > 1, will check if REFCASE has instance name and use it, otherwise without it.
* I/O fixes from Jim Edwards
* Update buildnamelist to cime5 python namelist infrastructure
* Add time period frequency to output history file
* Remove ESMF top level coupler interface and tests
* Have RTM react to CLM_ACCELERATED_SPINUP setting from CLM and turn itself off
* Update to newer cime versions
* Move tests from goldbach to hobart
* Don't assume that direction files are global
* NAG6.0 requires additional pointers to be nullified
* readnamelist on mastertask only
* PIO2 Compatibility changes
* address valgrind errors
* add SHR_ASSERT macros
* migration of cpl_share/, cpl_esmf/ and cpl_mct code into new cpl/ and introduction of rof_import_export.F90

Science Changes since last release: rtm1_0_30

* Treat irrigation as a seperate flux
* Remove directo to ocean runnoff
* fix fthresh bug and refactor RtmFloodInit
* convert volr coupling field from state to flux
* RTM Master Tag this corresponds to: rtm1_0_66

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

0 comments on commit 48e5252

Please sign in to comment.