Skip to content

Commit

Permalink
Merge pull request #695 from cbegeman/ocn-add-drying-slope-decomp-test
Browse files Browse the repository at this point in the history
Add decomp test case to the drying slope test group
  • Loading branch information
cbegeman authored Oct 16, 2023
2 parents bf035ca + e0ba5f0 commit ddbe352
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 0 deletions.
2 changes: 2 additions & 0 deletions compass/ocean/suites/wetdry.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ ocean/drying_slope/250m/single_layer/default
ocean/drying_slope/250m/single_layer/ramp
ocean/drying_slope/1km/sigma/default
ocean/drying_slope/1km/sigma/ramp
ocean/drying_slope/1km/sigma/decomp
ocean/drying_slope/1km/single_layer/default
ocean/drying_slope/1km/single_layer/ramp
ocean/drying_slope/1km/single_layer/decomp
ocean/dam_break/40cm/default
ocean/dam_break/40cm/ramp
ocean/dam_break/120cm/default
Expand Down
4 changes: 4 additions & 0 deletions compass/ocean/tests/drying_slope/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from compass.ocean.tests.drying_slope.decomp import Decomp
from compass.ocean.tests.drying_slope.default import Default
from compass.ocean.tests.drying_slope.loglaw import LogLaw
from compass.ocean.tests.drying_slope.ramp import Ramp
Expand All @@ -21,6 +22,9 @@ def __init__(self, mpas_core):
self.add_test_case(
Default(test_group=self, resolution=resolution,
coord_type=coord_type))
self.add_test_case(
Decomp(test_group=self, resolution=resolution,
coord_type=coord_type))
self.add_test_case(
Ramp(test_group=self, resolution=resolution,
coord_type=coord_type))
Expand Down
84 changes: 84 additions & 0 deletions compass/ocean/tests/drying_slope/decomp/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
from compass.ocean.tests import drying_slope
from compass.ocean.tests.drying_slope.forward import Forward
from compass.ocean.tests.drying_slope.initial_state import InitialState
from compass.testcase import TestCase
from compass.validate import compare_variables


class Decomp(TestCase):
"""
A decomposition test case for the baroclinic channel test group, which
makes sure the model produces identical results on 1 and 12 cores.
Attributes
----------
resolution : str
The resolution of the test case
"""

def __init__(self, test_group, resolution, coord_type):
"""
Create the test case
Parameters
----------
test_group : compass.ocean.tests.baroclinic_channel.BaroclinicChannel
The test group that this test case belongs to
resolution : str
The resolution of the test case
"""
name = 'decomp'
self.resolution = resolution
self.coord_type = coord_type
if resolution < 1.:
res_name = f'{int(resolution*1e3)}m'
else:
res_name = f'{int(resolution)}km'
subdir = f'{res_name}/{coord_type}/{name}'
super().__init__(test_group=test_group, name=name,
subdir=subdir)

self.add_step(InitialState(test_case=self, coord_type=coord_type))
if coord_type == 'single_layer':
damping_coeff = None
else:
damping_coeff = 0.01
for procs in [1, 12]:
name = '{}proc'.format(procs)
forward_step = Forward(test_case=self, name=name, subdir=name,
resolution=resolution,
ntasks=procs, openmp_threads=1,
damping_coeff=damping_coeff,
coord_type=coord_type)
self.add_step(forward_step)

def configure(self):
"""
Modify the configuration options for this test case.
"""

resolution = self.resolution
config = self.config
ny = round(28 / resolution)
if resolution < 1.:
ny += 2
dc = 1e3 * resolution

config.set('drying_slope', 'ny', f'{ny}', comment='the number of '
'mesh cells in the y direction')
config.set('drying_slope', 'dc', f'{dc}', comment='the distance '
'between adjacent cell centers')

# no run() method is needed

def validate(self):
"""
Test cases can override this method to perform validation of variables
and timers
"""
variables = ['temperature', 'salinity', 'layerThickness',
'normalVelocity']
compare_variables(test_case=self, variables=variables,
filename1='1proc/output.nc',
filename2='12proc/output.nc')
1 change: 1 addition & 0 deletions compass/ocean/tests/drying_slope/streams.forward
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

<stream name="mesh"/>
<var name="layerThickness"/>
<var_struct name="tracers"/>
<var name="ssh"/>
<var name="normalVelocity"/>
<var name="xtime"/>
Expand Down
4 changes: 4 additions & 0 deletions docs/developers_guide/ocean/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ drying_slope

DryingSlope

decomp.Decomp
decomp.Decomp.configure
decomp.Decomp.validate

default.Default
default.Default.configure
default.Default.validate
Expand Down
15 changes: 15 additions & 0 deletions docs/developers_guide/ocean/test_groups/drying_slope.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,21 @@ two cases at different values of ``config_Rayleigh_damping_coeff``, 0.0025 and
value of the implicit bottom drag coefficient.


.. _dev_ocean_drying_slope_decomp:

decomp
------

The :py:class:`compass.ocean.tests.drying_slope.decomp.Decomp`
test performs two 12-hour runs on 1 and 12 cores, respectively.
:ref:`dev_validation` is performed by comparing the output of the two runs.
This class accepts resolution and coordinate type ``coord_type`` as arguments.
Both ``sigma`` and ``single_layer`` coordinate types are supported. For
``sigma`` coordinates, this case is hard-coded to run with
``config_Rayleigh_damping_coeff`` equal to 0.01. The ``single_layer`` case
runs at one value of the implicit bottom drag coefficient.


.. _dev_ocean_drying_slope_ramp:

ramp
Expand Down
10 changes: 10 additions & 0 deletions docs/users_guide/ocean/test_groups/drying_slope.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ against analytic and ROMS solutions. ``RES`` is either 250m or 1km. ``COORD``
is either ``single_layer`` or ``sigma``. Rayleigh drag is not compatible with
``single_layer`` so implicit drag with a constant coefficient is used.

decomp
------

``ocean/drying_slope/${RES}/${COORD}/decomp`` is identical to the default version
of the drying slope test case except it is run twice, on 1 processor and 12
processors and the results of each are compared. ``RES`` is either 250m or 1km.
``COORD`` is either ``single_layer`` or ``sigma``. The ``sigma`` case uses a
Rayleigh drag coefficient of 0.01. Rayleigh drag is not compatible with
``single_layer`` so implicit drag with a constant coefficient is used.

ramp
----

Expand Down

0 comments on commit ddbe352

Please sign in to comment.