Skip to content

Commit 6744bfc

Browse files
authored
Merge pull request #1603 from CliMA/js/ocean-bugfix
fix ocean 3D field surface access
2 parents 5fb306b + 43d9c37 commit 6744bfc

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

experiments/ClimaEarth/components/ocean/oceananigans.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ function FluxCalculator.update_turbulent_fluxes!(sim::OceananigansSimulation, fi
367367
)
368368
moisture_fresh_water_flux = sim.remapping.scratch_arr1 ./ fresh_water_density
369369
oc_flux_S = surface_flux(sim.ocean.model.tracers.S)
370-
surface_salinity = OC.interior(sim.ocean.model.tracers.S, :, :, 1)
370+
surface_salinity = OC.interior(sim.ocean.model.tracers.S, :, :, grid.Nz)
371371
OC.interior(oc_flux_S, :, :, 1) .=
372372
OC.interior(oc_flux_S, :, :, 1) .-
373373
(1.0 .- ice_concentration) .* surface_salinity .* moisture_fresh_water_flux
@@ -401,6 +401,7 @@ so a sign change is needed when we convert from precipitation to salinity flux.
401401
function FieldExchanger.update_sim!(sim::OceananigansSimulation, csf)
402402
(; reference_density, heat_capacity, fresh_water_density) = sim.ocean_properties
403403
ice_concentration = sim.ice_concentration
404+
Nz = sim.ocean.model.grid.Nz
404405

405406
# Remap radiative flux onto scratch array; rename for clarity
406407
CC.Remapping.interpolate!(
@@ -428,7 +429,7 @@ function FieldExchanger.update_sim!(sim::OceananigansSimulation, csf)
428429
-(1 - α) .* remapped_SW_d .-
429430
ϵ * (
430431
remapped_LW_d .-
431-
σ .* (C_to_K .+ OC.interior(sim.ocean.model.tracers.T, :, :, 1)) .^ 4
432+
σ .* (C_to_K .+ OC.interior(sim.ocean.model.tracers.T, :, :, Nz)) .^ 4
432433
)
433434
) ./ (reference_density * heat_capacity)
434435

@@ -450,7 +451,7 @@ function FieldExchanger.update_sim!(sim::OceananigansSimulation, csf)
450451
oc_flux_S = surface_flux(sim.ocean.model.tracers.S)
451452
OC.interior(oc_flux_S, :, :, 1) .=
452453
OC.interior(oc_flux_S, :, :, 1) .-
453-
OC.interior(sim.ocean.model.tracers.S, :, :, 1) .* (1.0 .- ice_concentration) .*
454+
OC.interior(sim.ocean.model.tracers.S, :, :, Nz) .* (1.0 .- ice_concentration) .*
454455
(remapped_P_liq .+ remapped_P_snow) ./ fresh_water_density
455456
return nothing
456457
end

0 commit comments

Comments
 (0)