Skip to content

Commit 9e62322

Browse files
committed
Add baroclinic channel testcases
1 parent 868e9ba commit 9e62322

23 files changed

+1114
-1
lines changed

compass/ocean/tests/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from compass.ocean.tests import baroclinic_channel
2+
13

24
def collect():
35
"""
@@ -10,7 +12,7 @@ def collect():
1012
1113
"""
1214
testcases = list()
13-
for configuration in []:
15+
for configuration in [baroclinic_channel]:
1416
testcases.extend(configuration.collect())
1517

1618
return testcases
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
from compass.ocean.tests.baroclinic_channel import decomp_test, default, \
2+
restart_test, rpe_test, threads_test
3+
4+
5+
def collect():
6+
"""
7+
Get a list of testcases in this configuration
8+
9+
Returns
10+
-------
11+
testcases : list
12+
A list of tests within this configuration
13+
"""
14+
testcases = list()
15+
for resolution in ['1km', '4km', '10km']:
16+
for test in [rpe_test]:
17+
testcases.append(test.collect(resolution=resolution))
18+
for resolution in ['10km']:
19+
for test in [decomp_test, default, restart_test, threads_test]:
20+
testcases.append(test.collect(resolution=resolution))
21+
22+
return testcases
23+
24+
25+
def configure(testcase, config):
26+
"""
27+
Modify the configuration options for this testcase.
28+
29+
Parameters
30+
----------
31+
testcase : dict
32+
A dictionary of properties of this testcase from the ``collect()``
33+
function
34+
35+
config : configparser.ConfigParser
36+
Configuration options for this testcase, a combination of the defaults
37+
for the machine, core and configuration
38+
"""
39+
resolution = testcase['resolution']
40+
res_params = {'10km': {'nx': 16,
41+
'ny': 50,
42+
'dc': 10e3},
43+
'4km': {'nx': 40,
44+
'ny': 126,
45+
'dc': 4e3},
46+
'1km': {'nx': 160,
47+
'ny': 500,
48+
'dc': 1e3}}
49+
50+
if resolution not in res_params:
51+
raise ValueError('Unsupported resolution {}. Supported values are: '
52+
'{}'.format(resolution, list(res_params)))
53+
res_params = res_params[resolution]
54+
for param in res_params:
55+
config.set('baroclinic_channel', param, '{}'.format(res_params[param]))
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# namelist options for the baroclinic channel test case
2+
[baroclinic_channel]
3+
4+
# Number of vertical levels in baroclinic channel test case. Typical value is 20.
5+
vert_levels = 20
6+
7+
# Logical flag that determines if locations of features are defined by distance
8+
# or fractions. False means fractions.
9+
use_distances = False
10+
11+
# Temperature of the surface in the northern half of the domain.
12+
surface_temperature = 13.1
13+
14+
# Temperature of the bottom in the northern half of the domain.
15+
bottom_temperature = 10.1
16+
17+
# Difference in the temperature field between the northern and southern halves
18+
# of the domain.
19+
temperature_difference = 1.2
20+
21+
# Fraction of domain in Y direction the temperature gradient should be linear
22+
# over.
23+
gradient_width_frac = 0.08
24+
25+
# Width of the temperature gradient around the center sin wave. Default value
26+
# is relative to a 500km domain in Y.
27+
gradient_width_dist = 40e3
28+
29+
# Depth of the bottom of the ocean for the baroclinic channel test case.
30+
bottom_depth = 1000.0
31+
32+
# Salinity of the water in the entire domain.
33+
salinity = 35.0
34+
35+
# Coriolis parameter for entire domain.
36+
coriolis_parameter = -1.2e-4
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
from compass.testcase import run_steps, get_default
2+
from compass.ocean.tests.baroclinic_channel import initial_state, forward
3+
from compass.ocean.tests import baroclinic_channel
4+
5+
6+
def collect(resolution):
7+
"""
8+
Get a dictionary of testcase properties
9+
10+
Parameters
11+
----------
12+
resolution : {'10km'}
13+
The resolution of the mesh
14+
15+
Returns
16+
-------
17+
testcase : dict
18+
A dict of properties of this test case, including its steps
19+
"""
20+
description = 'baroclinic channel {} default'.format(resolution)
21+
module = __name__
22+
23+
name = module.split('.')[-1]
24+
subdir = '{}/{}'.format(resolution, name)
25+
steps = dict()
26+
step = initial_state.collect(resolution)
27+
steps[step['name']] = step
28+
29+
for procs in [4, 8]:
30+
step = forward.collect(resolution, procs=procs, threads=1)
31+
step['name'] = '{}proc'.format(procs)
32+
step['subdir'] = step['name']
33+
steps[step['name']] = step
34+
35+
testcase = get_default(module, description, steps, subdir=subdir)
36+
testcase['resolution'] = resolution
37+
38+
return testcase
39+
40+
41+
def configure(testcase, config):
42+
"""
43+
Modify the configuration options for this testcase.
44+
45+
Parameters
46+
----------
47+
testcase : dict
48+
A dictionary of properties of this testcase from the ``collect()``
49+
function
50+
51+
config : configparser.ConfigParser
52+
Configuration options for this testcase, a combination of the defaults
53+
for the machine, core and configuration
54+
"""
55+
baroclinic_channel.configure(testcase, config)
56+
57+
58+
def run(testcase, config):
59+
"""
60+
Run each step of the testcase
61+
62+
Parameters
63+
----------
64+
testcase : dict
65+
A dictionary of properties of this testcase from the ``collect()``
66+
function
67+
68+
config : configparser.ConfigParser
69+
Configuration options for this testcase, a combination of the defaults
70+
for the machine, core and configuration
71+
"""
72+
steps = ['initial_state', '4proc', '8proc']
73+
run_steps(testcase, config, steps)
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
from compass.testcase import run_steps, get_default
2+
from compass.ocean.tests.baroclinic_channel import initial_state, forward
3+
from compass.ocean.tests import baroclinic_channel
4+
5+
6+
def collect(resolution):
7+
"""
8+
Get a dictionary of testcase properties
9+
10+
Parameters
11+
----------
12+
resolution : {'10km'}
13+
The resolution of the mesh
14+
15+
Returns
16+
-------
17+
testcase : dict
18+
A dict of properties of this test case, including its steps
19+
"""
20+
description = 'baroclinic channel {} default'.format(resolution)
21+
module = __name__
22+
23+
name = module.split('.')[-1]
24+
subdir = '{}/{}'.format(resolution, name)
25+
steps = dict()
26+
step = initial_state.collect(resolution)
27+
steps[step['name']] = step
28+
step = forward.collect(resolution, procs=4, threads=1)
29+
steps[step['name']] = step
30+
31+
testcase = get_default(module, description, steps, subdir=subdir)
32+
testcase['resolution'] = resolution
33+
34+
return testcase
35+
36+
37+
def configure(testcase, config):
38+
"""
39+
Modify the configuration options for this testcase.
40+
41+
Parameters
42+
----------
43+
testcase : dict
44+
A dictionary of properties of this testcase from the ``collect()``
45+
function
46+
47+
config : configparser.ConfigParser
48+
Configuration options for this testcase, a combination of the defaults
49+
for the machine, core and configuration
50+
"""
51+
baroclinic_channel.configure(testcase, config)
52+
53+
54+
def run(testcase, config):
55+
"""
56+
Run each step of the testcase
57+
58+
Parameters
59+
----------
60+
testcase : dict
61+
A dictionary of properties of this testcase from the ``collect()``
62+
function
63+
64+
config : configparser.ConfigParser
65+
Configuration options for this testcase, a combination of the defaults
66+
for the machine, core and configuration
67+
"""
68+
steps = ['initial_state', 'forward']
69+
run_steps(testcase, config, steps)

0 commit comments

Comments
 (0)