Skip to content

Commit

Permalink
Fixup output comparison paths
Browse files Browse the repository at this point in the history
  • Loading branch information
cbegeman committed Aug 25, 2023
1 parent 2a41fe5 commit 84aef87
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 20 deletions.
15 changes: 8 additions & 7 deletions compass/ocean/tests/global_ocean/init/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __init__(self, test_group, mesh, initial_condition,
# Add the name of the subdir without inactive top cells whether or
# not is has or will be run
self.inactive_top_comp_subdir = init_subdir
init_subdir = os.path.join(init_subdir, inactive_top)
name = f'{name}_inactive_top'
self.init_subdir = init_subdir
subdir = os.path.join(self.init_subdir, name)
super().__init__(test_group=test_group, name=name, subdir=subdir)
Expand All @@ -66,7 +66,7 @@ def __init__(self, test_group, mesh, initial_condition,
self.add_step(
InitialState(
test_case=self, mesh=mesh,
initial_condition=initial_condition,
initial_condition=initial_condition,
with_inactive_top_cells=with_inactive_top_cells))

if mesh.with_ice_shelf_cavities:
Expand Down Expand Up @@ -116,11 +116,12 @@ def validate(self):
if os.path.exists(filename2):
variables = ['temperature', 'salinity', 'layerThickness',
'normalVelocity']
compare_variables(test_case=self, variables=variables,
filename1='initial_state/initial_state_crop.nc'
filename2=filename2,
quiet=False, check_outputs=False,
skip_if_step_not_run=False)
compare_variables(
test_case=self, variables=variables,
filename1='initial_state/initial_state_crop.nc',
filename2=filename2,
quiet=False, check_outputs=False,
skip_if_step_not_run=False)

else:
self.logger.warn('The version of "init" without inactive top '
Expand Down
38 changes: 25 additions & 13 deletions compass/ocean/tests/global_ocean/performance_test/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import os

from compass.ocean.inactive_top_cells import remove_inactive_top_cells_output
from compass.ocean.tests.global_ocean.forward import (
ForwardStep,
ForwardTestCase,
)
from compass.validate import compare_timers, compare_variables
from compass.ocean.inactive_top_cells import remove_inactive_top_cells_output


class PerformanceTest(ForwardTestCase):
Expand Down Expand Up @@ -33,9 +34,18 @@ def __init__(self, test_group, mesh, init, time_integrator):
time_integrator : {'split_explicit', 'RK4'}
The time integrator to use for the forward run
"""
name = 'performance_test'
if init.with_inactive_top_cells:
if time_integrator == 'RK4':
self.inactive_top_comp_subdir = os.path.join(
mesh.mesh_name, init.initial_condition, time_integrator,
name)
else:
self.inactive_top_comp_subdir = os.path.join(
mesh.mesh_name, init.initial_condition, name)
name = f'{name}_inactive_top'
super().__init__(test_group=test_group, mesh=mesh, init=init,
time_integrator=time_integrator,
name='performance_test')
time_integrator=time_integrator, name=name)

if mesh.with_ice_shelf_cavities:
this_module = self.__module__
Expand Down Expand Up @@ -74,19 +84,21 @@ def validate(self):
filename1=f'{step_subdir}/output.nc')

if self.init.with_inactive_top_cells:
# construct the work directory for the other test
subdir = get_forward_subdir(self.init.inactive_top_comp_subdir,
self.time_integrator, self.name)
filename2 = os.path.join(self.base_work_dir, self.mpas_core.name,
self.test_group.name, subdir,
filename2 = os.path.join(self.base_work_dir,
self.mpas_core.name,
self.test_group.name,
self.inactive_top_comp_subdir,
'forward/output.nc')
if os.path.exists(filename2):
compare_variables(test_case=self, variables=variables,
filename1='forward/output_crop.nc',
filename2=filename2)
compare_variables(
test_case=self, variables=variables,
filename1=f'{step_subdir}/output_crop.nc',
filename2=filename2,
quiet=False, check_outputs=False,
skip_if_step_not_run=False)
else:
self.logger.warn('The version of "performance_test" without '
'inactive top cells was not run.\n'
self.logger.warn('The version of "performance_test" '
'without inactive top cells was not run. '
'Skipping validation.')

if self.mesh.with_ice_shelf_cavities:
Expand Down

0 comments on commit 84aef87

Please sign in to comment.