Skip to content

Commit

Permalink
Reorganize hurricane mesh test case
Browse files Browse the repository at this point in the history
  • Loading branch information
xylar committed Aug 2, 2022
1 parent 6e2865a commit 0fe4e66
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 53 deletions.
8 changes: 3 additions & 5 deletions compass/ocean/tests/hurricane/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@ def configure_hurricane(test_case, mesh):
mesh : compass.ocean.tests.global_ocean.mesh.Mesh
The test case that produces the mesh for this run
init : compass.ocean.tests.global_ocean.init.Init, optional
The test case that produces the initial condition for this run
"""
config = test_case.config
mesh_step = mesh.mesh_step
config.add_from_package(mesh_step.package, mesh_step.mesh_config_filename,

config.add_from_package('compass.mesh', 'mesh.cfg')
config.add_from_package(mesh.package, mesh.mesh_config_filename,
exception=True)

get_author_and_email_from_git(config)
2 changes: 1 addition & 1 deletion compass/ocean/tests/hurricane/forward/forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(self, test_case, mesh, init, name='forward', subdir=None):
self.add_streams_file(
'compass.ocean.tests.hurricane.forward', 'streams.ocean')

mesh_package = mesh.mesh_step.package
mesh_package = mesh.package
self.add_namelist_file(mesh_package, 'namelist.ocean')

initial_state_target = \
Expand Down
17 changes: 11 additions & 6 deletions compass/ocean/tests/hurricane/mesh/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from compass.testcase import TestCase
from compass.ocean.tests.hurricane.mesh.dequ120at30cr10rr2 \
import DEQU120at30cr10rr2Mesh
import DEQU120at30cr10rr2BaseMesh
from compass.ocean.tests.hurricane.configure import configure_hurricane


class Mesh(TestCase):
Expand Down Expand Up @@ -28,26 +29,30 @@ def __init__(self, test_group, mesh_name):
name = 'mesh'
subdir = '{}/{}'.format(mesh_name, name)
super().__init__(test_group=test_group, name=name, subdir=subdir)

if mesh_name == 'DEQU120at30cr10rr2':
self.mesh_step = DEQU120at30cr10rr2Mesh(
self.mesh_step = DEQU120at30cr10rr2BaseMesh(
self, mesh_name,
preserve_floodplain=False)
mesh_lower = 'dequ120at30cr10rr2'
elif mesh_name == 'DEQU120at30cr10rr2WD':
self.mesh_step = DEQU120at30cr10rr2Mesh(
self.mesh_step = DEQU120at30cr10rr2BaseMesh(
self, mesh_name,
preserve_floodplain=True)
mesh_lower = 'dequ120at30cr10rr2'
else:
raise ValueError(f'Unexpected mesh name {mesh_name}')

self.package = f'compass.ocean.tests.hurricane.mesh.{mesh_lower}'
self.mesh_config_filename = f'{mesh_lower}.cfg'

self.add_step(self.mesh_step)

def configure(self):
"""
Modify the configuration options for this test case
"""
self.config.add_from_package(self.mesh_step.package,
self.mesh_step.mesh_config_filename,
exception=True)
configure_hurricane(test_case=self, mesh=self)

def run(self):
"""
Expand Down
33 changes: 2 additions & 31 deletions compass/ocean/tests/hurricane/mesh/dequ120at30cr10rr2/__init__.py
Original file line number Diff line number Diff line change
@@ -1,41 +1,12 @@
import mpas_tools.ocean.coastal_tools as ct

from compass.ocean.tests.global_ocean.mesh.mesh import MeshStep
from compass.ocean.mesh.floodplain_mesh import FloodplainMeshStep


class DEQU120at30cr10rr2Mesh(MeshStep):
class DEQU120at30cr10rr2BaseMesh(FloodplainMeshStep):
"""
A step for creating DEQU120at30cr10rr2 meshes
"""
def __init__(self, test_case, mesh_name, preserve_floodplain):
"""
Create a new step
Parameters
----------
test_case : compass.TestCase
The test case this step belongs to
mesh_name : str
The name of the mesh
preserve_floodplain : bool
Whether the mesh includes land cells
"""

with_ice_shelf_cavities = False

super().__init__(test_case, mesh_name, with_ice_shelf_cavities,
package=self.__module__,
mesh_config_filename='dequ120at30cr10rr2.cfg',
do_inject_bathymetry=True,
preserve_floodplain=preserve_floodplain)

self.add_input_file(
filename='earth_relief_15s.nc',
target='SRTM15_plus_earth_relief_15s.nc',
database='bathymetry_database')

def build_cell_width_lat_lon(self):
"""
Create cell width array for this mesh on a regular latitude-longitude
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
# options for global ocean testcases
[global_ocean]
# options for spherical meshes
[spherical_mesh]

## config options related to the mesh step
## config options related to the step for culling land from the mesh
# number of cores to use
mesh_cores = 1
cull_mesh_cores = 18
# minimum of cores, below which the step fails
mesh_min_cores = 1
cull_mesh_min_cores = 1
# maximum memory usage allowed (in MB)
cull_mesh_max_memory = 1000

# Elevation threshold to use for including land cells
floodplain_elevation = 10.0


# options for global ocean testcases
[global_ocean]

# The following options are detected from .gitconfig if not explicitly entered
author = autodetect
email = autodetect

# Elevation threshold to use for including land cells
floodplain_elevation = 10.0


# options for hurricane testcases
[hurricane]
Expand All @@ -22,11 +28,11 @@ floodplain_elevation = 10.0
# number of cores to use
init_cores = 36
# minimum of cores, below which the step fails
init_min_cores = 8
init_min_cores = 8
# maximum memory usage allowed (in MB)
init_max_memory = 1000
# number of threads
init_threads = 1
init_threads = 1

## config options related to the forward steps
# number of cores to use
Expand Down

0 comments on commit 0fe4e66

Please sign in to comment.