Repository: ESMCI/cime

Issue:
queue option without walltime option causes error 
Apparently if you use the --queue argument to create_test or create_newcase and don't use
the --walltime option then the walltime is not resolved. 



Discussion:
I've verified that this is not a problem in maint-cime5.1


Resolving patch:
diff --git a/utils/python/CIME/XML/env_batch.py b/utils/python/CIME/XML/env_batch.py
--- a/utils/python/CIME/XML/env_batch.py
+++ b/utils/python/CIME/XML/env_batch.py
@@ -25,14 +25,19 @@ def __init__(self, case_root=None, infile="env_batch.xml"):
         EnvBase.__init__(self, case_root, infile)
         self.prereq_jobid = None
         self.batchtype = None
+        # This arbitrary setting should always be overwritten
+        self._default_walltime = "00:20:00"
 
     def set_value(self, item, value, subgroup=None, ignore_type=False):
+        """
+        Override the entry_id set_value function with some special cases for this class
+        """
         val = None
         if item == "JOB_WALLCLOCK_TIME":
-            # Most systems use %H:%M:%S format for wallclock but LSF
-            # uses %H:%M this code corrects the value passed in to be
-            # the correct format - if we find we have more exceptions
-            # than this we may need to generalize this further
+            #Most systems use %H:%M:%S format for wallclock but LSF
+            #uses %H:%M this code corrects the value passed in to be
+            #the correct format - if we find we have more exceptions
+            #than this we may need to generalize this further
             walltime_format = self.get_value("walltime_format", subgroup=None)
             if walltime_format is not None and walltime_format.count(":") != value.count(":"): # pylint: disable=maybe-no-member
                 if value.count(":") == 1:
@@ -268,7 +273,11 @@ def set_job_defaults(self, bjobs, pesize=None, walltime=None, force_queue=None):
             walltime = self.get_max_walltime(queue) if walltime is None else walltime
             if walltime is None:
                 logger.warn("Could not find a queue matching task count %d, falling back to depreciated default walltime parameter"%task_count)
-                walltime = self.get_default_walltime()
+                #if the user names a queue which is not defined in config_batch.xml and does not set a
+                #walltime, fall back to the max walltime in the default queue
+                if force_queue:
+                    self.get_default_queue()
+                walltime = self._default_walltime
 
             self.set_value( "JOB_WALLCLOCK_TIME", walltime , subgroup=job)
             logger.info("Job %s queue %s walltime %s"%(job, queue, walltime))
@@ -479,13 +488,10 @@ def get_max_walltime(self, queue):
             if queue_node.text == queue:
                 return queue_node.get("walltimemax")
 
-    def get_default_walltime(self):
-        walltime = self.get_value("walltime", attribute={"default" : "true"}, subgroup=None)
-        expect(walltime is not None,"Could not find walltime setting in config_batch.xml")
-        return walltime
-
     def get_default_queue(self):
-        return self.get_optional_node("queue", attributes={"default" : "true"})
+        node = self.get_optional_node("queue", attributes={"default" : "true"})
+        self._default_walltime = node.get("walltimemax")
+        return(node)
 
     def get_all_queues(self):
         return self.get_nodes("queue")


Test patch: