Repository: ESMCI/cime

Issue:
ERI test does not handle hybrid initial case 
If the initial case in an ERI test is a hybrid the test will not run correctly. 


Discussion:
Part of the problem is in config_tests.xml - the REF case settings need to be removed from the ERI test.   However part of the problem is in cam usermods_dir where initial files are being defined.   Since these user mods take precedents over test settngs the ERI test will fail until they are removed.  So we need to have some known failures for the time being in ERI.  

Resolving patch:
diff --git a/scripts/lib/CIME/XML/grids.py b/scripts/lib/CIME/XML/grids.py
--- a/scripts/lib/CIME/XML/grids.py
+++ b/scripts/lib/CIME/XML/grids.py
@@ -243,18 +243,18 @@ def _get_domains(self, component_grids, atmlevregex, lndlevregex):
                     domain_name = ""
                     if grid_attrib is not None and mask_attrib is not None:
                         grid_match = re.search(comp_name.lower(), grid_attrib)
-                        mask_match = None
+                        mask_match = False
                         if mask_name is not None:
-                            mask_match = re.search(mask_name, mask_attrib)
-                        if grid_match is not None and mask_match is not None:
+                            mask_match = mask_name == mask_attrib
+                        if grid_match is not None and mask_match:
                             domain_name = self.text(file_node)
                     elif grid_attrib is not None:
                         grid_match = re.search(comp_name.lower(), grid_attrib)
                         if grid_match is not None:
                             domain_name = self.text(file_node)
                     elif mask_attrib is not None:
-                        mask_match = re.search(mask_name.lower(), mask_attrib)
-                        if mask_match is not None:
+                        mask_match = mask_name == mask_attrib
+                        if mask_match:
                             domain_name = self.text(file_node)
                     if domain_name:
                         domains[file_name] = os.path.basename(domain_name)


Test patch:
diff --git a/scripts/create_test b/scripts/create_test
--- a/scripts/create_test
+++ b/scripts/create_test
@@ -234,6 +234,12 @@ def parse_command_line(args, description):
                         default=default,
                         help="On batch systems, wait for submitted jobs to complete")
 
+    default = get_default_setting(config, "ALLOW_PNL", False, check_main=False)
+
+    parser.add_argument("--allow-pnl", action="store_true",
+                        default=default,
+                        help="Do not pass skip-pnl to case.submit")
+
     parser.add_argument("--wait-check-throughput", action="store_true",
                         help="If waiting, fail if throughput check fails")
 
@@ -430,7 +436,7 @@ def parse_command_line(args, description):
         args.namelists_only, args.project, \
         args.test_id, args.parallel_jobs, args.walltime, \
         args.single_submit, args.proc_pool, args.use_existing, args.save_timing, args.queue, \
-        args.allow_baseline_overwrite, args.output_root, args.wait, args.force_procs, args.force_threads, args.mpilib, args.input_dir, args.pesfile, args.retry, args.mail_user, args.mail_type, args.wait_check_throughput, args.wait_check_memory, args.wait_ignore_namelists, args.wait_ignore_memleak
+        args.allow_baseline_overwrite, args.output_root, args.wait, args.force_procs, args.force_threads, args.mpilib, args.input_dir, args.pesfile, args.retry, args.mail_user, args.mail_type, args.wait_check_throughput, args.wait_check_memory, args.wait_ignore_namelists, args.wait_ignore_memleak, args.allow_pnl
 
 ###############################################################################
 def get_default_setting(config, varname, default_if_not_found, check_main=False):
@@ -538,7 +544,7 @@ def create_test(test_names, test_data, compiler, machine_name, no_run, no_build,
                 baseline_root, clean, baseline_cmp_name, baseline_gen_name, namelists_only, project, test_id, parallel_jobs,
                 walltime, single_submit, proc_pool, use_existing, save_timing, queue, allow_baseline_overwrite, output_root, wait,
                 force_procs, force_threads, mpilib, input_dir, pesfile, mail_user, mail_type,
-                wait_check_throughput, wait_check_memory, wait_ignore_namelists, wait_ignore_memleak):
+                wait_check_throughput, wait_check_memory, wait_ignore_namelists, wait_ignore_memleak, allow_pnl):
 ###############################################################################
     impl = TestScheduler(test_names, test_data=test_data,
                          no_run=no_run, no_build=no_build, no_setup=no_setup, no_batch=no_batch,
@@ -551,7 +557,7 @@ def create_test(test_names, test_data, compiler, machine_name, no_run, no_build,
                          proc_pool=proc_pool, use_existing=use_existing, save_timing=save_timing,
                          queue=queue, allow_baseline_overwrite=allow_baseline_overwrite,
                          output_root=output_root, force_procs=force_procs, force_threads=force_threads,
-                         mpilib=mpilib, input_dir=input_dir, pesfile=pesfile, mail_user=mail_user, mail_type=mail_type)
+                         mpilib=mpilib, input_dir=input_dir, pesfile=pesfile, mail_user=mail_user, mail_type=mail_type, allow_pnl=allow_pnl)
 
     success = impl.run_tests(wait=wait,
                              wait_check_throughput=wait_check_throughput,
@@ -590,7 +596,7 @@ def _main_func(description):
     test_root, baseline_root, clean, baseline_cmp_name, baseline_gen_name, namelists_only, \
     project, test_id, parallel_jobs, walltime, single_submit, proc_pool, use_existing, \
     save_timing, queue, allow_baseline_overwrite, output_root, wait, force_procs, force_threads, mpilib, input_dir, pesfile, \
-    retry, mail_user, mail_type, wait_check_throughput, wait_check_memory, wait_ignore_namelists, wait_ignore_memleak = \
+    retry, mail_user, mail_type, wait_check_throughput, wait_check_memory, wait_ignore_namelists, wait_ignore_memleak, allow_pnl = \
         parse_command_line(sys.argv, description)
 
     success = False
@@ -601,7 +607,7 @@ def _main_func(description):
                               baseline_root, clean, baseline_cmp_name, baseline_gen_name, namelists_only,
                               project, test_id, parallel_jobs, walltime, single_submit, proc_pool, use_existing, save_timing,
                               queue, allow_baseline_overwrite, output_root, wait, force_procs, force_threads, mpilib, input_dir, pesfile,
-                              mail_user, mail_type, wait_check_throughput, wait_check_memory, wait_ignore_namelists, wait_ignore_memleak)
+                              mail_user, mail_type, wait_check_throughput, wait_check_memory, wait_ignore_namelists, wait_ignore_memleak, allow_pnl)
         run_count += 1
 
         # For testing only
diff --git a/scripts/lib/CIME/bless_test_results.py b/scripts/lib/CIME/bless_test_results.py
--- a/scripts/lib/CIME/bless_test_results.py
+++ b/scripts/lib/CIME/bless_test_results.py
@@ -31,9 +31,9 @@ def bless_namelists(test_name, test_dir, report_only, force, baseline_name, base
                 return False, "Could not determine baseline root"
 
         create_test_gen_args = " -g {} ".format(baseline_name if get_model() == "cesm" else " -g -b {} ".format(baseline_name))
-        stat, _, err = run_cmd("{}/create_test {} -n {} --baseline-root {} -o".format(get_scripts_root(), test_name, create_test_gen_args, baseline_root))
+        stat, out, _ = run_cmd("{}/create_test {} -n {} --baseline-root {} -o".format(get_scripts_root(), test_name, create_test_gen_args, baseline_root), combine_output=True)
         if stat != 0:
-            return False, "Namelist regen failed: '{}'".format(err)
+            return False, "Namelist regen failed: '{}'".format(out)
         else:
             return True, None
     else:
diff --git a/scripts/lib/CIME/test_scheduler.py b/scripts/lib/CIME/test_scheduler.py
--- a/scripts/lib/CIME/test_scheduler.py
+++ b/scripts/lib/CIME/test_scheduler.py
@@ -119,7 +119,7 @@ def __init__(self, test_names, test_data=None,
                  use_existing=False, save_timing=False, queue=None,
                  allow_baseline_overwrite=False, output_root=None,
                  force_procs=None, force_threads=None, mpilib=None,
-                 input_dir=None, pesfile=None, mail_user=None, mail_type=None):
+                 input_dir=None, pesfile=None, mail_user=None, mail_type=None, allow_pnl=False):
     ###########################################################################
         self._cime_root       = CIME.utils.get_cime_root()
         self._cime_model      = get_model()
@@ -131,6 +131,7 @@ def __init__(self, test_names, test_data=None,
         self._input_dir       = input_dir
         self._pesfile         = pesfile
         self._allow_baseline_overwrite = allow_baseline_overwrite
+        self._allow_pnl       = allow_pnl
 
         self._mail_user = mail_user
         self._mail_type = mail_type
@@ -661,7 +662,9 @@ def _run_phase(self, test):
     ###########################################################################
         test_dir = self._get_test_dir(test)
 
-        cmd = "./case.submit --skip-preview-namelist"
+        cmd = "./case.submit"
+        if not self._allow_pnl:
+            cmd += " --skip-preview-namelist"
         if self._no_batch:
             cmd += " --no-batch"
         if self._mail_user:
diff --git a/scripts/lib/CIME/wait_for_tests.py b/scripts/lib/CIME/wait_for_tests.py
--- a/scripts/lib/CIME/wait_for_tests.py
+++ b/scripts/lib/CIME/wait_for_tests.py
@@ -138,7 +138,7 @@ def create_cdash_test_xml(results, cdash_build_name, cdash_build_group, utc_time
         measurement_elem = xmlet.SubElement(results_elem, "Measurement")
 
         value_elem = xmlet.SubElement(measurement_elem, "Value")
-        value_elem.text = get_test_output(test_norm_path)
+        value_elem.text = ''.join([item for item in get_test_output(test_norm_path) if ord(item) < 128])
 
     elapsed_time_elem = xmlet.SubElement(testing_elem, "ElapsedMinutes")
     elapsed_time_elem.text = "0" # Skip for now