From db23ad5c68f118639d63eb529cfb9382f4df41ae Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Wed, 5 Apr 2017 14:14:41 -0600 Subject: [PATCH 1/4] avoid a problem with pio_typename in clone with keepexe --- scripts/lib/CIME/SystemTests/system_tests_compare_two.py | 6 ++++++ scripts/lib/CIME/case.py | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/scripts/lib/CIME/SystemTests/system_tests_compare_two.py b/scripts/lib/CIME/SystemTests/system_tests_compare_two.py index f51543dd79b..3eb1057373c 100644 --- a/scripts/lib/CIME/SystemTests/system_tests_compare_two.py +++ b/scripts/lib/CIME/SystemTests/system_tests_compare_two.py @@ -144,6 +144,12 @@ def build_phase(self, sharedlib_only=False, model_only=False): else: self._activate_case1() self.build_indv(sharedlib_only=sharedlib_only, model_only=model_only) + # pio_typename may be changed during the build if the default is not a + # valid value for this build, update case2 to reflect this change + for comp in self._case1.get_values("COMP_CLASSES"): + comp_pio_typename = "%s_PIO_TYPENAME"%comp + self._case2.set_value(comp_pio_typename, self._case1.get_value(comp_pio_typename)) + # The following is needed when _case_two_setup has a case_setup call # despite sharing the build (e.g., to change NTHRDS) self._case2.set_value("BUILD_COMPLETE",True) diff --git a/scripts/lib/CIME/case.py b/scripts/lib/CIME/case.py index e02963c8205..99c32c57a68 100644 --- a/scripts/lib/CIME/case.py +++ b/scripts/lib/CIME/case.py @@ -1007,6 +1007,10 @@ def create_clone(self, newcase, keepexe=False, mach_dir=None, project=None, cime orig_exeroot = self.get_value("EXEROOT") newcase.set_value("EXEROOT", orig_exeroot) newcase.set_value("BUILD_COMPLETE","TRUE") + orig_bld_complete = self.get_value("BUILD_COMPLETE") + if not orig_bld_complete: + logger.warn("\nWARNING: Creating a clone before building the original case may cause PIO_TYPENAME to be invalid in the clone") + logger.warn("Avoid this message by building case one before you clone.\n") else: newcase.set_value("BUILD_COMPLETE","FALSE") From b7de299d08e5540632f29e0e2a01bc5774c5b2af Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Wed, 5 Apr 2017 15:12:39 -0600 Subject: [PATCH 2/4] update warning --- scripts/lib/CIME/case.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/lib/CIME/case.py b/scripts/lib/CIME/case.py index 99c32c57a68..15be91c6096 100644 --- a/scripts/lib/CIME/case.py +++ b/scripts/lib/CIME/case.py @@ -1009,7 +1009,7 @@ def create_clone(self, newcase, keepexe=False, mach_dir=None, project=None, cime newcase.set_value("BUILD_COMPLETE","TRUE") orig_bld_complete = self.get_value("BUILD_COMPLETE") if not orig_bld_complete: - logger.warn("\nWARNING: Creating a clone before building the original case may cause PIO_TYPENAME to be invalid in the clone") + logger.warn("\nWARNING: Creating a clone with --keepexe before building the original case may cause PIO_TYPENAME to be invalid in the clone") logger.warn("Avoid this message by building case one before you clone.\n") else: newcase.set_value("BUILD_COMPLETE","FALSE") From a6b4e2af0581c478d66133c4bc72e47584b964b0 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Mon, 10 Apr 2017 08:44:38 -0600 Subject: [PATCH 3/4] enforce valid_values for compvars --- scripts/lib/CIME/XML/entry_id.py | 16 ++++++++++------ scripts/lib/CIME/XML/env_base.py | 8 ++++---- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/scripts/lib/CIME/XML/entry_id.py b/scripts/lib/CIME/XML/entry_id.py index 2b040b7edb1..331ed21b0ba 100644 --- a/scripts/lib/CIME/XML/entry_id.py +++ b/scripts/lib/CIME/XML/entry_id.py @@ -198,18 +198,22 @@ def _set_value(self, node, value, vid=None, subgroup=None, ignore_type=False): subgroup is ignored in the general routine and applied in specific methods """ expect(subgroup is None, "Subgroup not supported") + str_value = self.get_valid_value_string(node, value, vid, ignore_type) + node.set("value", str_value) + return value + + def get_valid_value_string(self, node, value,vid=None, ignore_type=False): valid_values = self._get_valid_values(node) if ignore_type: expect(type(value) is str, "Value must be type string if ignore_type is true") str_value = value - else: - type_str = self._get_type_info(node) - str_value = convert_to_string(value, type_str, vid) + return str_value + type_str = self._get_type_info(node) + str_value = convert_to_string(value, type_str, vid) + if valid_values is not None and not str_value.startswith('$'): expect(str_value in valid_values, "Did not find %s in valid values for %s: %s" % (value, vid, valid_values)) - node.set("value", str_value) - - return value + return str_value def set_value(self, vid, value, subgroup=None, ignore_type=False): """ diff --git a/scripts/lib/CIME/XML/env_base.py b/scripts/lib/CIME/XML/env_base.py index 1389e74ca5e..99f3d6d3c70 100644 --- a/scripts/lib/CIME/XML/env_base.py +++ b/scripts/lib/CIME/XML/env_base.py @@ -114,10 +114,10 @@ def _set_value(self, node, value, vid=None, subgroup=None, ignore_type=False, co if iscompvar: attribute = {"component":component} - type_str = self._get_type_info(node) - val = self.set_element_text("value", convert_to_string(value, type_str, vid), attribute, root=node) - return val - val = EntryID._set_value(self, node, value, vid, subgroup, ignore_type) + str_value = self.get_valid_value_string(node, value, vid, ignore_type) + val = self.set_element_text("value", str_value, attribute, root=node) + else: + val = EntryID._set_value(self, node, value, vid, subgroup, ignore_type) return val def get_nodes_by_id(self, varid): From 6ecf62e7efc78aacdb2c4b6f00eb765aa2cc0b1c Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Tue, 11 Apr 2017 14:39:19 -0600 Subject: [PATCH 4/4] update create_clone help message --- scripts/create_clone | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/create_clone b/scripts/create_clone index bcc13a729d4..968848a7a42 100755 --- a/scripts/create_clone +++ b/scripts/create_clone @@ -25,7 +25,7 @@ def parse_command_line(args): "is assumed to be under then current working directory ") parser.add_argument("--keepexe", "-keepexe", action="store_true", - help="Sets EXEROOT to point to original build") + help="Sets EXEROOT to point to original build, it is highly recommended that the original case be built before cloning if using the --keepexe flag") parser.add_argument("--mach-dir", "-mach_dir", help="Specify the locations of the Machines directory, other than the default"