Repository: ESMCI/cime

Issue:
changing env_mach_pes.xml without rerunning case.setup still permits you to run case.submit
This will cause a lot of confusion for users - since it will only result in a run-time failure. case.submit should die if this is the case with a user-friendly error as to what needs to be done.


Discussion:

Resolving patch:
diff --git a/scripts/lib/CIME/XML/entry_id.py b/scripts/lib/CIME/XML/entry_id.py
--- a/scripts/lib/CIME/XML/entry_id.py
+++ b/scripts/lib/CIME/XML/entry_id.py
@@ -366,11 +366,22 @@ def compare_xml(self, other):
         f1nodes = self.get_nodes("entry")
         for node in f1nodes:
             vid = node.get("id")
-            f2val = other.get_value(vid, resolved=False)
-            if f2val is not None:
+            f2match = other.get_optional_node("entry", attributes={"id":vid})
+            if f2match is not None:
                 f1val = self.get_value(vid, resolved=False)
-                if f2val != f1val:
-                    xmldiffs[vid] = [f1val, f2val]
+                if f1val is not None:
+                    f2val = other.get_value(vid, resolved=False)
+                    if f1val != f2val:
+                        xmldiffs[vid] = [f1val, f2val]
+                else:
+                    f1val = ET.tostring(node, method="text")
+                    f2val = ET.tostring(f2match, method="text")
+                    if f2val != f1val:
+                        f1value_nodes = self.get_nodes("value", root=node)
+                        for valnode in f1value_nodes:
+                            f2valnode = other.get_node("value", root=f2match, attributes=valnode.attrib)
+                            if f2valnode.text != valnode.text:
+                                xmldiffs["%s:%s"%(vid,valnode.attrib)] = [valnode.text, f2valnode.text]
 
         return xmldiffs
 
diff --git a/scripts/lib/CIME/check_lockedfiles.py b/scripts/lib/CIME/check_lockedfiles.py
--- a/scripts/lib/CIME/check_lockedfiles.py
+++ b/scripts/lib/CIME/check_lockedfiles.py
@@ -9,6 +9,8 @@
 from CIME.XML.env_batch import EnvBatch
 from CIME.utils import run_cmd_no_fail
 
+logger = logging.getLogger(__name__)
+
 import glob, shutil
 
 LOCKED_DIR = "LockedFiles"
@@ -82,13 +84,15 @@ def check_lockedfiles(caseroot=None):
     If caseroot is not specified, it is set to the current working directory
     """
     caseroot = os.getcwd() if caseroot is None else caseroot
-    lockedfiles = glob.glob(os.path.join(caseroot, "LockedFiles", "[^.]*.xml"))
+    lockedfiles = glob.glob(os.path.join(caseroot, "LockedFiles", "*.xml"))
     for lfile in lockedfiles:
         fpart = os.path.basename(lfile)
+        # ignore files used for tests such as env_mach_pes.ERP1.xml by looking for extra dots in the name
+        if lfile.count('.') > 1:
+            continue
         cfile = os.path.join(caseroot, fpart)
         if os.path.isfile(cfile):
             objname = fpart.split('.')[0]
-            logging.info("Checking file %s"%objname)
             if objname == "env_build":
                 f1obj = EnvBuild(caseroot, cfile)
                 f2obj = EnvBuild(caseroot, lfile)
@@ -104,7 +108,6 @@ def check_lockedfiles(caseroot=None):
             else:
                 logging.warn("Locked XML file '%s' is not current being handled" % fpart)
                 continue
-
             diffs = f1obj.compare_xml(f2obj)
             if diffs:
                 logging.warn("File %s has been modified"%lfile)


Test patch: