Skip to content

Commit 69e6e44

Browse files
committed
Add omega support to barotropic_gyre, pending forcing stream
1 parent 315f5b8 commit 69e6e44

File tree

4 files changed

+75
-17
lines changed

4 files changed

+75
-17
lines changed

polaris/tasks/ocean/barotropic_gyre/analysis.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ def __init__(self, component, indir, boundary_condition='free slip'):
4343

4444
def run(self):
4545
ds_mesh = xr.open_dataset('mesh.nc')
46-
ds_init = xr.open_dataset('init.nc')
47-
ds = xr.open_dataset('output.nc')
46+
ds_init = self.open_model_dataset('init.nc')
47+
ds = self.open_model_dataset('output.nc')
4848

4949
field_mpas = compute_barotropic_streamfunction(
5050
ds_init.isel(Time=0), ds, prefix='', time_index=-1

polaris/tasks/ocean/barotropic_gyre/barotropic_gyre.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
[barotropic_gyre]
22

3+
# time integrator
4+
time_integrator = RK4
5+
36
# distance in kilometers between cell centers
47
resolution = 20
58

polaris/tasks/ocean/barotropic_gyre/forward.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ def dynamic_model_config(self, at_setup):
149149
)
150150

151151
if self.run_time_steps is not None:
152+
output_frequency_units = 'seconds'
152153
run_duration = ceil(self.run_time_steps * dt)
153154
stop_time_str = time.strftime(
154155
'0001-01-01_%H:%M:%S', time.gmtime(run_duration)
@@ -157,13 +158,29 @@ def dynamic_model_config(self, at_setup):
157158
'0000_%H:%M:%S', time.gmtime(run_duration)
158159
)
159160
else:
161+
output_frequency_units = 'months'
162+
output_frequency = '1'
160163
stop_time_str = time.strftime('0004-01-01_00:00:00')
161164
output_interval_str = time.strftime('0000-01-00_00:00:00')
162165

166+
time_integrator = config.get('barotropic_gyre', 'time_integrator')
167+
time_integrator_map = dict([('RK4', 'RungeKutta4')])
168+
model = config.get('ocean', 'model')
169+
if model == 'omega':
170+
if time_integrator in time_integrator_map.keys():
171+
time_integrator = time_integrator_map[time_integrator]
172+
else:
173+
print('Warning: mapping from time integrator '
174+
f'{time_integrator} to omega not found, '
175+
'retaining name given in config')
176+
163177
replacements = dict(
164178
dt=dt_str,
165179
stop_time=stop_time_str,
166180
output_interval=output_interval_str,
181+
output_frequency=output_frequency,
182+
output_frequency_units=output_frequency_units,
183+
time_integrator=time_integrator,
167184
nu=f'{nu:02g}',
168185
)
169186

@@ -174,6 +191,16 @@ def dynamic_model_config(self, at_setup):
174191
template_replacements=replacements,
175192
)
176193

194+
def setup(self):
195+
"""
196+
TEMP: symlink initial condition to name hard-coded in Omega
197+
"""
198+
super().setup()
199+
model = self.config.get('ocean', 'model')
200+
# TODO: remove as soon as Omega no longer hard-codes this file
201+
if model == 'omega':
202+
self.add_input_file(filename='OmegaMesh.nc', target='init.nc')
203+
177204

178205
def compute_max_time_step(config):
179206
"""

polaris/tasks/ocean/barotropic_gyre/forward.yaml

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,29 @@ ocean:
44
config_run_duration: none
55
time_integration:
66
config_dt: {{ dt }}
7-
config_time_integrator: RK4
7+
config_time_integrator: {{ time_integrator }}
8+
advection:
9+
config_thickness_flux_type: constant
810
hmix_del2:
911
config_use_mom_del2: true
1012
config_mom_del2: {{ nu }}
13+
hmix_del4:
14+
config_use_mom_del4: false
15+
16+
mpas-ocean:
17+
run_modes:
18+
config_ocean_run_mode: forward
19+
decomposition:
20+
config_block_decomp_file_prefix: graph.info.part.
21+
bottom_drag:
22+
config_implicit_constant_bottom_drag_coeff: 0.
23+
forcing:
24+
config_use_bulk_wind_stress: true
25+
debug:
26+
config_disable_vel_hadv: true
27+
config_disable_vel_hmix: false
28+
config_disable_tr_all_tend: true
29+
1130
streams:
1231
mesh:
1332
filename_template: init.nc
@@ -32,21 +51,30 @@ ocean:
3251
- layerThickness
3352
- ssh
3453

35-
mpas-ocean:
36-
advection:
37-
config_thickness_flux_type: constant
38-
bottom_drag:
39-
config_implicit_constant_bottom_drag_coeff: 0.
40-
forcing:
41-
config_use_bulk_wind_stress: true
42-
debug:
43-
config_disable_vel_hadv: true
44-
config_disable_vel_hmix: false
45-
config_disable_tr_all_tend: true
46-
4754
Omega:
4855
Tendencies:
49-
VelDiffTendencyEnable: true
50-
VelHyperDiffTendencyEnable: false
56+
TracerHorzAdvTendencyEnable : false
57+
TracerDiffTendencyEnable : false
58+
TracerHyperDiffTendencyEnable : false
59+
Advection:
60+
FluxThicknessType: Center
5161
Dimension:
5262
NVertLevels: 1
63+
IOStreams:
64+
InitialState:
65+
Filename: init.nc
66+
Contents:
67+
- LayerThickness
68+
- NormalVelocity
69+
History:
70+
Filename: output.nc
71+
Freq: {{ output_frequency }}
72+
FreqUnits: {{ output_frequency_units }}
73+
IfExists: append
74+
# effectively never
75+
FileFreq: 9999
76+
FileFreqUnits: years
77+
Contents:
78+
- LayerThickness
79+
- NormalVelocity
80+
- SshCellDefault

0 commit comments

Comments
 (0)