Skip to content

Commit acc78b6

Browse files
committed
Add standalone test for creating wave mesh from existing ocean mesh
1 parent 66bb5c9 commit acc78b6

File tree

5 files changed

+40
-19
lines changed

5 files changed

+40
-19
lines changed

compass/ocean/tests/global_ocean/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ def __init__(self, mpas_core):
6363
# A test case for making E3SM support files from an existing mesh
6464
self.add_test_case(FilesForE3SM(test_group=self))
6565

66-
# Create waves mesh
66+
# Test cases for creating waves mesh
67+
self.add_test_case(WaveMesh(test_group=self))
6768
self._add_tests(mesh_names=['Icos'], include_wave_mesh=True)
6869

6970
def _add_tests(self, mesh_names, high_res_topography=True,

compass/ocean/tests/global_ocean/wave_mesh/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class WaveMesh(TestCase):
2727
Attributes
2828
----------
2929
"""
30-
def __init__(self, test_group, ocean_mesh, ocean_init):
30+
def __init__(self, test_group, ocean_mesh=None, ocean_init=None):
3131
"""
3232
Create test case for creating a global MPAS-Ocean mesh
3333
@@ -38,7 +38,11 @@ def __init__(self, test_group, ocean_mesh, ocean_init):
3838
3939
"""
4040
name = 'wave_mesh'
41-
subdir = f'{ocean_mesh.mesh_name}/{name}'
41+
if ocean_mesh is not None:
42+
subdir = f'{ocean_mesh.mesh_name}/{name}'
43+
else:
44+
subdir = name
45+
4246
super().__init__(test_group=test_group, name=name, subdir=subdir)
4347

4448
self.package = 'compass.ocean.tests.global_ocean.wave_mesh'

compass/ocean/tests/global_ocean/wave_mesh/base_mesh.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,32 @@ def setup(self):
3232
self.opts.init_file = 'init.msh'
3333

3434
# Set links to base mesh
35-
if self.config.has_option('wave_mesh', 'ocean_base_mesh'):
36-
ocean_base_mesh_path = self.config.get('wave_mesh',
37-
'ocean_base_mesh')
38-
else:
35+
if self.ocean_base_mesh is not None:
3936
mesh_path = self.ocean_base_mesh.steps['base_mesh'].path
4037
ocean_base_mesh_path = f'{mesh_path}/base_mesh.nc'
38+
else:
39+
if self.config.has_option('wave_mesh', 'ocean_base_mesh'):
40+
ocean_base_mesh_path = self.config.get('wave_mesh',
41+
'ocean_base_mesh')
42+
else:
43+
raise ValueError('ocean_base_mesh option required '
44+
'in wave_mesh section in cfg file')
4145

4246
self.add_input_file(
4347
filename='ocean_base_mesh.nc',
4448
work_dir_target=ocean_base_mesh_path)
4549

4650
# Set links to culled mesh
47-
if self.config.has_option('wave_mesh', 'ocean_culled_mesh'):
48-
ocean_culled_mesh_path = self.config.get('wave_mesh',
49-
'ocean_culled_mesh')
50-
else:
51+
if self.ocean_culled_mesh is not None:
5152
mesh_path = self.ocean_culled_mesh.steps['initial_state'].path
5253
ocean_culled_mesh_path = f'{mesh_path}/initial_state.nc'
54+
else:
55+
if self.config.has_option('wave_mesh', 'ocean_culled_mesh'):
56+
ocean_culled_mesh_path = self.config.get('wave_mesh',
57+
'ocean_culled_mesh')
58+
else:
59+
raise ValueError('ocean_culled_mesh option required '
60+
'in wave_mesh section in cfg file')
5361

5462
self.add_input_file(
5563
filename='ocean_culled_mesh.nc',

compass/ocean/tests/global_ocean/wave_mesh/cull_mesh.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,16 @@ def setup(self):
2626

2727
super().setup()
2828

29-
if self.config.has_option('wave_mesh', 'ocean_culled_mesh'):
30-
culled_mesh_path = self.config.get('wave_mesh',
31-
'ocean_culled_mesh')
32-
else:
29+
if self.ocean_mesh is not None:
3330
mesh_path = self.ocean_mesh.steps['initial_state'].path
3431
culled_mesh_path = f'{mesh_path}/initial_state.nc'
32+
else:
33+
if self.config.has_option('wave_mesh', 'ocean_culled_mesh'):
34+
culled_mesh_path = self.config.get('wave_mesh',
35+
'ocean_culled_mesh')
36+
else:
37+
raise ValueError('ocean_culled_mesh option required '
38+
'in wave_mesh section in cfg file')
3539

3640
self.add_input_file(
3741
filename='ocean_culled_mesh.nc',

compass/ocean/tests/global_ocean/wave_mesh/scrip_file.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,16 @@ def setup(self):
2727

2828
super().setup()
2929

30-
if self.config.has_option('wave_mesh', 'ocean_culled_mesh'):
31-
ocean_mesh_path = self.config.get('wave_mesh',
32-
'ocean_culled_mesh')
33-
else:
30+
if self.ocean_mesh is not None:
3431
mesh_path = self.ocean_mesh.steps['initial_state'].path
3532
ocean_mesh_path = f'{mesh_path}/initial_state.nc'
33+
else:
34+
if self.config.has_option('wave_mesh', 'ocean_culled_mesh'):
35+
ocean_mesh_path = self.config.get('wave_mesh',
36+
'ocean_culled_mesh')
37+
else:
38+
raise ValueError('ocean_culled_mesh option required '
39+
'in wave_mesh section in cfg file')
3640

3741
self.add_input_file(
3842
filename='ocean_mesh.nc',

0 commit comments

Comments
 (0)