Skip to content

Commit

Permalink
Update performance test
Browse files Browse the repository at this point in the history
Move cropping of inactive top cells to ForwardStep so it is
explicitly included as an output of that step.

Give `init.nc` as the mesh file for cropping.

For validation, point to the output file from the version of the
performance test without inactive top cells for `filename2`.
  • Loading branch information
xylar committed Aug 3, 2021
1 parent 13ce4a4 commit b43d8cf
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 14 deletions.
11 changes: 10 additions & 1 deletion compass/ocean/tests/global_ocean/forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
31 changes: 18 additions & 13 deletions compass/ocean/tests/global_ocean/performance_test/__init__.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -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 = [
Expand Down

0 comments on commit b43d8cf

Please sign in to comment.