Skip to content

Commit bbb1305

Browse files
committed
some fixes [skip ci]
1 parent 02d2be5 commit bbb1305

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

experiments/ClimaEarth/components/ocean/clima_seaice.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ function FluxCalculator.update_turbulent_fluxes!(sim::ClimaSeaIceSimulation, fie
192192
# Note that this requires the sea ice model to always be run with dynamics turned on
193193
si_flux_u = sim.ice.model.dynamics.external_momentum_stresses.top.u
194194
si_flux_v = sim.ice.model.dynamics.external_momentum_stresses.top.v
195-
set_from_extrinsic_vectors!(
195+
set_from_extrinsic_vector!(
196196
(; u = si_flux_u, v = si_flux_v),
197197
grid,
198198
F_turb_ρτxz_cc,
@@ -208,7 +208,7 @@ function FluxCalculator.update_turbulent_fluxes!(sim::ClimaSeaIceSimulation, fie
208208
remapped_F_sh = sim.remapping.scratch_arr2
209209

210210
# Update the sea ice only where the concentration is greater than zero.
211-
si_flux_heat = ice_sim.ice.model.external_heat_fluxes.top
211+
si_flux_heat = sim.ice.model.external_heat_fluxes.top
212212
OC.interior(si_flux_heat, :, :, 1) .=
213213
OC.interior(si_flux_heat, :, :, 1) .+ (remapped_F_lh .+ remapped_F_sh)
214214

experiments/ClimaEarth/components/ocean/oceananigans.jl

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ It contains the following objects:
2222
- `ocean_properties::OPROP`: A NamedTuple of ocean properties and parameters
2323
- `remapping::REMAP`: Objects needed to remap from the exchange (spectral) grid to Oceananigans spaces.
2424
"""
25-
struct OceananigansSimulation{SIM, A, OPROP, REMAP, SIC} <: Interfacer.OceanModelSimulation
25+
struct OceananigansSimulation{SIM, A, OPROP, REMAP} <: Interfacer.OceanModelSimulation
2626
ocean::SIM
2727
area_fraction::A
2828
ocean_properties::OPROP
@@ -152,8 +152,9 @@ function OceananigansSimulation(
152152
interpolated_values_dim..., _buffer_length = size(remapper_cc._interpolated_values)
153153
scratch_arr1 = ArrayType(zeros(FT, interpolated_values_dim...))
154154
scratch_arr2 = ArrayType(zeros(FT, interpolated_values_dim...))
155+
scratch_arr3 = ArrayType(zeros(FT, interpolated_values_dim...))
155156

156-
remapping = (; remapper_cc, scratch_cc1, scratch_cc2, scratch_arr1, scratch_arr2)
157+
remapping = (; remapper_cc, scratch_cc1, scratch_cc2, scratch_arr1, scratch_arr2, scratch_arr3)
157158

158159
ocean_properties = (;
159160
ocean_reference_density = 1020,
@@ -267,7 +268,14 @@ function FluxCalculator.update_turbulent_fluxes!(sim::OceananigansSimulation, fi
267268
# TODO clarify where we need to add and where we set fluxes directly
268269
(; F_lh, F_sh, F_turb_ρτxz, F_turb_ρτyz, F_turb_moisture) = fields
269270
grid = sim.ocean.model.grid
270-
area_fraction = sim.area_fraction
271+
272+
# Remap the area fraction from the boundary space to the Oceananigans grid
273+
CC.Remapping.interpolate!(
274+
sim.remapping.scratch_arr3,
275+
sim.remapping.remapper_cc,
276+
sim.area_fraction,
277+
)
278+
area_fraction = sim.remapping.scratch_arr3
271279

272280
# Remap momentum fluxes onto reduced 2D Center, Center fields using scratch arrays and fields
273281
CC.Remapping.interpolate!(
@@ -361,7 +369,14 @@ so a sign change is needed when we convert from precipitation to salinity flux.
361369
function FieldExchanger.update_sim!(sim::OceananigansSimulation, csf)
362370
(; ocean_reference_density, ocean_heat_capacity, ocean_fresh_water_density) =
363371
sim.ocean_properties
364-
area_fraction = sim.area_fraction # TODO use sea ice instead?
372+
# TODO use SIC instead?
373+
# Remap the area fraction from the boundary space to the Oceananigans grid
374+
CC.Remapping.interpolate!(
375+
sim.remapping.scratch_arr3,
376+
sim.remapping.remapper_cc,
377+
sim.area_fraction,
378+
)
379+
area_fraction = sim.remapping.scratch_arr3
365380

366381
# Remap radiative flux onto scratch array; rename for clarity
367382
CC.Remapping.interpolate!(
@@ -398,12 +413,12 @@ function FieldExchanger.update_sim!(sim::OceananigansSimulation, csf)
398413
CC.Remapping.interpolate!(
399414
sim.remapping.scratch_arr1,
400415
sim.remapping.remapper_cc,
401-
area_fraction .* csf.P_liq,
416+
sim.area_fraction .* csf.P_liq,
402417
)
403418
CC.Remapping.interpolate!(
404419
sim.remapping.scratch_arr2,
405420
sim.remapping.remapper_cc,
406-
area_fraction .* csf.P_snow,
421+
sim.area_fraction .* csf.P_snow,
407422
)
408423
remapped_P_liq = sim.remapping.scratch_arr1
409424
remapped_P_snow = sim.remapping.scratch_arr2

experiments/ClimaEarth/setup_run.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ function CoupledSimulation(config_dict::AbstractDict)
415415
)
416416

417417
# Get initial SIC values and use them to calculate ice fraction
418-
ice_fraction = CC.Fields.zeros(space)
418+
ice_fraction = CC.Fields.zeros(boundary_space)
419419
evaluate!(ice_fraction, SIC_timevaryinginput, tspan[1])
420420
else
421421
error("Invalid ice model specified: $(ice_model)")

0 commit comments

Comments
 (0)