Skip to content

Commit d83d623

Browse files
authored
(0.4.7) Update for latest oceananigans (#390)
* Update for latest oceananigans * More cleanup * Bump ClimaSeaIce compat
1 parent 3819723 commit d83d623

File tree

3 files changed

+31
-28
lines changed

3 files changed

+31
-28
lines changed

Project.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name = "ClimaOcean"
22
uuid = "0376089a-ecfe-4b0e-a64f-9c555d74d754"
33
license = "MIT"
44
authors = ["Climate Modeling Alliance and contributors"]
5-
version = "0.4.6"
5+
version = "0.4.7"
66

77
[deps]
88
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
@@ -33,7 +33,7 @@ Thermodynamics = "b60c26fb-14c3-4610-9d3e-2d17fe7ff00c"
3333
Adapt = "4"
3434
CFTime = "0.1"
3535
CUDA = "4, 5"
36-
ClimaSeaIce = "0.2.3"
36+
ClimaSeaIce = "0.2.4"
3737
CubicSplines = "0.2"
3838
DataDeps = "0.7"
3939
Downloads = "1.6"
@@ -42,7 +42,7 @@ JLD2 = "0.4, 0.5"
4242
KernelAbstractions = "0.9"
4343
MPI = "0.20"
4444
NCDatasets = "0.12, 0.13, 0.14"
45-
Oceananigans = "0.95.18 - 0.99"
45+
Oceananigans = "0.95.21 - 0.99"
4646
OffsetArrays = "1.14"
4747
OrthogonalSphericalShellGrids = "0.2.2"
4848
Scratch = "1"

src/OceanSeaIceModels/ocean_sea_ice_model.jl

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ import Oceananigans.TimeSteppers: time_step!, update_state!, time
1919
import Oceananigans.Utils: prettytime
2020
import Oceananigans.Models: timestepper, NaNChecker, default_nan_checker
2121

22-
struct OceanSeaIceModel{I, A, O, F, C} <: AbstractModel{Nothing}
22+
struct OceanSeaIceModel{I, A, O, F, C, Arch} <: AbstractModel{Nothing, Arch}
23+
architecture :: Arch
2324
clock :: C
2425
atmosphere :: A
2526
sea_ice :: I
@@ -57,7 +58,6 @@ Base.eltype(model::OSIM) = Base.eltype(model.ocean.model)
5758
prettytime(model::OSIM) = prettytime(model.clock.time)
5859
iteration(model::OSIM) = model.clock.iteration
5960
timestepper(::OSIM) = nothing
60-
initialize!(::OSIM) = nothing
6161
default_included_properties(::OSIM) = tuple()
6262
prognostic_fields(cm::OSIM) = nothing
6363
fields(::OSIM) = NamedTuple()
@@ -68,6 +68,11 @@ function reset!(model::OSIM)
6868
return nothing
6969
end
7070

71+
function initialize!(model::OSIM)
72+
initialize!(model.ocean)
73+
return nothing
74+
end
75+
7176
reference_density(unsupported) =
7277
throw(ArgumentError("Cannot extract reference density from $(typeof(unsupported))"))
7378

@@ -102,26 +107,21 @@ function OceanSeaIceModel(ocean, sea_ice=FreezingLimitedOceanTemperature(eltype(
102107
sea_ice_heat_capacity = heat_capacity(sea_ice),
103108
interfaces = nothing)
104109

105-
# Remove some potentially irksome callbacks from the ocean simulation
106-
pop!(ocean.callbacks, :stop_time_exceeded, nothing)
107-
pop!(ocean.callbacks, :stop_iteration_exceeded, nothing)
108-
pop!(ocean.callbacks, :wall_time_limit_exceeded, nothing)
109-
pop!(ocean.callbacks, :nan_checker, nothing)
110-
111-
# In case there was any doubt these are meaningless.
112-
ocean.stop_time = Inf
113-
ocean.stop_iteration = Inf
114-
ocean.wall_time_limit = Inf
115-
110+
if !isnothing(ocean.callbacks)
111+
# Remove some potentially irksome callbacks from the ocean simulation
112+
pop!(ocean.callbacks, :stop_time_exceeded, nothing)
113+
pop!(ocean.callbacks, :stop_iteration_exceeded, nothing)
114+
pop!(ocean.callbacks, :wall_time_limit_exceeded, nothing)
115+
pop!(ocean.callbacks, :nan_checker, nothing)
116+
end
117+
116118
if sea_ice isa SeaIceSimulation
117-
pop!(sea_ice.callbacks, :stop_time_exceeded, nothing)
118-
pop!(sea_ice.callbacks, :stop_iteration_exceeded, nothing)
119-
pop!(sea_ice.callbacks, :wall_time_limit_exceeded, nothing)
120-
pop!(sea_ice.callbacks, :nan_checker, nothing)
121-
122-
sea_ice.stop_time = Inf
123-
sea_ice.stop_iteration = Inf
124-
sea_ice.wall_time_limit = Inf
119+
if !isnothing(sea_ice.callbacks)
120+
pop!(sea_ice.callbacks, :stop_time_exceeded, nothing)
121+
pop!(sea_ice.callbacks, :stop_iteration_exceeded, nothing)
122+
pop!(sea_ice.callbacks, :wall_time_limit_exceeded, nothing)
123+
pop!(sea_ice.callbacks, :nan_checker, nothing)
124+
end
125125
end
126126

127127
# Contains information about flux contributions: bulk formula, prescribed fluxes, etc.
@@ -134,7 +134,10 @@ function OceanSeaIceModel(ocean, sea_ice=FreezingLimitedOceanTemperature(eltype(
134134
radiation)
135135
end
136136

137-
ocean_sea_ice_model = OceanSeaIceModel(clock,
137+
arch = architecture(ocean.model.grid)
138+
139+
ocean_sea_ice_model = OceanSeaIceModel(arch,
140+
clock,
138141
atmosphere,
139142
sea_ice,
140143
ocean,

src/OceanSeaIceModels/time_step_ocean_sea_ice_model.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ using Oceananigans.Grids: φnode
1010

1111
using Printf
1212

13-
function time_step!(coupled_model::OceanSeaIceModel, Δt; callbacks=[], compute_tendencies=true)
13+
function time_step!(coupled_model::OceanSeaIceModel, Δt; callbacks=[], compute_tendencies=true, kw...)
1414
ocean = coupled_model.ocean
1515
sea_ice = coupled_model.sea_ice
1616
atmosphere = coupled_model.atmosphere
1717
clock = coupled_model.clock
1818

1919
# Be paranoid and update state at iteration 0
20-
coupled_model.clock.iteration == 0 && update_state!(coupled_model, callbacks)
20+
#coupled_model.clock.iteration == 0 && update_state!(coupled_model, callbacks)
2121

2222
# Eventually, split out into OceanOnlyModel
2323
if sea_ice isa SeaIceSimulation
@@ -37,7 +37,7 @@ function time_step!(coupled_model::OceanSeaIceModel, Δt; callbacks=[], compute_
3737

3838
# TODO after ice time-step:
3939
# - Adjust ocean heat flux if the ice completely melts?
40-
time_step!(ocean, Δt)
40+
time_step!(ocean.model, Δt; kw...)
4141

4242
# Time step the atmosphere
4343
time_step!(atmosphere, Δt)

0 commit comments

Comments
 (0)