Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve compset issue #1981

Merged
merged 6 commits into from
Oct 25, 2017
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions config/cesm/config_files.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@
<entry id="COMP_ROOT_DIR_ATM">
<type>char</type>
<values>
<value component="cam" >$SRCROOT/components/cam/</value>
<value component="datm" >$CIMEROOT/src/components/data_comps/datm</value>
<value component="satm" >$CIMEROOT/src/components/stub_comps/satm</value>
<value component="xatm" >$CIMEROOT/src/components/xcpl_comps/xatm</value>
<value component="cam" >$SRCROOT/components/cam/</value>
</values>
<group>case_comps</group>
<file>env_case.xml</file>
Expand All @@ -103,7 +103,7 @@
<type>char</type>
<values>
<value >$CIMEROOT/src/drivers/mct</value>
<value component="mct">$CIMEROOT/src/drivers/mct</value>
<value component="drv">$CIMEROOT/src/drivers/mct</value>
</values>
<group>case_comps</group>
<file>env_case.xml</file>
Expand Down Expand Up @@ -255,7 +255,7 @@
<type>char</type>
<values>
<value>$CIMEROOT/config/cesm/config_archive.xml</value>
<value component="cpl" >$COMP_ROOT_DIR_CPL/cime_config/config_archive.xml</value>
<value component="drv" >$COMP_ROOT_DIR_CPL/cime_config/config_archive.xml</value>
<!-- data model components -->
<value component="drof">$COMP_ROOT_DIR_ROF/cime_config/config_archive.xml</value>
<value component="datm">$COMP_ROOT_DIR_ATM/cime_config/config_archive.xml</value>
Expand Down Expand Up @@ -356,8 +356,6 @@
<type>char</type>
<default_value>unset</default_value>
<values>
<value component="modelio" >$COMP_ROOT_DIR_CPL/cime_config/namelist_definition_modelio.xml</value>
<value component="drv_flds">$COMP_ROOT_DIR_CPL/cime_config/namelist_definition_drv_flds.xml</value>
<value component="drv" >$COMP_ROOT_DIR_CPL/cime_config/namelist_definition_drv.xml</value>
<!-- data model components -->
<value component="drof">$CIMEROOT/src/components/data_comps/drof/cime_config/namelist_definition_drof.xml</value>
Expand Down
5 changes: 2 additions & 3 deletions scripts/lib/CIME/XML/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ def setup(self, env_archive, components, files=None):


model = get_model()
if 'cpl' not in components:
components.append('cpl')
if 'drv' not in components:
components.append('drv')
if 'dart' not in components and model == 'cesm':
components.append('dart')

Expand All @@ -55,4 +55,3 @@ def setup(self, env_archive, components, files=None):
logger.debug("adding archive spec for {}".format(comp))
components_node.append(specs)
env_archive.add_child(components_node)

10 changes: 10 additions & 0 deletions scripts/lib/CIME/XML/entry_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,16 @@ def compare_xml(self, other):
xmldiffs["{}:{}".format(vid, valnode.attrib)] = [valnode.text, f2valnode.text]
return xmldiffs

def overwrite_existing_entries(self):
# if there
for node in self.get_nodes("entry"):
vid = node.get("id")
samenodes = self.get_nodes_by_id(vid)
if len(samenodes) > 1:
expect(len(samenodes) == 2, "Too many matchs for id {} in file {}".format(vid, self.filename))
logger.debug("Overwriting node {}".format(vid))
self.root.remove(samenodes[0])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it always the case that the new node will be after the original node - this is assumed in that your are removing samenodes[0] - the first node. Also - could you please document what this routine is doing in terms of the new functionality we are building in (you are taking the entry from the .config_files in $SRCROOT and overwriting the entry here with that one).


def __iter__(self):
for node in self.get_nodes("entry"):
vid = node.get("id")
Expand Down
18 changes: 18 additions & 0 deletions scripts/lib/CIME/XML/files.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Interface to the config_files.xml file. This class inherits from EntryID.py
"""
import re
from CIME.XML.standard_module_setup import *

from CIME.XML.entry_id import EntryID
Expand All @@ -23,6 +24,23 @@ def __init__(self):
expect(os.path.isfile(infile), "Could not find or open file {}".format(infile))
schema = os.path.join(cimeroot, "config", "xml_schemas", "entry_id.xsd")
EntryID.__init__(self, infile, schema=schema)
config_files_override = os.path.join(os.path.dirname(cimeroot),".config_files.xml")
# .config_file.xml at the top level may overwrite COMP_ROOT_DIR_ nodes in config_files
if os.path.isfile(config_files_override):
self.read(config_files_override)
self.overwrite_existing_entries()

def get_value(self, vid, attribute=None, resolved=True, subgroup=None):
value = super(Files, self).get_value(vid, attribute=attribute, resolved=False, subgroup=subgroup)
if "COMP_ROOT_DIR" not in vid and value is not None and resolved and "COMP_ROOT_DIR" in value:
m = re.search("(COMP_ROOT_DIR_[^/]+)/", value)
comp_root_dir_var_name = m.group(1)
comp_root_dir = self.get_value(comp_root_dir_var_name, attribute=attribute, resolved=False, subgroup=subgroup)
self.set_value(comp_root_dir_var_name, comp_root_dir)
if resolved and value is not None:
value = self.get_resolved_value(value)

return value

def get_schema(self, nodename, attributes=None):
node = self.get_optional_node("entry", {"id":nodename})
Expand Down
11 changes: 9 additions & 2 deletions scripts/lib/CIME/case_st_archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def _get_component_archive_entries(case, archive):
case's compset components.
"""
compset_comps = case.get_compset_components()
compset_comps.append('cpl')
compset_comps.append('drv')
compset_comps.append('dart')

for compname in compset_comps:
Expand Down Expand Up @@ -180,6 +180,9 @@ def _archive_history_files(case, archive, archive_entry,
if not os.path.exists(archive_histdir):
os.makedirs(archive_histdir)
logger.debug("created directory {}".format(archive_histdir))
# the compname is drv but the files are named cpl
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please give an example of what files are named cpl currently so that we can have this documented.

if compname == 'drv':
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment as to why you are doing this.

compname = 'cpl'

# determine ninst and ninst_string
ninst, ninst_string = _get_ninst_info(case, compclass)
Expand Down Expand Up @@ -319,6 +322,10 @@ def _archive_restarts_date_comp(case, archive, archive_entry,
last_restart_file_fn = shutil.copy
last_restart_file_fn_msg = "copying"

# the compname is drv but the files are named cpl
if compname == 'drv':
compname = 'cpl'

# get file_extension suffixes
for suffix in archive.get_rest_file_extensions(archive_entry):
for i in range(ninst):
Expand All @@ -337,7 +344,7 @@ def _archive_restarts_date_comp(case, archive, archive_entry,
pattern = suffix + datename
pfile = re.compile(pattern)
restfiles = [f for f in files if pfile.search(f)]

logger.debug("Pattern is {} restfiles {}".format(pattern, restfiles))
for restfile in restfiles:
restfile = os.path.basename(restfile)

Expand Down
6 changes: 4 additions & 2 deletions src/drivers/mct/cime_config/buildnml
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@ def write_drv_flds_in_file(case, nmlgen, files):

# Now create drv_flds_in
config = {}
definition_file = [files.get_value("NAMELIST_DEFINITION_FILE", attribute={"component":"drv_flds"})]
definition_dir = os.path.dirname(files.get_value("NAMELIST_DEFINITION_FILE", attribute={"component":"drv"}))
definition_file = [os.path.join(definition_dir, "namelist_definition_drv_flds.xml")]
nmlgen = NamelistGenerator(case, definition_file, files=files)
skip_entry_loop = True
nmlgen.init_defaults(infiles, config, skip_entry_loop=skip_entry_loop)
Expand All @@ -296,7 +297,8 @@ def _create_component_modelio_namelists(case, files):

# will need to create a new namelist generator
infiles = []
definition_file = [files.get_value("NAMELIST_DEFINITION_FILE", attribute={"component":"modelio"})]
definition_dir = os.path.dirname(files.get_value("NAMELIST_DEFINITION_FILE", attribute={"component":"drv"}))
definition_file = [os.path.join(definition_dir, "namelist_definition_modelio.xml")]

confdir = os.path.join(case.get_value("CASEBUILD"), "cplconf")
lid = os.environ["LID"] if "LID" in os.environ else get_timestamp("%y%m%d-%H%M%S")
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/mct/cime_config/config_archive.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<components version="2.0">
<comp_archive_spec compname="cpl" compclass="cpl">
<comp_archive_spec compname="drv" compclass="cpl">
<rest_file_extension>\.r\..*</rest_file_extension>
<hist_file_extension>\.h.*.nc$</hist_file_extension>
<rest_history_varname>unset</rest_history_varname>
Expand Down