Skip to content

Commit c9a3176

Browse files
committed
Add cached meshes and ICs to global_ocean
For most supported meshes (except SOwISC12to60) and for the PHC initial condition, this merge adds "cached" versions of each mesh, init and performance_test test case. QU*240 meshes also have restart, decomposition and thread tests. The steps of each "cached" test case use files from a new database, "compass_cache", that has the same directory structure as the non-cached test cases, e.g.: global_ocean/QU240/mesh/mesh global_ocean/QU240/PHC/init/initial_state The mesh and init test cases are just stubs that create the expected symlinks and cause the cached files to be downloaded during setup if needed.
1 parent d936485 commit c9a3176

File tree

11 files changed

+210
-38
lines changed

11 files changed

+210
-38
lines changed

compass/ocean/cached_files.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"ocean/global_ocean/cached/QU240/mesh/mesh/culled_mesh.nc": "global_ocean/QU240/mesh/mesh/culled_mesh.210727.nc",
3+
"ocean/global_ocean/cached/QU240/mesh/mesh/culled_graph.info": "global_ocean/QU240/mesh/mesh/culled_graph.210727.info",
4+
"ocean/global_ocean/cached/QU240/mesh/mesh/critical_passages_mask_final.nc": "global_ocean/QU240/mesh/mesh/critical_passages_mask_final.210727.nc",
5+
"ocean/global_ocean/cached/QU240/PHC/init/initial_state/initial_state.nc": "global_ocean/QU240/PHC/init/initial_state/initial_state.210727.nc",
6+
"ocean/global_ocean/cached/QU240/PHC/init/initial_state/init_mode_forcing_data.nc": "global_ocean/QU240/PHC/init/initial_state/init_mode_forcing_data.210727.nc",
7+
"ocean/global_ocean/cached/EC30to60/mesh/mesh/culled_mesh.nc": "global_ocean/EC30to60/mesh/mesh/culled_mesh.210727.nc",
8+
"ocean/global_ocean/cached/EC30to60/mesh/mesh/culled_graph.info": "global_ocean/EC30to60/mesh/mesh/culled_graph.210727.info",
9+
"ocean/global_ocean/cached/EC30to60/mesh/mesh/critical_passages_mask_final.nc": "global_ocean/EC30to60/mesh/mesh/critical_passages_mask_final.210727.nc",
10+
"ocean/global_ocean/cached/EC30to60/PHC/init/initial_state/initial_state.nc": "global_ocean/EC30to60/PHC/init/initial_state/initial_state.210727.nc",
11+
"ocean/global_ocean/cached/EC30to60/PHC/init/initial_state/init_mode_forcing_data.nc": "global_ocean/EC30to60/PHC/init/initial_state/init_mode_forcing_data.210727.nc",
12+
"ocean/global_ocean/cached/WC14/mesh/mesh/culled_mesh.nc": "global_ocean/WC14/mesh/mesh/culled_mesh.210727.nc",
13+
"ocean/global_ocean/cached/WC14/mesh/mesh/culled_graph.info": "global_ocean/WC14/mesh/mesh/culled_graph.210727.info",
14+
"ocean/global_ocean/cached/WC14/mesh/mesh/critical_passages_mask_final.nc": "global_ocean/WC14/mesh/mesh/critical_passages_mask_final.210727.nc",
15+
"ocean/global_ocean/cached/WC14/PHC/init/initial_state/initial_state.nc": "global_ocean/WC14/PHC/init/initial_state/initial_state.210727.nc",
16+
"ocean/global_ocean/cached/WC14/PHC/init/initial_state/init_mode_forcing_data.nc": "global_ocean/WC14/PHC/init/initial_state/init_mode_forcing_data.210727.nc",
17+
"ocean/global_ocean/cached/QUwISC240/mesh/mesh/culled_mesh.nc": "global_ocean/QUwISC240/mesh/mesh/culled_mesh.210727.nc",
18+
"ocean/global_ocean/cached/QUwISC240/mesh/mesh/culled_graph.info": "global_ocean/QUwISC240/mesh/mesh/culled_graph.210727.info",
19+
"ocean/global_ocean/cached/QUwISC240/mesh/mesh/critical_passages_mask_final.nc": "global_ocean/QUwISC240/mesh/mesh/critical_passages_mask_final.210727.nc",
20+
"ocean/global_ocean/cached/QUwISC240/PHC/init/initial_state/initial_state.nc": "global_ocean/QUwISC240/PHC/init/initial_state/initial_state.210727.nc",
21+
"ocean/global_ocean/cached/QUwISC240/PHC/init/initial_state/init_mode_forcing_data.nc": "global_ocean/QUwISC240/PHC/init/initial_state/init_mode_forcing_data.210727.nc",
22+
"ocean/global_ocean/cached/QUwISC240/PHC/init/ssh_adjustment/adjusted_init.nc": "global_ocean/QUwISC240/PHC/init/ssh_adjustment/adjusted_init.210727.nc",
23+
"ocean/global_ocean/cached/ECwISC30to60/mesh/mesh/culled_mesh.nc": "global_ocean/ECwISC30to60/mesh/mesh/culled_mesh.210727.nc",
24+
"ocean/global_ocean/cached/ECwISC30to60/mesh/mesh/culled_graph.info": "global_ocean/ECwISC30to60/mesh/mesh/culled_graph.210727.info",
25+
"ocean/global_ocean/cached/ECwISC30to60/mesh/mesh/critical_passages_mask_final.nc": "global_ocean/ECwISC30to60/mesh/mesh/critical_passages_mask_final.210727.nc",
26+
"ocean/global_ocean/cached/ECwISC30to60/PHC/init/initial_state/initial_state.nc": "global_ocean/ECwISC30to60/PHC/init/initial_state/initial_state.210727.nc",
27+
"ocean/global_ocean/cached/ECwISC30to60/PHC/init/initial_state/init_mode_forcing_data.nc": "global_ocean/ECwISC30to60/PHC/init/initial_state/init_mode_forcing_data.210727.nc",
28+
"ocean/global_ocean/cached/ECwISC30to60/PHC/init/ssh_adjustment/adjusted_init.nc": "global_ocean/ECwISC30to60/PHC/init/ssh_adjustment/adjusted_init.210727.nc"
29+
}

compass/ocean/tests/global_ocean/__init__.py

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,34 @@ def __init__(self, mpas_core):
125125
test_group=self, mesh=mesh, init=init,
126126
time_integrator=time_integrator))
127127

128+
# tests with cached meshes and initial conditions
129+
mesh = Mesh(test_group=self, mesh_name=mesh_name,
130+
cached=True)
131+
self.add_test_case(mesh)
132+
133+
init = Init(test_group=self, mesh=mesh,
134+
initial_condition='PHC',
135+
with_bgc=False, cached=True)
136+
self.add_test_case(init)
137+
138+
time_integrator = 'split_explicit'
139+
self.add_test_case(
140+
PerformanceTest(
141+
test_group=self, mesh=mesh, init=init,
142+
time_integrator=time_integrator))
143+
self.add_test_case(
144+
RestartTest(
145+
test_group=self, mesh=mesh, init=init,
146+
time_integrator=time_integrator))
147+
self.add_test_case(
148+
DecompTest(
149+
test_group=self, mesh=mesh, init=init,
150+
time_integrator=time_integrator))
151+
self.add_test_case(
152+
ThreadsTest(
153+
test_group=self, mesh=mesh, init=init,
154+
time_integrator=time_integrator))
155+
128156
# for other meshes, we do fewer tests
129157
for mesh_name in ['EC30to60', 'ECwISC30to60']:
130158
mesh = Mesh(test_group=self, mesh_name=mesh_name)
@@ -149,6 +177,22 @@ def __init__(self, mpas_core):
149177
test_group=self, mesh=mesh, init=init,
150178
dynamic_adjustment=dynamic_adjustment))
151179

180+
# tests with cached meshes and initial conditions
181+
mesh = Mesh(test_group=self, mesh_name=mesh_name,
182+
cached=True)
183+
self.add_test_case(mesh)
184+
185+
init = Init(test_group=self, mesh=mesh,
186+
initial_condition='PHC',
187+
with_bgc=False, cached=True)
188+
self.add_test_case(init)
189+
190+
time_integrator = 'split_explicit'
191+
self.add_test_case(
192+
PerformanceTest(
193+
test_group=self, mesh=mesh, init=init,
194+
time_integrator=time_integrator))
195+
152196
# SOwISC12to60: just the version with cavities for now
153197
for mesh_name in ['SOwISC12to60']:
154198
mesh = Mesh(test_group=self, mesh_name=mesh_name)
@@ -172,6 +216,23 @@ def __init__(self, mpas_core):
172216
test_group=self, mesh=mesh, init=init,
173217
dynamic_adjustment=dynamic_adjustment))
174218

219+
# tests with cached meshes and initial conditions,
220+
# not yet supported as we work out some output issues
221+
# mesh = Mesh(test_group=self, mesh_name=mesh_name,
222+
# cached=True)
223+
# self.add_test_case(mesh)
224+
225+
# init = Init(test_group=self, mesh=mesh,
226+
# initial_condition='PHC',
227+
# with_bgc=False, cached=True)
228+
# self.add_test_case(init)
229+
230+
# time_integrator = 'split_explicit'
231+
# self.add_test_case(
232+
# PerformanceTest(
233+
# test_group=self, mesh=mesh, init=init,
234+
# time_integrator=time_integrator))
235+
175236
# WC14: just the version without cavities
176237
for mesh_name in ['WC14']:
177238
mesh = Mesh(test_group=self, mesh_name=mesh_name)
@@ -195,5 +256,21 @@ def __init__(self, mpas_core):
195256
test_group=self, mesh=mesh, init=init,
196257
dynamic_adjustment=dynamic_adjustment))
197258

259+
# tests with cached meshes and initial conditions
260+
mesh = Mesh(test_group=self, mesh_name=mesh_name,
261+
cached=True)
262+
self.add_test_case(mesh)
263+
264+
init = Init(test_group=self, mesh=mesh,
265+
initial_condition='PHC',
266+
with_bgc=False, cached=True)
267+
self.add_test_case(init)
268+
269+
time_integrator = 'split_explicit'
270+
self.add_test_case(
271+
PerformanceTest(
272+
test_group=self, mesh=mesh, init=init,
273+
time_integrator=time_integrator))
274+
198275
# A test case for making diagnostics files from an existing mesh
199276
self.add_test_case(MakeDiagnosticsFiles(test_group=self))

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ class Init(TestCase):
2626
The subdirectory within the test group for all test cases with this
2727
initial condition
2828
"""
29-
def __init__(self, test_group, mesh, initial_condition, with_bgc):
29+
def __init__(self, test_group, mesh, initial_condition, with_bgc,
30+
cached=False):
3031
"""
3132
Create the test case
3233
@@ -43,14 +44,16 @@ def __init__(self, test_group, mesh, initial_condition, with_bgc):
4344
4445
with_bgc : bool
4546
Whether to include biogeochemistry (BGC) in the initial condition
47+
48+
cached : bool, optional
49+
Whether to use a cached initial state instead of computing one
4650
"""
4751
name = 'init'
48-
mesh_name = mesh.mesh_name
4952
if with_bgc:
5053
ic_dir = '{}_BGC'.format(initial_condition)
5154
else:
5255
ic_dir = initial_condition
53-
self.init_subdir = os.path.join(mesh_name, ic_dir)
56+
self.init_subdir = os.path.join(mesh.mesh_subdir, ic_dir)
5457
subdir = os.path.join(self.init_subdir, name)
5558
super().__init__(test_group=test_group, name=name, subdir=subdir)
5659

@@ -61,11 +64,12 @@ def __init__(self, test_group, mesh, initial_condition, with_bgc):
6164
self.add_step(
6265
InitialState(
6366
test_case=self, mesh=mesh,
64-
initial_condition=initial_condition, with_bgc=with_bgc))
67+
initial_condition=initial_condition, with_bgc=with_bgc,
68+
cached=cached))
6569

6670
if mesh.with_ice_shelf_cavities:
6771
self.add_step(
68-
SshAdjustment(test_case=self, cores=4))
72+
SshAdjustment(test_case=self, cores=4, cached=cached))
6973

7074
def configure(self):
7175
"""

compass/ocean/tests/global_ocean/init/initial_state.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class InitialState(Step):
2222
with_bgc : bool
2323
Whether to include biogeochemistry (BGC) in the initial condition
2424
"""
25-
def __init__(self, test_case, mesh, initial_condition, with_bgc):
25+
def __init__(self, test_case, mesh, initial_condition, with_bgc, cached):
2626
"""
2727
Create the step
2828
@@ -36,16 +36,28 @@ def __init__(self, test_case, mesh, initial_condition, with_bgc):
3636
3737
with_bgc : bool
3838
Whether to include biogeochemistry (BGC) in the initial condition
39+
40+
cached : bool
41+
Whether to use a cached initial state instead of computing one
3942
"""
4043
if initial_condition not in ['PHC', 'EN4_1900']:
4144
raise ValueError('Unknown initial_condition {}'.format(
4245
initial_condition))
4346

44-
super().__init__(test_case=test_case, name='initial_state')
47+
super().__init__(test_case=test_case, name='initial_state',
48+
cached=cached)
4549
self.mesh = mesh
4650
self.initial_condition = initial_condition
4751
self.with_bgc = with_bgc
4852

53+
outputs = ['initial_state.nc', 'init_mode_forcing_data.nc']
54+
55+
for filename in outputs:
56+
self.add_output_file(filename)
57+
58+
if self.cached:
59+
return
60+
4961
package = 'compass.ocean.tests.global_ocean.init'
5062

5163
# generate the namelist, replacing a few default options
@@ -133,9 +145,6 @@ def __init__(self, test_case, mesh, initial_condition, with_bgc):
133145

134146
self.add_model_as_input()
135147

136-
for file in ['initial_state.nc', 'init_mode_forcing_data.nc']:
137-
self.add_output_file(filename=file)
138-
139148
def setup(self):
140149
"""
141150
Set up the test case in the work directory, including downloading any

compass/ocean/tests/global_ocean/init/ssh_adjustment.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ class SshAdjustment(Step):
77
A step for iteratively adjusting the pressure from the weight of the ice
88
shelf to match the sea-surface height as part of ice-shelf 2D test cases
99
"""
10-
def __init__(self, test_case, cores=None, min_cores=None, threads=None):
10+
def __init__(self, test_case, cached, cores=None, min_cores=None,
11+
threads=None):
1112
"""
1213
Create the step
1314
@@ -16,6 +17,9 @@ def __init__(self, test_case, cores=None, min_cores=None, threads=None):
1617
test_case : compass.ocean.tests.global_ocean.init.Init
1718
The test case this step belongs to
1819
20+
cached : bool
21+
Whether to use a cached initial state instead of computing one
22+
1923
cores : int, optional
2024
the number of cores the step would ideally use. If fewer cores
2125
are available on the system, the step will run on all available
@@ -32,7 +36,15 @@ def __init__(self, test_case, cores=None, min_cores=None, threads=None):
3236
if min_cores is None:
3337
min_cores = cores
3438
super().__init__(test_case=test_case, name='ssh_adjustment',
35-
cores=cores, min_cores=min_cores, threads=threads)
39+
cores=cores, min_cores=min_cores, threads=threads,
40+
cached=cached)
41+
42+
output = 'adjusted_init.nc'
43+
44+
self.add_output_file(output)
45+
46+
if self.cached:
47+
return
3648

3749
self.add_namelist_file(
3850
'compass.ocean.tests.global_ocean', 'namelist.forward')
@@ -59,8 +71,6 @@ def __init__(self, test_case, cores=None, min_cores=None, threads=None):
5971

6072
self.add_model_as_input()
6173

62-
self.add_output_file(filename='adjusted_init.nc')
63-
6474
def setup(self):
6575
"""
6676
Set up the test case in the work directory, including downloading any

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

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,14 @@ class Mesh(TestCase):
1616
mesh_step : compass.ocean.tests.global_ocean.mesh.mesh.MeshStep
1717
The step for creating the mesh
1818
19+
mesh_subdir : str
20+
The subdirectory within the test group for all test cases with this
21+
mesh
22+
1923
with_ice_shelf_cavities : bool
2024
Whether the mesh includes ice-shelf cavities
2125
"""
22-
def __init__(self, test_group, mesh_name):
26+
def __init__(self, test_group, mesh_name, cached=False):
2327
"""
2428
Create test case for creating a global MPAS-Ocean mesh
2529
@@ -30,34 +34,48 @@ def __init__(self, test_group, mesh_name):
3034
3135
mesh_name : str
3236
The name of the mesh
37+
38+
cached : bool, optional
39+
Whether to use a cached initial state instead of computing one
3340
"""
3441
name = 'mesh'
35-
subdir = '{}/{}'.format(mesh_name, name)
42+
if cached:
43+
mesh_subdir = f'cached/{mesh_name}'
44+
else:
45+
mesh_subdir = mesh_name
46+
subdir = f'{mesh_subdir}/{name}'
3647
super().__init__(test_group=test_group, name=name, subdir=subdir)
3748
if mesh_name in 'QU240':
3849
self.mesh_step = QU240Mesh(self, mesh_name,
39-
with_ice_shelf_cavities=False)
50+
with_ice_shelf_cavities=False,
51+
cached=cached)
4052
elif mesh_name in 'QUwISC240':
4153
self.mesh_step = QU240Mesh(self, mesh_name,
42-
with_ice_shelf_cavities=True)
54+
with_ice_shelf_cavities=True,
55+
cached=cached)
4356
elif mesh_name in 'EC30to60':
4457
self.mesh_step = EC30to60Mesh(self, mesh_name,
45-
with_ice_shelf_cavities=False)
58+
with_ice_shelf_cavities=False,
59+
cached=cached)
4660
elif mesh_name in 'ECwISC30to60':
4761
self.mesh_step = EC30to60Mesh(self, mesh_name,
48-
with_ice_shelf_cavities=True)
62+
with_ice_shelf_cavities=True,
63+
cached=cached)
4964
elif mesh_name in 'SOwISC12to60':
5065
self.mesh_step = SO12to60Mesh(self, mesh_name,
51-
with_ice_shelf_cavities=True)
66+
with_ice_shelf_cavities=True,
67+
cached=cached)
5268
elif mesh_name in 'WC14':
5369
self.mesh_step = WC14Mesh(self, mesh_name,
54-
with_ice_shelf_cavities=False)
70+
with_ice_shelf_cavities=False,
71+
cached=cached)
5572
else:
5673
raise ValueError('Unknown mesh name {}'.format(mesh_name))
5774

5875
self.add_step(self.mesh_step)
5976

6077
self.mesh_name = mesh_name
78+
self.mesh_subdir = mesh_subdir
6179
self.with_ice_shelf_cavities = self.mesh_step.with_ice_shelf_cavities
6280

6381
def configure(self):

compass/ocean/tests/global_ocean/mesh/ec30to60/__init__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,28 @@ class EC30to60Mesh(MeshStep):
88
"""
99
A step for creating EC30to60 and ECwISC30to60 meshes
1010
"""
11-
def __init__(self, test_case, mesh_name, with_ice_shelf_cavities):
11+
def __init__(self, test_case, mesh_name, with_ice_shelf_cavities, cached):
1212
"""
1313
Create a new step
1414
1515
Parameters
1616
----------
17-
test_case : compass.TestCase
17+
test_case : compass.ocean.tests.global_ocean.Mesh
1818
The test case this step belongs to
1919
2020
mesh_name : str
2121
The name of the mesh
2222
2323
with_ice_shelf_cavities : bool
2424
Whether the mesh includes ice-shelf cavities
25+
26+
cached : bool
27+
Whether to use a cached initial state instead of computing one
2528
"""
2629

2730
super().__init__(test_case, mesh_name, with_ice_shelf_cavities,
2831
package=self.__module__,
29-
mesh_config_filename='ec30to60.cfg')
32+
mesh_config_filename='ec30to60.cfg', cached=cached)
3033

3134
def build_cell_width_lat_lon(self):
3235
"""

0 commit comments

Comments
 (0)