Skip to content

Commit f9da5bb

Browse files
committed
Only append EnvPostprocessing in two situations:
In Case.read_xml(), we only want to include EnvPostprocessing object if one of the following is true: 1. The case is being created (added Case._existing_case to make it easy to check) 2. env_postprocessing.xml exists (which should only be the case if the file in POSTPROCESSING_SPEC_FILE exists)
1 parent b2bbd83 commit f9da5bb

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

CIME/XML/postprocessing.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ def __init__(self, infile=None, files=None):
1919
files = Files()
2020
if infile is None:
2121
infile = files.get_value("POSTPROCESSING_SPEC_FILE")
22-
self._file_exists = os.path.isfile(infile)
23-
if not self._file_exists:
22+
self.file_exists = os.path.isfile(infile)
23+
if not self.file_exists:
2424
return
2525
expect(infile, "No postprocessing file defined in {}".format(files.filename))
2626

CIME/case/case.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ def __init__(self, case_root=None, read_only=True, record=False, non_local=False
111111
case_root
112112
),
113113
)
114+
self._existing_case = os.path.isdir(case_root)
114115

115116
self._caseroot = case_root
116117
logger.debug("Initializing Case.")
@@ -358,9 +359,10 @@ def read_xml(self):
358359
self._env_entryid_files.append(
359360
EnvWorkflow(self._caseroot, read_only=self._force_read_only)
360361
)
361-
self._env_entryid_files.append(
362-
EnvPostprocessing(self._caseroot, read_only=self._force_read_only)
363-
)
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+
)
364366

365367
if os.path.isfile(os.path.join(self._caseroot, "env_test.xml")):
366368
self._env_entryid_files.append(
@@ -1591,7 +1593,7 @@ def configure(
15911593
workflow = Workflow(files=files)
15921594

15931595
postprocessing = Postprocessing(files=files)
1594-
if postprocessing._file_exists:
1596+
if postprocessing.file_exists:
15951597
env_postprocessing = self.get_env("postprocessing")
15961598
env_postprocessing.add_elements_by_group(srcobj=postprocessing)
15971599

0 commit comments

Comments
 (0)