|
29 | 29 | from CIME.XML.grids import Grids |
30 | 30 | from CIME.XML.batch import Batch |
31 | 31 | from CIME.XML.workflow import Workflow |
| 32 | +from CIME.XML.postprocessing import Postprocessing |
32 | 33 | from CIME.XML.pio import PIO |
33 | 34 | from CIME.XML.archive import Archive |
34 | 35 | from CIME.XML.env_test import EnvTest |
|
40 | 41 | from CIME.XML.env_archive import EnvArchive |
41 | 42 | from CIME.XML.env_batch import EnvBatch |
42 | 43 | from CIME.XML.env_workflow import EnvWorkflow |
| 44 | +from CIME.XML.env_postprocessing import EnvPostprocessing |
43 | 45 | from CIME.XML.generic_xml import GenericXML |
44 | 46 | from CIME.user_mod_support import apply_user_mods |
45 | 47 | from CIME.aprun import get_aprun_cmd_for_case |
@@ -109,6 +111,7 @@ def __init__(self, case_root=None, read_only=True, record=False, non_local=False |
109 | 111 | case_root |
110 | 112 | ), |
111 | 113 | ) |
| 114 | + self._existing_case = os.path.isdir(case_root) |
112 | 115 |
|
113 | 116 | self._caseroot = case_root |
114 | 117 | logger.debug("Initializing Case.") |
@@ -356,6 +359,10 @@ def read_xml(self): |
356 | 359 | self._env_entryid_files.append( |
357 | 360 | EnvWorkflow(self._caseroot, read_only=self._force_read_only) |
358 | 361 | ) |
| 362 | + if not self._existing_case or os.path.isfile("env_postprocessing.xml"): |
| 363 | + self._env_entryid_files.append( |
| 364 | + EnvPostprocessing(self._caseroot, read_only=self._force_read_only) |
| 365 | + ) |
359 | 366 |
|
360 | 367 | if os.path.isfile(os.path.join(self._caseroot, "env_test.xml")): |
361 | 368 | self._env_entryid_files.append( |
@@ -430,6 +437,19 @@ def flush(self, flushall=False): |
430 | 437 | # do not flush if caseroot wasnt created |
431 | 438 | return |
432 | 439 |
|
| 440 | + _postprocessing_spec_file = self.get_value("POSTPROCESSING_SPEC_FILE") |
| 441 | + if _postprocessing_spec_file is not None: |
| 442 | + have_postprocessing = os.path.isfile(_postprocessing_spec_file) |
| 443 | + else: |
| 444 | + have_postprocessing = False |
| 445 | + if not have_postprocessing: |
| 446 | + # Remove env_postprocessing.xml from self._files |
| 447 | + self._files = [ |
| 448 | + file |
| 449 | + for file in self._files |
| 450 | + if file.get_id() != "env_postprocessing.xml" |
| 451 | + ] |
| 452 | + |
433 | 453 | for env_file in self._files: |
434 | 454 | env_file.write(force_write=flushall) |
435 | 455 |
|
@@ -1577,6 +1597,11 @@ def configure( |
1577 | 1597 |
|
1578 | 1598 | workflow = Workflow(files=files) |
1579 | 1599 |
|
| 1600 | + postprocessing = Postprocessing(files=files) |
| 1601 | + if postprocessing.file_exists: |
| 1602 | + env_postprocessing = self.get_env("postprocessing") |
| 1603 | + env_postprocessing.add_elements_by_group(srcobj=postprocessing) |
| 1604 | + |
1580 | 1605 | env_batch.set_batch_system(batch, batch_system_type=batch_system_type) |
1581 | 1606 |
|
1582 | 1607 | bjobs = workflow.get_workflow_jobs(machine=machine_name, workflowid=workflowid) |
@@ -2216,6 +2241,8 @@ def set_file(self, xmlfile): |
2216 | 2241 | new_env_file = EnvBatch(infile=xmlfile) |
2217 | 2242 | elif ftype == "env_workflow.xml": |
2218 | 2243 | new_env_file = EnvWorkflow(infile=xmlfile) |
| 2244 | + elif ftype == "env_postprocessing.xml": |
| 2245 | + new_env_file = EnvPostprocessing(infile=xmlfile) |
2219 | 2246 | elif ftype == "env_test.xml": |
2220 | 2247 | new_env_file = EnvTest(infile=xmlfile) |
2221 | 2248 | elif ftype == "env_archive.xml": |
|
0 commit comments