diff --git a/compass/ocean/tests/global_ocean/forward.py b/compass/ocean/tests/global_ocean/forward.py index 271b1ffae9..685d515cc5 100644 --- a/compass/ocean/tests/global_ocean/forward.py +++ b/compass/ocean/tests/global_ocean/forward.py @@ -7,6 +7,7 @@ from compass.model import run_model from compass.testcase import TestCase from compass.step import Step +from compass.ocean.inactive_top_cells import remove_inactive_top_cells_output class ForwardStep(Step): @@ -121,6 +122,9 @@ def __init__(self, test_case, mesh, init, time_integrator, name='forward', self.add_output_file(filename='output.nc') + if self.init.with_inactive_top_cells: + self.add_output_file(filename='output_crop.nc') + def setup(self): """ Set up the test case in the work directory, including downloading any @@ -141,10 +145,15 @@ def run(self): Run this step of the testcase """ run_model(self) + + if self.init.with_inactive_top_cells: + remove_inactive_top_cells_output(in_filename='output.nc', + out_filename='output_crop.nc', + mesh_filename='init.nc') + add_mesh_and_init_metadata(self.outputs, self.config, init_filename='init.nc') - class ForwardTestCase(TestCase): """ A parent class for test cases for forward runs with global MPAS-Ocean mesh diff --git a/compass/ocean/tests/global_ocean/performance_test/__init__.py b/compass/ocean/tests/global_ocean/performance_test/__init__.py index 78ddb3f5a8..85f1f14c18 100644 --- a/compass/ocean/tests/global_ocean/performance_test/__init__.py +++ b/compass/ocean/tests/global_ocean/performance_test/__init__.py @@ -1,7 +1,8 @@ +import os + from compass.validate import compare_variables, compare_timers from compass.ocean.tests.global_ocean.forward import ForwardTestCase, \ - ForwardStep -from compass.ocean.inactive_top_cells import remove_inactive_top_cells_output + ForwardStep, get_forward_subdir class PerformanceTest(ForwardTestCase): @@ -62,17 +63,21 @@ def validate(self): compare_variables(test_case=self, variables=variables, filename1='forward/output.nc') - if self.config.has_option('vertical_grid', 'inactive_top_cells'): - offset = self.config.getint('vertical_grid', 'inactive_top_cells') - if offset > 0: - remove_inactive_top_cells_output('forward/output.nc', - inactive_top_cells=offset) - variables = ['temperature', 'salinity', 'layerThickness', - 'normalVelocity'] - compare_variables(test_case=self, variables=variables, - filename1='forward/output_crop.nc', - filename2='forward/output_comp.nc', - quiet=False, check_outputs=False) + 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, + 'forward/output.nc') + + variables = ['temperature', 'salinity', 'layerThickness', + 'normalVelocity'] + compare_variables(test_case=self, variables=variables, + filename1='forward/output_crop.nc', + filename2=filename2, + quiet=False, check_outputs=False, + skip_if_step_not_run=False) if self.mesh.with_ice_shelf_cavities: variables = [