Skip to content

Commit

Permalink
Merge pull request #620 from cbegeman/ocn-add-wetting-drying-ramp-tests
Browse files Browse the repository at this point in the history
Add ocean wetting-and-drying ramp tests

This PR is for testing the wetting-and-drying ramp feature introduced in E3SM-Project/E3SM#5590
  • Loading branch information
cbegeman authored Jun 1, 2023
2 parents dbb6766 + ec0d40c commit 4952914
Show file tree
Hide file tree
Showing 12 changed files with 246 additions and 14 deletions.
2 changes: 1 addition & 1 deletion E3SM-Project
Submodule E3SM-Project updated 35 files
+15 −0 cime_config/allactive/config_compsets.xml
+6 −6 cime_config/allactive/config_pesall.xml
+1 −0 cime_config/config_files.xml
+14 −0 cime_config/machines/Depends.pm-cpu.intel.cmake
+49 −0 cime_config/machines/cmake_macros/intel_pm-cpu.cmake
+13 −3 cime_config/machines/config_machines.xml
+3 −1 cime_config/testmods_dirs/allactive/wcprodssp/user_nl_eam
+2 −1 cime_config/tests.py
+1 −0 components/data_comps/datm/cime_config/config_component.xml
+3 −3 components/data_comps/datm/cime_config/namelist_definition_datm.xml
+25 −10 components/eam/cime_config/config_pes.xml
+5 −0 components/eam/src/chemistry/mozart/chemistry.F90
+24 −9 components/eam/src/chemistry/mozart/mo_chm_diags.F90
+1 −0 components/eam/src/chemistry/mozart/mo_gas_phase_chemdr.F90
+34 −15 components/eam/src/physics/cam/tropopause.F90
+2 −2 components/elm/cime_config/config_pes.xml
+1 −0 components/mpas-ocean/bld/build-namelist
+1 −0 components/mpas-ocean/bld/build-namelist-section
+1 −0 components/mpas-ocean/bld/namelist_files/namelist_defaults_mpaso.xml
+8 −0 components/mpas-ocean/bld/namelist_files/namelist_definition_mpaso.xml
+2 −2 components/mpas-ocean/cime_config/config_pes.xml
+5 −0 components/mpas-ocean/cime_config/testdefs/testmods_dirs/mpaso/harmonic_mean_drag/README
+1 −0 components/mpas-ocean/cime_config/testdefs/testmods_dirs/mpaso/harmonic_mean_drag/user_nl_mpaso
+23 −2 components/mpas-ocean/src/Registry.xml
+1 −1 components/mpas-ocean/src/mode_forward/mpas_ocn_time_integration.F
+47 −1 components/mpas-ocean/src/mode_forward/mpas_ocn_time_integration_rk4.F
+93 −13 components/mpas-ocean/src/shared/mpas_ocn_diagnostics.F
+6 −0 components/mpas-ocean/src/shared/mpas_ocn_diagnostics_variables.F
+1 −0 components/mpas-ocean/src/shared/mpas_ocn_tendency.F
+4 −2 components/mpas-ocean/src/shared/mpas_ocn_vel_forcing.F
+4 −4 components/mpas-ocean/src/shared/mpas_ocn_vel_forcing_explicit_bottom_drag.F
+91 −41 components/mpas-ocean/src/shared/mpas_ocn_vmix.F
+40 −16 components/mpas-ocean/src/shared/mpas_ocn_wetting_drying.F
+2 −2 components/mpas-seaice/cime_config/config_pes.xml
+2 −0 components/mpas-seaice/cime_config/testdefs/testmods_dirs/mpassi/jra_1958/shell_commands
6 changes: 6 additions & 0 deletions compass/ocean/suites/wetdry.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
ocean/drying_slope/250m/sigma/default
ocean/drying_slope/250m/sigma/ramp
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/single_layer/default
ocean/drying_slope/1km/single_layer/ramp
ocean/dam_break/40cm/default
ocean/dam_break/40cm/ramp
ocean/dam_break/120cm/default
ocean/dam_break/120cm/ramp
ocean/isomip_plus/planar/5km/sigma/thin_film_drying_Ocean0
ocean/isomip_plus/planar/5km/sigma/thin_film_wetting_Ocean0
ocean/isomip_plus/planar/5km/single_layer/thin_film_tidal_forcing_Ocean0
10 changes: 6 additions & 4 deletions compass/ocean/tests/dam_break/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from compass.testgroup import TestGroup
from compass.ocean.tests.dam_break.default import Default
from compass.ocean.tests.dam_break.ramp import Ramp
from compass.testgroup import TestGroup


class DamBreak(TestGroup):
Expand All @@ -15,6 +16,7 @@ def __init__(self, mpas_core):
super().__init__(mpas_core=mpas_core, name='dam_break')

for resolution in [0.04, 0.12]:
for coord_type in ['sigma']:
self.add_test_case(
Default(test_group=self, resolution=resolution))
self.add_test_case(
Default(test_group=self, resolution=resolution))
self.add_test_case(
Ramp(test_group=self, resolution=resolution))
82 changes: 82 additions & 0 deletions compass/ocean/tests/dam_break/ramp/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
from math import floor

from compass.ocean.tests.dam_break.forward import Forward
from compass.ocean.tests.dam_break.initial_state import InitialState
from compass.ocean.tests.dam_break.viz import Viz
from compass.testcase import TestCase
from compass.validate import compare_variables


class Ramp(TestCase):
"""
The default dam_break test case
Attributes
----------
resolution : float
The resolution of the test case in km
"""

def __init__(self, test_group, resolution):
"""
Create the test case
Parameters
----------
test_group : compass.ocean.tests.dam_break.DamBreak
The test group that this test case belongs to
resolution : float
The resolution of the test case in m
"""
name = 'ramp'

self.resolution = resolution
if resolution < 1.:
res_name = f'{int(resolution*1e3)}cm'
else:
res_name = f'{int(resolution)}m'
min_tasks = int(40 / (resolution / 0.04)**2)
ntasks = 10 * min_tasks
subdir = f'{res_name}/{name}'
super().__init__(test_group=test_group, name=name,
subdir=subdir)

self.add_step(InitialState(test_case=self))
forward_step = Forward(test_case=self, resolution=resolution,
ntasks=ntasks, min_tasks=min_tasks,
openmp_threads=1)
forward_step.add_namelist_options({'config_zero_drying_velocity_ramp':
".true."})
self.add_step(forward_step)
self.add_step(Viz(test_case=self))

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

resolution = self.resolution
config = self.config
dc = resolution # cell width in m
dx = 13 # width of the domain in m
dy = 28 # length of the domain in m
nx = round(dx / dc)
ny = int(2 * floor(dy / (2 * dc))) # guarantee that ny is even

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

def validate(self):
"""
Validate variables against a baseline
"""
variables = ['layerThickness', 'normalVelocity', 'ssh']
compare_variables(test_case=self, variables=variables,
filename1='forward/output.nc')
8 changes: 6 additions & 2 deletions compass/ocean/tests/drying_slope/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from compass.testgroup import TestGroup
from compass.ocean.tests.drying_slope.default import Default
from compass.ocean.tests.drying_slope.ramp import Ramp
from compass.testgroup import TestGroup


class DryingSlope(TestGroup):
Expand All @@ -14,8 +15,11 @@ def __init__(self, mpas_core):
"""
super().__init__(mpas_core=mpas_core, name='drying_slope')

for resolution in [0.25, 1]:
for resolution in [0.25, 1.]:
for coord_type in ['sigma', 'single_layer']:
self.add_test_case(
Default(test_group=self, resolution=resolution,
coord_type=coord_type))
self.add_test_case(
Ramp(test_group=self, resolution=resolution,
coord_type=coord_type))
3 changes: 3 additions & 0 deletions compass/ocean/tests/drying_slope/forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ def __init__(self, test_case, resolution, name='forward', subdir=None,
damping_coeff: float, optional
the value of the rayleigh damping coefficient
coord_type: string, optional
the coordinate type
"""
if min_tasks is None:
min_tasks = ntasks
Expand Down
99 changes: 99 additions & 0 deletions compass/ocean/tests/drying_slope/ramp/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
from compass.ocean.tests.drying_slope.forward import Forward
from compass.ocean.tests.drying_slope.initial_state import InitialState
from compass.ocean.tests.drying_slope.viz import Viz
from compass.testcase import TestCase
from compass.validate import compare_variables


class Ramp(TestCase):
"""
The default drying_slope test case
Attributes
----------
resolution : float
The resolution of the test case in km
coord_type : str
The type of vertical coordinate (``sigma``, ``single_layer``, etc.)
"""

def __init__(self, test_group, resolution, coord_type):
"""
Create the test case
Parameters
----------
test_group : compass.ocean.tests.drying_slope.DryingSlope
The test group that this test case belongs to
resolution : float
The resolution of the test case in km
coord_type : str
The type of vertical coordinate (``sigma``, ``single_layer``)
"""
name = 'ramp'

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':
forward_step = Forward(test_case=self, resolution=resolution,
ntasks=4, openmp_threads=1,
coord_type=coord_type)
damping_coeffs = None
forward_step.add_namelist_options(
{'config_zero_drying_velocity_ramp': ".true."})
self.add_step(forward_step)
else:
damping_coeffs = [0.0025, 0.01]
for damping_coeff in damping_coeffs:
forward_step = Forward(test_case=self, resolution=resolution,
ntasks=4, openmp_threads=1,
damping_coeff=damping_coeff,
coord_type=coord_type)
forward_step.add_namelist_options(
{'config_zero_drying_velocity_ramp': ".true."})
self.add_step(forward_step)
self.damping_coeffs = damping_coeffs
self.add_step(Viz(test_case=self, damping_coeffs=damping_coeffs))

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')

def validate(self):
"""
Validate variables against a baseline
"""
damping_coeffs = self.damping_coeffs
variables = ['layerThickness', 'normalVelocity']
if damping_coeffs is not None:
for damping_coeff in damping_coeffs:
compare_variables(test_case=self, variables=variables,
filename1=f'forward_{damping_coeff}/'
'output.nc')
else:
compare_variables(test_case=self, variables=variables,
filename1='forward/output.nc')
1 change: 0 additions & 1 deletion compass/ocean/tests/drying_slope/streams.forward
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
clobber_mode="truncate">

<stream name="mesh"/>
<var_struct name="tracers"/>
<var name="layerThickness"/>
<var name="ssh"/>
<var name="normalVelocity"/>
Expand Down
10 changes: 10 additions & 0 deletions docs/developers_guide/ocean/test_groups/dam_break.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,13 @@ test performs one 10-minute run on 40 cores. It doesn't contain any
is configured to have a 1 m by 1 m dammed region matching the experimental
setup and a ~12 m by ~12 m flood plain to minimize reflections off the
boundaries.


.. _dev_ocean_dam_break_ramp:

ramp
----

The :py:class:`compass.ocean.tests.dam_break.ramp.Ramp` is identical to the
default class except it sets ``ramp`` to ``True`` for the forward step to enable
the ramp feature for wetting and drying.
10 changes: 10 additions & 0 deletions docs/developers_guide/ocean/test_groups/drying_slope.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,13 @@ types are supported. For ``sigma`` coordinates, this case is hard-coded to run
two cases at different values of ``config_Rayleigh_damping_coeff``, 0.0025 and
0.01, for which there is comparison data. The ``single_layer`` case runs at one
value of the explicit bottom drag coefficient.


.. _dev_ocean_drying_slope_ramp:

ramp
----

The :py:class:`compass.ocean.tests.drying_slope.ramp.Ramp` is identical to the
default class except it sets ``ramp`` to ``True`` for the forward step to enable
the ramp feature for wetting and drying.
12 changes: 10 additions & 2 deletions docs/users_guide/ocean/test_groups/dam_break.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ The config options for this test case are:
default
-------

``ocean/dam_break/40cm/default`` is the default version of the dam break
``ocean/dam_break/${RES}/default`` is the default version of the dam break
test case for validation of sea surface height through visual inspection
against experimental data and ROMS solutions.
against experimental data and ROMS solutions. ``RES`` is either 40cm or 120cm.

ramp
----

``ocean/dam_break/${RES}/ramp`` is identical to the ``default`` test except
the factor that scales velocities and velocity tendencies is ramped over a
given layer thickness range rather than a binary switch at the minimum
thickness. ``RES`` is either 40cm or 120cm.
17 changes: 13 additions & 4 deletions docs/users_guide/ocean/test_groups/drying_slope.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,16 @@ All units are mks.
default
-------

``ocean/drying_slope/1km/default`` is the default version of the drying slope
test case for two short (12h) test runs with two different drag coefficients
and validation of sea surface height through visual inspection against analytic
and ROMS solutions.
``ocean/drying_slope/${RES}/${COORD}/default`` is the default version of the
drying slope test case for two short (12h) test runs with two different drag
coefficients and validation of sea surface height through visual inspection
against analytic and ROMS solutions. ``RES`` is either 250m or 1km. ``COORD`` is either ``single_layer`` or ``sigma``.

ramp
----

``ocean/drying_slope/${RES}/${COORD}/ramp`` is identical to the ``default``
test except the factor that scales velocities and velocity tendencies is
ramped over a given layer thickness range rather than a binary switch at the
minimum thickness. ``RES`` is either 250m or 1km. ``COORD`` is either
``single_layer`` or ``sigma``.

0 comments on commit 4952914

Please sign in to comment.