Skip to content

Commit c0d5b9e

Browse files
committed
Skip validation if comparison test not run
If the necessary output files for performing validation against the version of each test case without inactive top cells aren't present, skip validation with a warning message.
1 parent 483cff6 commit c0d5b9e

File tree

2 files changed

+27
-14
lines changed

2 files changed

+27
-14
lines changed

compass/ocean/tests/global_ocean/init/__init__.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,17 +130,24 @@ def validate(self):
130130

131131
if self.with_inactive_top_cells:
132132
# construct the work directory for the other test
133+
filename1 = 'initial_state/initial_state_crop.nc'
133134
filename2 = os.path.join(self.base_work_dir, self.mpas_core.name,
134135
self.test_group.name,
135136
self.inactive_top_comp_subdir,
136137
'init/initial_state/initial_state.nc')
137-
variables = [
138-
'temperature', 'salinity', 'layerThickness', 'normalVelocity']
139-
compare_variables(test_case=self, variables=variables,
140-
filename1='initial_state/initial_state_crop.nc',
141-
filename2=filename2, quiet=False,
142-
check_outputs=False,
143-
skip_if_step_not_run=False)
138+
if os.path.exists(filename2):
139+
variables = [
140+
'temperature', 'salinity', 'layerThickness',
141+
'normalVelocity']
142+
compare_variables(test_case=self, variables=variables,
143+
filename1=filename1, filename2=filename2,
144+
quiet=False, check_outputs=False,
145+
skip_if_step_not_run=False)
146+
147+
else:
148+
self.logger.warn('The version of "init" without inactive top '
149+
'cells was not run. Skipping\n'
150+
'validation.')
144151

145152
if self.mesh.with_ice_shelf_cavities:
146153
variables = ['ssh', 'landIcePressure']

compass/ocean/tests/global_ocean/performance_test/__init__.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,25 @@ def validate(self):
6565

6666
if self.init.with_inactive_top_cells:
6767
# construct the work directory for the other test
68+
filename1 = 'forward/output_crop.nc'
69+
6870
subdir = get_forward_subdir(self.init.inactive_top_comp_subdir,
6971
self.time_integrator, self.name)
7072
filename2 = os.path.join(self.base_work_dir, self.mpas_core.name,
7173
self.test_group.name, subdir,
7274
'forward/output.nc')
7375

74-
variables = ['temperature', 'salinity', 'layerThickness',
75-
'normalVelocity']
76-
compare_variables(test_case=self, variables=variables,
77-
filename1='forward/output_crop.nc',
78-
filename2=filename2,
79-
quiet=False, check_outputs=False,
80-
skip_if_step_not_run=False)
76+
if os.path.exists(filename2):
77+
variables = ['temperature', 'salinity', 'layerThickness',
78+
'normalVelocity']
79+
compare_variables(test_case=self, variables=variables,
80+
filename1=filename1, filename2=filename2,
81+
quiet=False, check_outputs=False,
82+
skip_if_step_not_run=False)
83+
else:
84+
self.logger.warn('The version of "performance_test" without '
85+
'inactive top cells was not run.\n'
86+
'Skipping validation.')
8187

8288
if self.mesh.with_ice_shelf_cavities:
8389
variables = [

0 commit comments

Comments
 (0)