Skip to content

Commit 9b3ed24

Browse files
committed
fixup rebase onto move tasks
1 parent f433a10 commit 9b3ed24

File tree

17 files changed

+730
-431
lines changed

17 files changed

+730
-431
lines changed

polaris/ocean/convergence/forward.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@ def __init__(
4141
refinement='both',
4242
forcing=False,
4343
):
44-
def __init__(self, component, name, subdir, refinement_factor, mesh, init,
45-
package, yaml_filename='forward.yaml',
46-
options=None, graph_target=None, output_filename='output.nc',
47-
validate_vars=None, refinement='both', forcing=False):
4844
"""
4945
Create a new step
5046
@@ -121,8 +117,8 @@ def __init__(self, component, name, subdir, refinement_factor, mesh, init,
121117
if forcing:
122118
self.add_input_file(
123119
filename='forcing.nc',
124-
work_dir_target=f'{init.path}/forcing.nc')
125-
120+
work_dir_target=f'{init.path}/forcing.nc',
121+
)
126122

127123
def compute_cell_count(self):
128124
"""

polaris/ocean/tasks/drying_slope/__init__.py

Lines changed: 0 additions & 115 deletions
This file was deleted.

polaris/tasks/ocean/add_tasks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def add_ocean_tasks(component):
2828
# planar tasks
2929
add_baroclinic_channel_tasks(component=component)
3030
add_barotropic_gyre_tasks(component=component)
31-
add_drying_slope_tasks(component=self)
31+
add_drying_slope_tasks(component=component)
3232
add_ice_shelf_2d_tasks(component=component)
3333
add_inertial_gravity_wave_tasks(component=component)
3434
add_internal_wave_tasks(component=component)
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
from polaris.config import PolarisConfigParser
2+
from polaris.ocean.resolution import resolution_to_subdir
3+
from polaris.tasks.ocean.drying_slope.baroclinic import Baroclinic
4+
from polaris.tasks.ocean.drying_slope.barotropic import Barotropic
5+
from polaris.tasks.ocean.drying_slope.convergence import Convergence
6+
from polaris.tasks.ocean.drying_slope.decomp import Decomp
7+
from polaris.tasks.ocean.drying_slope.init import Init
8+
9+
10+
def add_drying_slope_tasks(component):
11+
"""
12+
Add tasks for different drying slope tests to the ocean component
13+
14+
component : polaris.ocean.Ocean
15+
the ocean component that the tasks will be added to
16+
"""
17+
config_filename = 'drying_slope.cfg'
18+
19+
for coord_type in ['sigma', 'single_layer']:
20+
group_dir = f'planar/drying_slope/{coord_type}'
21+
22+
# The config file lives in the coord_type directory because
23+
# config options change between coordinate types
24+
config = PolarisConfigParser(filepath=f'{group_dir}/{config_filename}')
25+
config.add_from_package('polaris.ocean.convergence', 'convergence.cfg')
26+
config.add_from_package(
27+
'polaris.ocean.tasks.drying_slope', config_filename
28+
)
29+
if coord_type == 'single_layer':
30+
config.set(
31+
'vertical_grid',
32+
'vert_levels',
33+
'1',
34+
comment='Number of vertical levels',
35+
)
36+
config.set('vertical_grid', 'coord_type', 'z-level')
37+
else:
38+
config.set('vertical_grid', 'coord_type', 'sigma')
39+
40+
case_dir = f'{group_dir}/barotropic'
41+
for resolution in [0.25, 1.0]:
42+
resdir = resolution_to_subdir(resolution)
43+
indir = f'{case_dir}/{resdir}'
44+
45+
# Add one init step per resolution in barotropic
46+
init_dir = f'{indir}/init'
47+
if init_dir in component.steps:
48+
init = component.steps[init_dir]
49+
else:
50+
init = Init(
51+
component=component,
52+
resolution=resolution,
53+
name=f'init_{resdir}',
54+
subdir=init_dir,
55+
baroclinic=False,
56+
)
57+
init.set_shared_config(config, link=config_filename)
58+
59+
for method in ['standard', 'ramp']:
60+
if coord_type == 'single_layer':
61+
default = Barotropic(
62+
component=component,
63+
resolution=resolution,
64+
subdir=f'{indir}/{method}',
65+
init=init,
66+
method=method,
67+
coord_type=coord_type,
68+
drag_type='constant',
69+
)
70+
else:
71+
default = Barotropic(
72+
component=component,
73+
resolution=resolution,
74+
subdir=f'{indir}/{method}',
75+
init=init,
76+
method=method,
77+
coord_type=coord_type,
78+
)
79+
default.set_shared_config(config, link=config_filename)
80+
component.add_task(default)
81+
82+
if method == 'ramp':
83+
loglaw = Barotropic(
84+
component=component,
85+
resolution=resolution,
86+
subdir=f'{indir}/{method}',
87+
init=init,
88+
method=method,
89+
drag_type='loglaw',
90+
coord_type=coord_type,
91+
)
92+
loglaw.set_shared_config(config, link=config_filename)
93+
component.add_task(loglaw)
94+
95+
if (
96+
method == 'ramp'
97+
and resolution == 1.0
98+
and coord_type == 'sigma'
99+
):
100+
decomp = Decomp(
101+
component=component,
102+
resolution=resolution,
103+
indir=indir,
104+
init=init,
105+
method=method,
106+
coord_type=coord_type,
107+
)
108+
decomp.set_shared_config(config, link=config_filename)
109+
component.add_task(decomp)
110+
111+
# Add convergence test only for sigma coordinate
112+
if coord_type == 'sigma':
113+
method = 'ramp'
114+
task_dir = f'{case_dir}/convergence/{method}'
115+
convergence = Convergence(
116+
component=component,
117+
subdir=task_dir,
118+
group_dir=group_dir,
119+
config=config,
120+
method=method,
121+
)
122+
convergence.set_shared_config(config, link=config_filename)
123+
component.add_task(convergence)
124+
125+
if coord_type != 'single_layer':
126+
case_dir = f'{group_dir}/baroclinic'
127+
forcing_type = 'linear_drying'
128+
resolution = 1.0
129+
resdir = resolution_to_subdir(resolution)
130+
indir = f'{case_dir}/{resdir}'
131+
method = 'ramp'
132+
133+
# Create a new initial condition for the baroclinic case
134+
init = Init(
135+
component=component,
136+
indir=indir,
137+
resolution=resolution,
138+
baroclinic=True,
139+
)
140+
init.set_shared_config(config, link=config_filename)
141+
142+
baroclinic = Baroclinic(
143+
component=component,
144+
resolution=resolution,
145+
init=init,
146+
subdir=f'{indir}/{method}',
147+
coord_type=coord_type,
148+
method=method,
149+
forcing_type=forcing_type,
150+
)
151+
baroclinic.set_shared_config(config, link=config_filename)
152+
component.add_task(baroclinic)

0 commit comments

Comments
 (0)