From e0ba5f08fbc0b499d8de4ddb923a715cb7a665dd Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Wed, 12 Jul 2023 07:51:54 -0700 Subject: [PATCH] Add decomp test to the drying slope case --- compass/ocean/suites/wetdry.txt | 2 + compass/ocean/tests/drying_slope/__init__.py | 4 + .../tests/drying_slope/decomp/__init__.py | 84 +++++++++++++++++++ .../ocean/tests/drying_slope/streams.forward | 1 + docs/developers_guide/ocean/api.rst | 4 + .../ocean/test_groups/drying_slope.rst | 15 ++++ .../ocean/test_groups/drying_slope.rst | 10 +++ 7 files changed, 120 insertions(+) create mode 100644 compass/ocean/tests/drying_slope/decomp/__init__.py diff --git a/compass/ocean/suites/wetdry.txt b/compass/ocean/suites/wetdry.txt index 31bdf04734..42169c7f29 100644 --- a/compass/ocean/suites/wetdry.txt +++ b/compass/ocean/suites/wetdry.txt @@ -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 diff --git a/compass/ocean/tests/drying_slope/__init__.py b/compass/ocean/tests/drying_slope/__init__.py index 3ff3a17d72..75b0cd8c3e 100644 --- a/compass/ocean/tests/drying_slope/__init__.py +++ b/compass/ocean/tests/drying_slope/__init__.py @@ -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 @@ -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)) diff --git a/compass/ocean/tests/drying_slope/decomp/__init__.py b/compass/ocean/tests/drying_slope/decomp/__init__.py new file mode 100644 index 0000000000..aa969f4cd5 --- /dev/null +++ b/compass/ocean/tests/drying_slope/decomp/__init__.py @@ -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') diff --git a/compass/ocean/tests/drying_slope/streams.forward b/compass/ocean/tests/drying_slope/streams.forward index a9c861ff35..c29be24374 100644 --- a/compass/ocean/tests/drying_slope/streams.forward +++ b/compass/ocean/tests/drying_slope/streams.forward @@ -30,6 +30,7 @@ + diff --git a/docs/developers_guide/ocean/api.rst b/docs/developers_guide/ocean/api.rst index baf545f4d5..653ea00bd2 100644 --- a/docs/developers_guide/ocean/api.rst +++ b/docs/developers_guide/ocean/api.rst @@ -87,6 +87,10 @@ drying_slope DryingSlope + decomp.Decomp + decomp.Decomp.configure + decomp.Decomp.validate + default.Default default.Default.configure default.Default.validate diff --git a/docs/developers_guide/ocean/test_groups/drying_slope.rst b/docs/developers_guide/ocean/test_groups/drying_slope.rst index 2c8247ebdc..5b58fbdbba 100644 --- a/docs/developers_guide/ocean/test_groups/drying_slope.rst +++ b/docs/developers_guide/ocean/test_groups/drying_slope.rst @@ -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 diff --git a/docs/users_guide/ocean/test_groups/drying_slope.rst b/docs/users_guide/ocean/test_groups/drying_slope.rst index f9b5f11b1a..37c40b12f5 100644 --- a/docs/users_guide/ocean/test_groups/drying_slope.rst +++ b/docs/users_guide/ocean/test_groups/drying_slope.rst @@ -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 ----