Repository: ESMCI/cime

Issue:
env_batch.py does not pick up queue-specific directives and only uses ones from default queue
Was trying to port CESM2.1.5 on one of the sigma2 machines (with slurm scheduler), which have `nodemin>4` for the normal queue. The different queues on this  machines are handled by `--qos` and `--partition` directives (some partitions have more than one `--qos`). Similar to `archer2` config:
```
  <batch_system MACH="archer2" type="slurm" >
    <batch_submit>sbatch</batch_submit>
    <submit_args>
      <arg flag="--time" name="$JOB_WALLCLOCK_TIME"/>
      <arg flag="-q" name="$JOB_QUEUE"/>
      <arg flag="--account" name="$PROJECT"/>
      <arg flag="--export=ALL"/>
    </submit_args>

    <directives queue="standard">
      <directive>--partition=standard</directive>
      <directive>--qos=standard</directive>
      <directive>--cpus-per-task={{ thread_count }}</directive>
    </directives>

    <directives queue="short">
      <directive>--partition=standard</directive>
      <directive>--qos=short</directive>
      <directive>--cpus-per-task={{ thread_count }}</directive>
    </directives>

    <directives queue="serial">
      <directive>--partition=serial</directive>
      <directive>--qos=serial</directive>
    </directives>

    <!-- following will need updating as system develops -->
    <queues>
      <queue walltimemax="24:00:00" nodemin="1" nodemax="1024" default="true">standard</queue>
      <!-- <queue walltimemin="24:00:00" walltimemax="48:00:00" nodemin="1" nodemax="64" >long</queue> -->
      <queue walltimemax="00:20:00" nodemin="1" nodemax="32">short</queue>
      <queue walltimemax="24:00:00" nodemin="1" nodemax="1">serial</queue>
    </queues>
  </batch_system>
  ```
`master` set the directives correctly. However  `maint-5.6` does not. Even though it assigns a correct queue in `select_best_queue`
(JOB_QUEUE gets set correctly).


Discussion:
Found a fix.
https://github.com/ESMCI/cime/blob/a488510bc24b981809b3dda5ee7b9809a7fc9616/scripts/lib/CIME/XML/env_batch.py#L331
Changing `self` to `case` here, same way it is done in `maint-5.8` actually gets the proper `$JOB_QUEUE` value and not `None`.

Resolving patch:
diff --git a/scripts/lib/CIME/XML/env_batch.py b/scripts/lib/CIME/XML/env_batch.py
--- a/scripts/lib/CIME/XML/env_batch.py
+++ b/scripts/lib/CIME/XML/env_batch.py
@@ -328,7 +328,8 @@ def get_batch_directives(self, case, job, overrides=None, output_format='default
         directive_prefix = None
 
         roots = self.get_children("batch_system")
-        queue = self.get_value("JOB_QUEUE", subgroup=job)
+        # This must go through the case object
+        queue = case.get_value("JOB_QUEUE", subgroup=job)
         if self._batchtype != "none" and not queue in self._get_all_queue_names():
             unknown_queue = True
             qnode = self.get_default_queue()
diff --git a/scripts/lib/CIME/XML/machines.py b/scripts/lib/CIME/XML/machines.py
--- a/scripts/lib/CIME/XML/machines.py
+++ b/scripts/lib/CIME/XML/machines.py
@@ -252,7 +252,7 @@ def is_valid_compiler(self,compiler):
         """
         Check the compiler is valid for the current machine
 
-        >>> machobj = Machines(machine="cori-haswell")
+        >>> machobj = Machines(machine="derecho")
         >>> machobj.get_default_compiler()
         'intel'
         >>> machobj.is_valid_compiler("gnu")
@@ -266,7 +266,7 @@ def is_valid_MPIlib(self, mpilib, attributes=None):
         """
         Check the MPILIB is valid for the current machine
 
-        >>> machobj = Machines(machine="cori-haswell")
+        >>> machobj = Machines(machine="derecho")
         >>> machobj.is_valid_MPIlib("mpi-serial")
         True
         >>> machobj.is_valid_MPIlib("fake-mpi")
@@ -279,7 +279,7 @@ def has_batch_system(self):
         """
         Return if this machine has a batch system
 
-        >>> machobj = Machines(machine="cori-haswell")
+        >>> machobj = Machines(machine="derecho")
         >>> machobj.has_batch_system()
         True
         >>> machobj.set_machine("melvin")
diff --git a/scripts/lib/CIME/code_checker.py b/scripts/lib/CIME/code_checker.py
--- a/scripts/lib/CIME/code_checker.py
+++ b/scripts/lib/CIME/code_checker.py
@@ -15,7 +15,7 @@
 ###############################################################################
 def _run_pylint(on_file, interactive):
 ###############################################################################
-    pylint = find_executable("pylint")
+    pylint = find_executable("pylint") 
 
     cmd_options = " --disable=I,C,R,logging-not-lazy,wildcard-import,unused-wildcard-import"
     cmd_options += ",fixme,broad-except,bare-except,eval-used,exec-used,global-statement"


Test patch:
diff --git a/scripts/fortran_unit_testing/run_tests.py b/scripts/fortran_unit_testing/run_tests.py
--- a/scripts/fortran_unit_testing/run_tests.py
+++ b/scripts/fortran_unit_testing/run_tests.py
@@ -130,7 +130,7 @@ def parse_command_line(args):
 
     args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser)
     output = Printer(color=args.color)
-
+    
     if args.xml_test_list is None and args.test_spec_dir is None:
         output.print_error(
             "You must specify either --test-spec-dir or --xml-test-list."
diff --git a/scripts/lib/CIME/SystemTests/system_tests_common.py b/scripts/lib/CIME/SystemTests/system_tests_common.py
--- a/scripts/lib/CIME/SystemTests/system_tests_common.py
+++ b/scripts/lib/CIME/SystemTests/system_tests_common.py
@@ -399,6 +399,7 @@ def _compare_baseline(self):
         """
         compare the current test output to a baseline result
         """
+        memlist = None
         with self._test_status:
             # compare baseline
             success, comments = compare_baseline(self._case)
diff --git a/scripts/tests/scripts_regression_tests.py b/scripts/tests/scripts_regression_tests.py
--- a/scripts/tests/scripts_regression_tests.py
+++ b/scripts/tests/scripts_regression_tests.py
@@ -2764,7 +2764,7 @@ def check_for_pylint():
     from distutils.spawn import find_executable
     pylint = find_executable("pylint")
     if pylint is not None:
-        output = run_cmd_no_fail("pylint --version")
+        output = run_cmd_no_fail(pylint+" --version")
         pylintver = re.search(r"pylint\s+(\d+)[.](\d+)[.](\d+)", output)
         major = int(pylintver.group(1))
         minor = int(pylintver.group(2))