Skip to content

Commit 5a1f62e

Browse files
committed
Add omega support to barotropic_gyre, pending forcing stream
1 parent 8cc6acb commit 5a1f62e

File tree

4 files changed

+76
-18
lines changed

4 files changed

+76
-18
lines changed

polaris/ocean/tasks/barotropic_gyre/analysis.py

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

4848
ds_mesh = xr.open_dataset('mesh.nc')
49-
ds_init = xr.open_dataset('init.nc')
50-
ds = xr.open_dataset('output.nc')
49+
ds_init = self.open_model_dataset('init.nc')
50+
ds = self.open_model_dataset('output.nc')
5151

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

polaris/ocean/tasks/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/ocean/tasks/barotropic_gyre/forward.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ def dynamic_model_config(self, at_setup):
119119
model = config.get('ocean', 'model')
120120
if model == 'mpas-ocean':
121121
self.add_yaml_file('polaris.ocean.config', 'single_layer.yaml')
122-
123122
nu = config.getfloat("barotropic_gyre", "nu_2")
124123
rho_0 = config.getfloat("barotropic_gyre", "rho_0")
125124

@@ -133,26 +132,54 @@ def dynamic_model_config(self, at_setup):
133132
config_model='mpas-ocean')
134133

135134
if self.run_time_steps is not None:
135+
output_frequency_units = 'seconds'
136136
run_duration = ceil(self.run_time_steps * dt)
137+
output_frequency = f'{run_duration}'
137138
stop_time_str = time.strftime('0001-01-01_%H:%M:%S',
138139
time.gmtime(run_duration))
139140
output_interval_str = time.strftime('0000_%H:%M:%S',
140141
time.gmtime(run_duration))
141142
else:
143+
output_frequency_units = 'months'
144+
output_frequency = '1'
142145
stop_time_str = time.strftime('0004-01-01_00:00:00')
143146
output_interval_str = time.strftime('0000-01-00_00:00:00')
144147

148+
time_integrator = config.get('barotropic_gyre', 'time_integrator')
149+
time_integrator_map = dict([('RK4', 'RungeKutta4')])
150+
model = config.get('ocean', 'model')
151+
if model == 'omega':
152+
if time_integrator in time_integrator_map.keys():
153+
time_integrator = time_integrator_map[time_integrator]
154+
else:
155+
print('Warning: mapping from time integrator '
156+
f'{time_integrator} to omega not found, '
157+
'retaining name given in config')
158+
145159
replacements = dict(
146160
dt=dt_str,
147161
stop_time=stop_time_str,
148162
output_interval=output_interval_str,
163+
output_frequency=output_frequency,
164+
output_frequency_units=output_frequency_units,
165+
time_integrator=time_integrator,
149166
nu=f'{nu:02g}',
150167
)
151168

152169
# make sure output is double precision
153170
self.add_yaml_file(self.package, self.yaml_filename,
154171
template_replacements=replacements)
155172

173+
def setup(self):
174+
"""
175+
TEMP: symlink initial condition to name hard-coded in Omega
176+
"""
177+
super().setup()
178+
model = self.config.get('ocean', 'model')
179+
# TODO: remove as soon as Omega no longer hard-codes this file
180+
if model == 'omega':
181+
self.add_input_file(filename='OmegaMesh.nc', target='init.nc')
182+
156183

157184
def compute_max_time_step(config):
158185
"""

polaris/ocean/tasks/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)