We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Comment at the top of env_batch.xml is wrong
The comment at the top of env_batch.xml (imported from config/config_headers.xml) is:

>       These variables may be changed anytime during a run, they
>       control arguments to the batch submit command.
> 
However, if I submit a job and then try:
```
./xmlchange JOB_WALLCLOCK_TIME=40:00:00
./xmlchange JOB_QUEUE=long
```
My job is killed (if it is in the queue when I make the change) or resubmit fails and I see the following message in my output file:
```
goldy@hobart^GFile /scratch/cluster/goldy/FQ3D_ne5pg3_ne5pg3_mg37/LockedFiles/env_batch.xml has been modified
  found difference in JOB_WALLCLOCK_TIME : case '40:00:00' locked '80:00:00'
  found difference in USER_REQUESTED_WALLTIME : case '40:00:00' locked ''
ERROR: Batch configuration has changed, please run case.setup --reset
```
The CIME documentation does not seem to mention this ability to change (cf http://esmci.github.io/cime/users_guide/running-a-case.html?highlight=job_wallclock_time).

Please fix the header with correct information.

Question: Is there a way to see the `<header>` information via `xmlquery`?

Reported by a CESM 2.0 user.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `scripts/lib/CIME/case/case_submit.py`
Content:
```
1 #!/usr/bin/env python
2 
3 """
4 case.submit - Submit a cesm workflow to the queueing system or run it
5 if there is no queueing system.  A cesm workflow may include multiple
6 jobs.
7 submit, check_case and check_da_settings are members of class Case in file case.py
8 """
9 import socket
10 from six.moves                   import configparser
11 from CIME.XML.standard_module_setup import *
12 from CIME.utils                     import expect, run_and_log_case_status, verbatim_success_msg
13 from CIME.locked_files              import unlock_file, lock_file
14 from CIME.test_status               import *
15 
16 logger = logging.getLogger(__name__)
17 
18 def _build_prereq_str(case, prev_job_ids):
19     delimiter = case.get_value("depend_separator")
20     prereq_str = ""
21     for job_id in prev_job_ids.values():
22         prereq_str += str(job_id) + delimiter
23     return prereq_str[:-1]
24 
25 def _submit(case, job=None, no_batch=False, prereq=None, allow_fail=False, resubmit=False,
26             resubmit_immediate=False, skip_pnl=False, mail_user=None, mail_type=None,
27             batch_args=None):
28     if job is None:
29         job = case.get_primary_job()
30 
31     rundir = case.get_value("RUNDIR")
32     if job != "case.test":
33         continue_run = case.get_value("CONTINUE_RUN")
34         expect(os.path.isdir(rundir) or not continue_run,
35                " CONTINUE_RUN is true but RUNDIR {} does not exist".format(rundir))
36 
37     # if case.submit is called with the no_batch flag then we assume that this
38     # flag will stay in effect for the duration of the RESUBMITs
39     env_batch = case.get_env("batch")
40     if resubmit:
41         if env_batch.get_batch_system_type() == "none":
42             no_batch = True
43 
44         # This is a resubmission, do not reinitialize test values
45         if job == "case.test":
46             case.set_value("IS_FIRST_RUN", False)
47 
48         resub = case.get_value("RESUBMIT")
49         logger.info("Submitting job '{}', resubmit={:d}".format(job, resub))
50         case.set_value("RESUBMIT", resub-1)
51         if case.get_value("RESUBMIT_SETS_CONTINUE_RUN"):
52             case.set_value("CONTINUE_RUN", True)
53 
54     else:
55         if job == "case.test":
56             case.set_value("IS_FIRST_RUN", True)
57 
58         if no_batch:
59             batch_system = "none"
60         else:
61             batch_system = env_batch.get_batch_system_type()
62 
63         case.set_value("BATCH_SYSTEM", batch_system)
64 
65         env_batch_has_changed = False
66         try:
67             case.check_lockedfile(os.path.basename(env_batch.filename))
68         except SystemExit:
69             env_batch_has_changed = True
70 
71         if env_batch.get_batch_system_type() != "none" and env_batch_has_changed:
72             # May need to regen batch files if user made batch setting changes (e.g. walltime, queue, etc)
73             logger.warning(\
74 """
75 env_batch.xml appears to have changed, regenerating batch scripts
76 manual edits to these file will be lost!
77 """)
78             env_batch.make_all_batch_files(case)
79 
80         unlock_file(os.path.basename(env_batch.filename))
81         lock_file(os.path.basename(env_batch.filename))
82 
83         if job == case.get_primary_job():
84             case.check_case()
85             case.check_DA_settings()
86             if case.get_value("MACH") == "mira":
87                 with open(".original_host", "w") as fd:
88                     fd.write( socket.gethostname())
89 
90     #Load Modules
91     case.load_env()
92 
93     case.flush()
94 
95     logger.warning("submit_jobs {}".format(job))
96     job_ids = case.submit_jobs(no_batch=no_batch, job=job, prereq=prereq,
97                                skip_pnl=skip_pnl, resubmit_immediate=resubmit_immediate,
98                                allow_fail=allow_fail, mail_user=mail_user,
99                                mail_type=mail_type, batch_args=batch_args)
100 
101     xml_jobids = []
102     for jobname, jobid in job_ids.items():
103         logger.info("Submitted job {} with id {}".format(jobname, jobid))
104         if jobid:
105             xml_jobids.append("{}:{}".format(jobname, jobid))
106 
107     xml_jobid_text = ", ".join(xml_jobids)
108     if xml_jobid_text:
109         case.set_value("JOB_IDS", xml_jobid_text)
110 
111     return xml_jobid_text
112 
113 def submit(self, job=None, no_batch=False, prereq=None, allow_fail=False, resubmit=False,
114            resubmit_immediate=False, skip_pnl=False, mail_user=None, mail_type=None,
115            batch_args=None):
116     if resubmit_immediate and self.get_value("MACH") in ['mira', 'cetus']:
117         logger.warning("resubmit_immediate does not work on Mira/Cetus, submitting normally")
118         resubmit_immediate = False
119 
120     if self.get_value("TEST"):
121         caseroot = self.get_value("CASEROOT")
122         casebaseid = self.get_value("CASEBASEID")
123         # This should take care of the race condition where the submitted job
124         # begins immediately and tries to set RUN phase. We proactively assume
125         # a passed SUBMIT phase. If this state is already PASS, don't set it again
126         # because then we'll lose RUN phase info if it's there. This info is important
127         # for system_tests_common to know if it needs to reinitialize the test or not.
128         with TestStatus(test_dir=caseroot, test_name=casebaseid) as ts:
129             phase_status = ts.get_status(SUBMIT_PHASE)
130             if phase_status != TEST_PASS_STATUS:
131                 ts.set_status(SUBMIT_PHASE, TEST_PASS_STATUS)
132 
133     # If this is a resubmit check the hidden file .submit_options for
134     # any submit options used on the original submit and use them again
135     caseroot = self.get_value("CASEROOT")
136     submit_options = os.path.join(caseroot, ".submit_options")
137     if resubmit and os.path.exists(submit_options):
138         config = configparser.SafeConfigParser()
139         config.read(submit_options)
140         if not skip_pnl and config.has_option('SubmitOptions','skip_pnl'):
141             skip_pnl = config.getboolean('SubmitOptions', 'skip_pnl')
142         if mail_user is None and config.has_option('SubmitOptions', 'mail_user'):
143             mail_user = config.get('SubmitOptions', 'mail_user')
144         if mail_type is None and config.has_option('SubmitOptions', 'mail_type'):
145             mail_type = config.get('SubmitOptions', 'mail_type').split(',')
146         if batch_args is None and config.has_option('SubmitOptions', 'batch_args'):
147             batch_args = config.get('SubmitOptions', 'batch_args')
148 
149     try:
150         functor = lambda: _submit(self, job=job, no_batch=no_batch, prereq=prereq,
151                                   allow_fail=allow_fail, resubmit=resubmit,
152                                   resubmit_immediate=resubmit_immediate, skip_pnl=skip_pnl,
153                                   mail_user=mail_user, mail_type=mail_type,
154                                   batch_args=batch_args)
155         run_and_log_case_status(functor, "case.submit", caseroot=caseroot,
156                                 custom_success_msg_functor=verbatim_success_msg)
157     except:
158         # If something failed in the batch system, make sure to mark
159         # the test as failed if we are running a test.
160         if self.get_value("TEST"):
161             with TestStatus(test_dir=caseroot, test_name=casebaseid) as ts:
162                 ts.set_status(SUBMIT_PHASE, TEST_FAIL_STATUS)
163 
164         raise
165 
166 def check_case(self):
167     self.check_lockedfiles()
168     self.create_namelists() # Must be called before check_all_input_data
169     logger.info("Checking that inputdata is available as part of case submission")
170     self.check_all_input_data()
171 
172     if self.get_value('COMP_WAV') == 'ww':
173         # the ww3 buildnml has dependancies on inputdata so we must run it again
174         self.create_namelists(component='WAV')
175 
176 
177     expect(self.get_value("BUILD_COMPLETE"), "Build complete is "
178            "not True please rebuild the model by calling case.build")
179     logger.info("Check case OK")
180 
181 def check_DA_settings(self):
182     script = self.get_value("DATA_ASSIMILATION_SCRIPT")
183     cycles = self.get_value("DATA_ASSIMILATION_CYCLES")
184     if len(script) > 0 and os.path.isfile(script) and cycles > 0:
185         logger.info("Data Assimilation enabled using script {} with {:d} cycles".format(script,
186                                                                                         cycles))
187
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/scripts/lib/CIME/case/case_submit.py b/scripts/lib/CIME/case/case_submit.py
--- a/scripts/lib/CIME/case/case_submit.py
+++ b/scripts/lib/CIME/case/case_submit.py
@@ -37,10 +37,35 @@
     # if case.submit is called with the no_batch flag then we assume that this
     # flag will stay in effect for the duration of the RESUBMITs
     env_batch = case.get_env("batch")
-    if resubmit:
-        if env_batch.get_batch_system_type() == "none":
-            no_batch = True
 
+    if resubmit and env_batch.get_batch_system_type() == "none":
+        no_batch = True
+    if no_batch:
+        batch_system = "none"
+    else:
+        batch_system = env_batch.get_batch_system_type()
+
+    case.set_value("BATCH_SYSTEM", batch_system)
+
+    env_batch_has_changed = False
+    try:
+        case.check_lockedfile(os.path.basename(env_batch.filename))
+    except:
+        env_batch_has_changed = True
+
+    if batch_system != "none" and env_batch_has_changed:
+        # May need to regen batch files if user made batch setting changes (e.g. walltime, queue, etc)
+        logger.warning(\
+"""
+env_batch.xml appears to have changed, regenerating batch scripts
+manual edits to these file will be lost!
+""")
+        env_batch.make_all_batch_files(case)
+
+    unlock_file(os.path.basename(env_batch.filename))
+    lock_file(os.path.basename(env_batch.filename))
+
+    if resubmit:
         # This is a resubmission, do not reinitialize test values
         if job == "case.test":
             case.set_value("IS_FIRST_RUN", False)
@@ -55,31 +80,6 @@
         if job == "case.test":
             case.set_value("IS_FIRST_RUN", True)
 
-        if no_batch:
-            batch_system = "none"
-        else:
-            batch_system = env_batch.get_batch_system_type()
-
-        case.set_value("BATCH_SYSTEM", batch_system)
-
-        env_batch_has_changed = False
-        try:
-            case.check_lockedfile(os.path.basename(env_batch.filename))
-        except SystemExit:
-            env_batch_has_changed = True
-
-        if env_batch.get_batch_system_type() != "none" and env_batch_has_changed:
-            # May need to regen batch files if user made batch setting changes (e.g. walltime, queue, etc)
-            logger.warning(\
-"""
-env_batch.xml appears to have changed, regenerating batch scripts
-manual edits to these file will be lost!
-""")
-            env_batch.make_all_batch_files(case)
-
-        unlock_file(os.path.basename(env_batch.filename))
-        lock_file(os.path.basename(env_batch.filename))
-
         if job == case.get_primary_job():
             case.check_case()
             case.check_DA_settings()

{"golden_diff": "diff --git a/scripts/lib/CIME/case/case_submit.py b/scripts/lib/CIME/case/case_submit.py\n--- a/scripts/lib/CIME/case/case_submit.py\n+++ b/scripts/lib/CIME/case/case_submit.py\n@@ -37,10 +37,35 @@\n     # if case.submit is called with the no_batch flag then we assume that this\n     # flag will stay in effect for the duration of the RESUBMITs\n     env_batch = case.get_env(\"batch\")\n-    if resubmit:\n-        if env_batch.get_batch_system_type() == \"none\":\n-            no_batch = True\n \n+    if resubmit and env_batch.get_batch_system_type() == \"none\":\n+        no_batch = True\n+    if no_batch:\n+        batch_system = \"none\"\n+    else:\n+        batch_system = env_batch.get_batch_system_type()\n+\n+    case.set_value(\"BATCH_SYSTEM\", batch_system)\n+\n+    env_batch_has_changed = False\n+    try:\n+        case.check_lockedfile(os.path.basename(env_batch.filename))\n+    except:\n+        env_batch_has_changed = True\n+\n+    if batch_system != \"none\" and env_batch_has_changed:\n+        # May need to regen batch files if user made batch setting changes (e.g. walltime, queue, etc)\n+        logger.warning(\\\n+\"\"\"\n+env_batch.xml appears to have changed, regenerating batch scripts\n+manual edits to these file will be lost!\n+\"\"\")\n+        env_batch.make_all_batch_files(case)\n+\n+    unlock_file(os.path.basename(env_batch.filename))\n+    lock_file(os.path.basename(env_batch.filename))\n+\n+    if resubmit:\n         # This is a resubmission, do not reinitialize test values\n         if job == \"case.test\":\n             case.set_value(\"IS_FIRST_RUN\", False)\n@@ -55,31 +80,6 @@\n         if job == \"case.test\":\n             case.set_value(\"IS_FIRST_RUN\", True)\n \n-        if no_batch:\n-            batch_system = \"none\"\n-        else:\n-            batch_system = env_batch.get_batch_system_type()\n-\n-        case.set_value(\"BATCH_SYSTEM\", batch_system)\n-\n-        env_batch_has_changed = False\n-        try:\n-            case.check_lockedfile(os.path.basename(env_batch.filename))\n-        except SystemExit:\n-            env_batch_has_changed = True\n-\n-        if env_batch.get_batch_system_type() != \"none\" and env_batch_has_changed:\n-            # May need to regen batch files if user made batch setting changes (e.g. walltime, queue, etc)\n-            logger.warning(\\\n-\"\"\"\n-env_batch.xml appears to have changed, regenerating batch scripts\n-manual edits to these file will be lost!\n-\"\"\")\n-            env_batch.make_all_batch_files(case)\n-\n-        unlock_file(os.path.basename(env_batch.filename))\n-        lock_file(os.path.basename(env_batch.filename))\n-\n         if job == case.get_primary_job():\n             case.check_case()\n             case.check_DA_settings()\n", "issue": "Comment at the top of env_batch.xml is wrong\nThe comment at the top of env_batch.xml (imported from config/config_headers.xml) is:\r\n\r\n>       These variables may be changed anytime during a run, they\r\n>       control arguments to the batch submit command.\r\n> \r\nHowever, if I submit a job and then try:\r\n```\r\n./xmlchange JOB_WALLCLOCK_TIME=40:00:00\r\n./xmlchange JOB_QUEUE=long\r\n```\r\nMy job is killed (if it is in the queue when I make the change) or resubmit fails and I see the following message in my output file:\r\n```\r\ngoldy@hobart^GFile /scratch/cluster/goldy/FQ3D_ne5pg3_ne5pg3_mg37/LockedFiles/env_batch.xml has been modified\r\n  found difference in JOB_WALLCLOCK_TIME : case '40:00:00' locked '80:00:00'\r\n  found difference in USER_REQUESTED_WALLTIME : case '40:00:00' locked ''\r\nERROR: Batch configuration has changed, please run case.setup --reset\r\n```\r\nThe CIME documentation does not seem to mention this ability to change (cf http://esmci.github.io/cime/users_guide/running-a-case.html?highlight=job_wallclock_time).\r\n\r\nPlease fix the header with correct information.\r\n\r\nQuestion: Is there a way to see the `<header>` information via `xmlquery`?\r\n\r\nReported by a CESM 2.0 user.\n", "before_files": [{"content": "#!/usr/bin/env python\n\n\"\"\"\ncase.submit - Submit a cesm workflow to the queueing system or run it\nif there is no queueing system.  A cesm workflow may include multiple\njobs.\nsubmit, check_case and check_da_settings are members of class Case in file case.py\n\"\"\"\nimport socket\nfrom six.moves                   import configparser\nfrom CIME.XML.standard_module_setup import *\nfrom CIME.utils                     import expect, run_and_log_case_status, verbatim_success_msg\nfrom CIME.locked_files              import unlock_file, lock_file\nfrom CIME.test_status               import *\n\nlogger = logging.getLogger(__name__)\n\ndef _build_prereq_str(case, prev_job_ids):\n    delimiter = case.get_value(\"depend_separator\")\n    prereq_str = \"\"\n    for job_id in prev_job_ids.values():\n        prereq_str += str(job_id) + delimiter\n    return prereq_str[:-1]\n\ndef _submit(case, job=None, no_batch=False, prereq=None, allow_fail=False, resubmit=False,\n            resubmit_immediate=False, skip_pnl=False, mail_user=None, mail_type=None,\n            batch_args=None):\n    if job is None:\n        job = case.get_primary_job()\n\n    rundir = case.get_value(\"RUNDIR\")\n    if job != \"case.test\":\n        continue_run = case.get_value(\"CONTINUE_RUN\")\n        expect(os.path.isdir(rundir) or not continue_run,\n               \" CONTINUE_RUN is true but RUNDIR {} does not exist\".format(rundir))\n\n    # if case.submit is called with the no_batch flag then we assume that this\n    # flag will stay in effect for the duration of the RESUBMITs\n    env_batch = case.get_env(\"batch\")\n    if resubmit:\n        if env_batch.get_batch_system_type() == \"none\":\n            no_batch = True\n\n        # This is a resubmission, do not reinitialize test values\n        if job == \"case.test\":\n            case.set_value(\"IS_FIRST_RUN\", False)\n\n        resub = case.get_value(\"RESUBMIT\")\n        logger.info(\"Submitting job '{}', resubmit={:d}\".format(job, resub))\n        case.set_value(\"RESUBMIT\", resub-1)\n        if case.get_value(\"RESUBMIT_SETS_CONTINUE_RUN\"):\n            case.set_value(\"CONTINUE_RUN\", True)\n\n    else:\n        if job == \"case.test\":\n            case.set_value(\"IS_FIRST_RUN\", True)\n\n        if no_batch:\n            batch_system = \"none\"\n        else:\n            batch_system = env_batch.get_batch_system_type()\n\n        case.set_value(\"BATCH_SYSTEM\", batch_system)\n\n        env_batch_has_changed = False\n        try:\n            case.check_lockedfile(os.path.basename(env_batch.filename))\n        except SystemExit:\n            env_batch_has_changed = True\n\n        if env_batch.get_batch_system_type() != \"none\" and env_batch_has_changed:\n            # May need to regen batch files if user made batch setting changes (e.g. walltime, queue, etc)\n            logger.warning(\\\n\"\"\"\nenv_batch.xml appears to have changed, regenerating batch scripts\nmanual edits to these file will be lost!\n\"\"\")\n            env_batch.make_all_batch_files(case)\n\n        unlock_file(os.path.basename(env_batch.filename))\n        lock_file(os.path.basename(env_batch.filename))\n\n        if job == case.get_primary_job():\n            case.check_case()\n            case.check_DA_settings()\n            if case.get_value(\"MACH\") == \"mira\":\n                with open(\".original_host\", \"w\") as fd:\n                    fd.write( socket.gethostname())\n\n    #Load Modules\n    case.load_env()\n\n    case.flush()\n\n    logger.warning(\"submit_jobs {}\".format(job))\n    job_ids = case.submit_jobs(no_batch=no_batch, job=job, prereq=prereq,\n                               skip_pnl=skip_pnl, resubmit_immediate=resubmit_immediate,\n                               allow_fail=allow_fail, mail_user=mail_user,\n                               mail_type=mail_type, batch_args=batch_args)\n\n    xml_jobids = []\n    for jobname, jobid in job_ids.items():\n        logger.info(\"Submitted job {} with id {}\".format(jobname, jobid))\n        if jobid:\n            xml_jobids.append(\"{}:{}\".format(jobname, jobid))\n\n    xml_jobid_text = \", \".join(xml_jobids)\n    if xml_jobid_text:\n        case.set_value(\"JOB_IDS\", xml_jobid_text)\n\n    return xml_jobid_text\n\ndef submit(self, job=None, no_batch=False, prereq=None, allow_fail=False, resubmit=False,\n           resubmit_immediate=False, skip_pnl=False, mail_user=None, mail_type=None,\n           batch_args=None):\n    if resubmit_immediate and self.get_value(\"MACH\") in ['mira', 'cetus']:\n        logger.warning(\"resubmit_immediate does not work on Mira/Cetus, submitting normally\")\n        resubmit_immediate = False\n\n    if self.get_value(\"TEST\"):\n        caseroot = self.get_value(\"CASEROOT\")\n        casebaseid = self.get_value(\"CASEBASEID\")\n        # This should take care of the race condition where the submitted job\n        # begins immediately and tries to set RUN phase. We proactively assume\n        # a passed SUBMIT phase. If this state is already PASS, don't set it again\n        # because then we'll lose RUN phase info if it's there. This info is important\n        # for system_tests_common to know if it needs to reinitialize the test or not.\n        with TestStatus(test_dir=caseroot, test_name=casebaseid) as ts:\n            phase_status = ts.get_status(SUBMIT_PHASE)\n            if phase_status != TEST_PASS_STATUS:\n                ts.set_status(SUBMIT_PHASE, TEST_PASS_STATUS)\n\n    # If this is a resubmit check the hidden file .submit_options for\n    # any submit options used on the original submit and use them again\n    caseroot = self.get_value(\"CASEROOT\")\n    submit_options = os.path.join(caseroot, \".submit_options\")\n    if resubmit and os.path.exists(submit_options):\n        config = configparser.SafeConfigParser()\n        config.read(submit_options)\n        if not skip_pnl and config.has_option('SubmitOptions','skip_pnl'):\n            skip_pnl = config.getboolean('SubmitOptions', 'skip_pnl')\n        if mail_user is None and config.has_option('SubmitOptions', 'mail_user'):\n            mail_user = config.get('SubmitOptions', 'mail_user')\n        if mail_type is None and config.has_option('SubmitOptions', 'mail_type'):\n            mail_type = config.get('SubmitOptions', 'mail_type').split(',')\n        if batch_args is None and config.has_option('SubmitOptions', 'batch_args'):\n            batch_args = config.get('SubmitOptions', 'batch_args')\n\n    try:\n        functor = lambda: _submit(self, job=job, no_batch=no_batch, prereq=prereq,\n                                  allow_fail=allow_fail, resubmit=resubmit,\n                                  resubmit_immediate=resubmit_immediate, skip_pnl=skip_pnl,\n                                  mail_user=mail_user, mail_type=mail_type,\n                                  batch_args=batch_args)\n        run_and_log_case_status(functor, \"case.submit\", caseroot=caseroot,\n                                custom_success_msg_functor=verbatim_success_msg)\n    except:\n        # If something failed in the batch system, make sure to mark\n        # the test as failed if we are running a test.\n        if self.get_value(\"TEST\"):\n            with TestStatus(test_dir=caseroot, test_name=casebaseid) as ts:\n                ts.set_status(SUBMIT_PHASE, TEST_FAIL_STATUS)\n\n        raise\n\ndef check_case(self):\n    self.check_lockedfiles()\n    self.create_namelists() # Must be called before check_all_input_data\n    logger.info(\"Checking that inputdata is available as part of case submission\")\n    self.check_all_input_data()\n\n    if self.get_value('COMP_WAV') == 'ww':\n        # the ww3 buildnml has dependancies on inputdata so we must run it again\n        self.create_namelists(component='WAV')\n\n\n    expect(self.get_value(\"BUILD_COMPLETE\"), \"Build complete is \"\n           \"not True please rebuild the model by calling case.build\")\n    logger.info(\"Check case OK\")\n\ndef check_DA_settings(self):\n    script = self.get_value(\"DATA_ASSIMILATION_SCRIPT\")\n    cycles = self.get_value(\"DATA_ASSIMILATION_CYCLES\")\n    if len(script) > 0 and os.path.isfile(script) and cycles > 0:\n        logger.info(\"Data Assimilation enabled using script {} with {:d} cycles\".format(script,\n                                                                                        cycles))\n", "path": "scripts/lib/CIME/case/case_submit.py"}], "after_files": [{"content": "#!/usr/bin/env python\n\n\"\"\"\ncase.submit - Submit a cesm workflow to the queueing system or run it\nif there is no queueing system.  A cesm workflow may include multiple\njobs.\nsubmit, check_case and check_da_settings are members of class Case in file case.py\n\"\"\"\nimport socket\nfrom six.moves                   import configparser\nfrom CIME.XML.standard_module_setup import *\nfrom CIME.utils                     import expect, run_and_log_case_status, verbatim_success_msg\nfrom CIME.locked_files              import unlock_file, lock_file\nfrom CIME.test_status               import *\n\nlogger = logging.getLogger(__name__)\n\ndef _build_prereq_str(case, prev_job_ids):\n    delimiter = case.get_value(\"depend_separator\")\n    prereq_str = \"\"\n    for job_id in prev_job_ids.values():\n        prereq_str += str(job_id) + delimiter\n    return prereq_str[:-1]\n\ndef _submit(case, job=None, no_batch=False, prereq=None, allow_fail=False, resubmit=False,\n            resubmit_immediate=False, skip_pnl=False, mail_user=None, mail_type=None,\n            batch_args=None):\n    if job is None:\n        job = case.get_primary_job()\n\n    rundir = case.get_value(\"RUNDIR\")\n    if job != \"case.test\":\n        continue_run = case.get_value(\"CONTINUE_RUN\")\n        expect(os.path.isdir(rundir) or not continue_run,\n               \" CONTINUE_RUN is true but RUNDIR {} does not exist\".format(rundir))\n\n    # if case.submit is called with the no_batch flag then we assume that this\n    # flag will stay in effect for the duration of the RESUBMITs\n    env_batch = case.get_env(\"batch\")\n\n    if resubmit and env_batch.get_batch_system_type() == \"none\":\n        no_batch = True\n    if no_batch:\n        batch_system = \"none\"\n    else:\n        batch_system = env_batch.get_batch_system_type()\n\n    case.set_value(\"BATCH_SYSTEM\", batch_system)\n\n    env_batch_has_changed = False\n    try:\n        case.check_lockedfile(os.path.basename(env_batch.filename))\n    except:\n        env_batch_has_changed = True\n\n    if batch_system != \"none\" and env_batch_has_changed:\n        # May need to regen batch files if user made batch setting changes (e.g. walltime, queue, etc)\n        logger.warning(\\\n\"\"\"\nenv_batch.xml appears to have changed, regenerating batch scripts\nmanual edits to these file will be lost!\n\"\"\")\n        env_batch.make_all_batch_files(case)\n\n    unlock_file(os.path.basename(env_batch.filename))\n    lock_file(os.path.basename(env_batch.filename))\n\n    if resubmit:\n        # This is a resubmission, do not reinitialize test values\n        if job == \"case.test\":\n            case.set_value(\"IS_FIRST_RUN\", False)\n\n        resub = case.get_value(\"RESUBMIT\")\n        logger.info(\"Submitting job '{}', resubmit={:d}\".format(job, resub))\n        case.set_value(\"RESUBMIT\", resub-1)\n        if case.get_value(\"RESUBMIT_SETS_CONTINUE_RUN\"):\n            case.set_value(\"CONTINUE_RUN\", True)\n\n    else:\n        if job == \"case.test\":\n            case.set_value(\"IS_FIRST_RUN\", True)\n\n        if job == case.get_primary_job():\n            case.check_case()\n            case.check_DA_settings()\n            if case.get_value(\"MACH\") == \"mira\":\n                with open(\".original_host\", \"w\") as fd:\n                    fd.write( socket.gethostname())\n\n    #Load Modules\n    case.load_env()\n\n    case.flush()\n\n    logger.warning(\"submit_jobs {}\".format(job))\n    job_ids = case.submit_jobs(no_batch=no_batch, job=job, prereq=prereq,\n                               skip_pnl=skip_pnl, resubmit_immediate=resubmit_immediate,\n                               allow_fail=allow_fail, mail_user=mail_user,\n                               mail_type=mail_type, batch_args=batch_args)\n\n    xml_jobids = []\n    for jobname, jobid in job_ids.items():\n        logger.info(\"Submitted job {} with id {}\".format(jobname, jobid))\n        if jobid:\n            xml_jobids.append(\"{}:{}\".format(jobname, jobid))\n\n    xml_jobid_text = \", \".join(xml_jobids)\n    if xml_jobid_text:\n        case.set_value(\"JOB_IDS\", xml_jobid_text)\n\n    return xml_jobid_text\n\ndef submit(self, job=None, no_batch=False, prereq=None, allow_fail=False, resubmit=False,\n           resubmit_immediate=False, skip_pnl=False, mail_user=None, mail_type=None,\n           batch_args=None):\n    if resubmit_immediate and self.get_value(\"MACH\") in ['mira', 'cetus']:\n        logger.warning(\"resubmit_immediate does not work on Mira/Cetus, submitting normally\")\n        resubmit_immediate = False\n\n    if self.get_value(\"TEST\"):\n        caseroot = self.get_value(\"CASEROOT\")\n        casebaseid = self.get_value(\"CASEBASEID\")\n        # This should take care of the race condition where the submitted job\n        # begins immediately and tries to set RUN phase. We proactively assume\n        # a passed SUBMIT phase. If this state is already PASS, don't set it again\n        # because then we'll lose RUN phase info if it's there. This info is important\n        # for system_tests_common to know if it needs to reinitialize the test or not.\n        with TestStatus(test_dir=caseroot, test_name=casebaseid) as ts:\n            phase_status = ts.get_status(SUBMIT_PHASE)\n            if phase_status != TEST_PASS_STATUS:\n                ts.set_status(SUBMIT_PHASE, TEST_PASS_STATUS)\n\n    # If this is a resubmit check the hidden file .submit_options for\n    # any submit options used on the original submit and use them again\n    caseroot = self.get_value(\"CASEROOT\")\n    submit_options = os.path.join(caseroot, \".submit_options\")\n    if resubmit and os.path.exists(submit_options):\n        config = configparser.SafeConfigParser()\n        config.read(submit_options)\n        if not skip_pnl and config.has_option('SubmitOptions','skip_pnl'):\n            skip_pnl = config.getboolean('SubmitOptions', 'skip_pnl')\n        if mail_user is None and config.has_option('SubmitOptions', 'mail_user'):\n            mail_user = config.get('SubmitOptions', 'mail_user')\n        if mail_type is None and config.has_option('SubmitOptions', 'mail_type'):\n            mail_type = config.get('SubmitOptions', 'mail_type').split(',')\n        if batch_args is None and config.has_option('SubmitOptions', 'batch_args'):\n            batch_args = config.get('SubmitOptions', 'batch_args')\n\n    try:\n        functor = lambda: _submit(self, job=job, no_batch=no_batch, prereq=prereq,\n                                  allow_fail=allow_fail, resubmit=resubmit,\n                                  resubmit_immediate=resubmit_immediate, skip_pnl=skip_pnl,\n                                  mail_user=mail_user, mail_type=mail_type,\n                                  batch_args=batch_args)\n        run_and_log_case_status(functor, \"case.submit\", caseroot=caseroot,\n                                custom_success_msg_functor=verbatim_success_msg)\n    except:\n        # If something failed in the batch system, make sure to mark\n        # the test as failed if we are running a test.\n        if self.get_value(\"TEST\"):\n            with TestStatus(test_dir=caseroot, test_name=casebaseid) as ts:\n                ts.set_status(SUBMIT_PHASE, TEST_FAIL_STATUS)\n\n        raise\n\ndef check_case(self):\n    self.check_lockedfiles()\n    self.create_namelists() # Must be called before check_all_input_data\n    logger.info(\"Checking that inputdata is available as part of case submission\")\n    self.check_all_input_data()\n\n    if self.get_value('COMP_WAV') == 'ww':\n        # the ww3 buildnml has dependancies on inputdata so we must run it again\n        self.create_namelists(component='WAV')\n\n\n    expect(self.get_value(\"BUILD_COMPLETE\"), \"Build complete is \"\n           \"not True please rebuild the model by calling case.build\")\n    logger.info(\"Check case OK\")\n\ndef check_DA_settings(self):\n    script = self.get_value(\"DATA_ASSIMILATION_SCRIPT\")\n    cycles = self.get_value(\"DATA_ASSIMILATION_CYCLES\")\n    if len(script) > 0 and os.path.isfile(script) and cycles > 0:\n        logger.info(\"Data Assimilation enabled using script {} with {:d} cycles\".format(script,\n                                                                                        cycles))\n", "path": "scripts/lib/CIME/case/case_submit.py"}]}