diff --git a/config/cesm/config_files.xml b/config/cesm/config_files.xml index 9051e4ffb2f..8c60fed3530 100644 --- a/config/cesm/config_files.xml +++ b/config/cesm/config_files.xml @@ -88,10 +88,10 @@ char - $SRCROOT/components/cam/ $CIMEROOT/src/components/data_comps/datm $CIMEROOT/src/components/stub_comps/satm $CIMEROOT/src/components/xcpl_comps/xatm + $SRCROOT/components/cam/ case_comps env_case.xml @@ -103,7 +103,7 @@ char $CIMEROOT/src/drivers/mct - $CIMEROOT/src/drivers/mct + $CIMEROOT/src/drivers/mct case_comps env_case.xml @@ -255,7 +255,7 @@ char $CIMEROOT/config/cesm/config_archive.xml - $COMP_ROOT_DIR_CPL/cime_config/config_archive.xml + $COMP_ROOT_DIR_CPL/cime_config/config_archive.xml $COMP_ROOT_DIR_ROF/cime_config/config_archive.xml $COMP_ROOT_DIR_ATM/cime_config/config_archive.xml @@ -356,8 +356,6 @@ char unset - $COMP_ROOT_DIR_CPL/cime_config/namelist_definition_modelio.xml - $COMP_ROOT_DIR_CPL/cime_config/namelist_definition_drv_flds.xml $COMP_ROOT_DIR_CPL/cime_config/namelist_definition_drv.xml $CIMEROOT/src/components/data_comps/drof/cime_config/namelist_definition_drof.xml diff --git a/scripts/lib/CIME/XML/archive.py b/scripts/lib/CIME/XML/archive.py index e7e6ba8353b..516bf9f257a 100644 --- a/scripts/lib/CIME/XML/archive.py +++ b/scripts/lib/CIME/XML/archive.py @@ -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') @@ -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) - diff --git a/scripts/lib/CIME/XML/entry_id.py b/scripts/lib/CIME/XML/entry_id.py index 8928a52add5..d488a5b2905 100644 --- a/scripts/lib/CIME/XML/entry_id.py +++ b/scripts/lib/CIME/XML/entry_id.py @@ -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 exist two nodes with the same id delete the first one. + 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]) + def __iter__(self): for node in self.get_nodes("entry"): vid = node.get("id") diff --git a/scripts/lib/CIME/XML/files.py b/scripts/lib/CIME/XML/files.py index f6aef704c92..7da9078b966 100644 --- a/scripts/lib/CIME/XML/files.py +++ b/scripts/lib/CIME/XML/files.py @@ -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 @@ -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}) diff --git a/scripts/lib/CIME/case_st_archive.py b/scripts/lib/CIME/case_st_archive.py index ea8931a88a6..078b89e5ec9 100644 --- a/scripts/lib/CIME/case_st_archive.py +++ b/scripts/lib/CIME/case_st_archive.py @@ -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: @@ -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 + if compname == 'drv': + compname = 'cpl' # determine ninst and ninst_string ninst, ninst_string = _get_ninst_info(case, compclass) @@ -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): @@ -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) diff --git a/src/drivers/mct/cime_config/buildnml b/src/drivers/mct/cime_config/buildnml index 970efa691c0..cd38fcf0626 100755 --- a/src/drivers/mct/cime_config/buildnml +++ b/src/drivers/mct/cime_config/buildnml @@ -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) @@ -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") diff --git a/src/drivers/mct/cime_config/config_archive.xml b/src/drivers/mct/cime_config/config_archive.xml index e2aaeb96db7..7efe6a0c511 100644 --- a/src/drivers/mct/cime_config/config_archive.xml +++ b/src/drivers/mct/cime_config/config_archive.xml @@ -1,5 +1,5 @@ - + \.r\..* \.h.*.nc$ unset