Skip to content

Detach ClimaOcean to ClimaCoupler#2039

Open
simone-silvestri wants to merge 5 commits into
mainfrom
ss/detach-numerical-earth
Open

Detach ClimaOcean to ClimaCoupler#2039
simone-silvestri wants to merge 5 commits into
mainfrom
ss/detach-numerical-earth

Conversation

@simone-silvestri

Copy link
Copy Markdown
Contributor

There are not too many lines we need to port over to completely detach ClimaCoupler from ClimaOcean and just depend on Oceananigans and ClimaSeaIce.

This PR does the initial port.

@hgpeterson hgpeterson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @simone-silvestri, this looks good so far! I think most of the problems I caught have to do with the fact that you used v0.5.8 of NumericalEarth, but there were some important changes since then (like wiring in the clock/stop_time to the simulations, including mass fluxes, and a few other things). Once those get ported over, I think we're almost ready to merge.

"""
simplified_ocean_closure(FT=Oceananigans.defaults.FloatType)

A minimal closure suitable for testing on memory-limited GPUs (e.g. P100). Uses `ConvectiveAdjustmentVerticalDiffusivity`with a background

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
A minimal closure suitable for testing on memory-limited GPUs (e.g. P100). Uses `ConvectiveAdjustmentVerticalDiffusivity`with a background
A minimal closure suitable for testing on memory-limited GPUs (e.g. P100). Uses `ConvectiveAdjustmentVerticalDiffusivity` with a background

Comment on lines +1 to +2
# Ported from ClimaOcean v0.10.0, src/OceanConfigurations/{OceanConfigurations,one_degree_tripolar}.jl,
# and NumericalEarth v0.5.8, src/Oceans/ocean_simulation.jl

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just state this in the PR but don't need it in the code? Also, should we be using the latest NE version (0.6.0)?

@@ -0,0 +1,442 @@
# Ported from NumericalEarth v0.5.8, src/Oceans/{ocean_simulation,Oceans,barotropic_potential_forcing}.jl

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment here

Comment on lines +18 to +19
@inline default_gravitational_acceleration() = OC.defaults.gravitational_acceleration
@inline default_planet_rotation_rate() = OC.defaults.planet_rotation_rate

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't these come from the Coupler somewhere?

Comment on lines +420 to +439
# Only forward `clock` when supplied so the model keeps its own default otherwise.
clock_kw = isnothing(clock) ? NamedTuple() : (; clock)

ocean_model = OC.HydrostaticFreeSurfaceModel(
grid;
buoyancy,
closure,
biogeochemistry,
tracer_advection,
momentum_advection,
tracers,
timestepper,
free_surface,
coriolis,
forcing,
boundary_conditions,
clock_kw...,
)

ocean = OC.Simulation(ocean_model; Δt, verbose)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Only forward `clock` when supplied so the model keeps its own default otherwise.
clock_kw = isnothing(clock) ? NamedTuple() : (; clock)
ocean_model = OC.HydrostaticFreeSurfaceModel(
grid;
buoyancy,
closure,
biogeochemistry,
tracer_advection,
momentum_advection,
tracers,
timestepper,
free_surface,
coriolis,
forcing,
boundary_conditions,
clock_kw...,
)
ocean = OC.Simulation(ocean_model; Δt, verbose)
ocean_model = OC.HydrostaticFreeSurfaceModel(
grid;
clock,
buoyancy,
closure,
biogeochemistry,
tracer_advection,
momentum_advection,
tracers,
timestepper,
free_surface,
coriolis,
forcing,
boundary_conditions)
ocean = OC.Simulation(ocean_model; Δt, stop_time, verbose)

We lost the clock changes from NE v0.5.9 again!

Comment on lines +123 to +124
kᴺ = size(ocean.model.grid, 3)
surface_ocean_salinity = OC.interior(ocean.model.tracers.S, :, :, kᴺ:kᴺ)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
kᴺ = size(ocean.model.grid, 3)
surface_ocean_salinity = OC.interior(ocean.model.tracers.S, :, :, kᴺ:kᴺ)
surface_ocean_salinity = ocean_surface_salinity(ocean)

And port over ocean_surface_salinity() from v0.6.0?

# Build the sea ice model
sea_ice_model = CSI.SeaIceModel(
grid;
ice_salinity,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ice_salinity,
clock,
ice_salinity,

)

verbose = false
sea_ice = OC.Simulation(sea_ice_model; Δt, verbose)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
sea_ice = OC.Simulation(sea_ice_model; Δt, verbose)
sea_ice = OC.Simulation(sea_ice_model; Δt, stop_time, verbose)

Comment on lines +195 to +205
# `ocean_surface_velocities(ocean)` is inlined here: the singleton vertical dimension is dropped,
# unlike the surface salinity slice in `sea_ice_simulation`, which keeps it.
if isnothing(ocean)
SSU = OC.Fields.ZeroField()
SSV = OC.Fields.ZeroField()
else
kᴺ = size(ocean.model.grid, 3)
SSU = view(ocean.model.velocities.u, :, :, kᴺ)
SSV = view(ocean.model.velocities.v, :, :, kᴺ)
end

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# `ocean_surface_velocities(ocean)` is inlined here: the singleton vertical dimension is dropped,
# unlike the surface salinity slice in `sea_ice_simulation`, which keeps it.
if isnothing(ocean)
SSU = OC.Fields.ZeroField()
SSV = OC.Fields.ZeroField()
else
kᴺ = size(ocean.model.grid, 3)
SSU = view(ocean.model.velocities.u, :, :, kᴺ)
SSV = view(ocean.model.velocities.v, :, :, kᴺ)
end
SSU, SSV = ocean_surface_velocities(ocean)

and port over ocean_surface_velocities() from v0.6.0

Comment on lines +216 to +217
τua = OC.Field{OC.Face, OC.Center, Nothing}(grid)
τva = OC.Field{OC.Center, OC.Face, Nothing}(grid)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No boundary_conditions like in NE?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants