Skip to content

Commit efc5477

Browse files
authored
Bugfix: time_step!(model, dt) (#410)
* Update time_step_ocean_sea_ice_model.jl * Implement a simple test for callbacks
1 parent c7ce952 commit efc5477

File tree

6 files changed

+33
-61
lines changed

6 files changed

+33
-61
lines changed

.buildkite/pipeline.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ steps:
134134
slurm_gpus_per_task: 1
135135

136136
- label: "Run simulation tests"
137-
key: "test_simulations"
137+
key: "test_ocean_sea_ice_model"
138138
env:
139-
TEST_GROUP: "simulations"
139+
TEST_GROUP: "ocean_sea_ice_model"
140140
GPU_TEST: "true"
141141
commands:
142142
- "julia --project -e 'using Pkg; Pkg.test()'"

src/OceanSeaIceModels/time_step_ocean_sea_ice_model.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ using Oceananigans.Grids: φnode
1010

1111
using Printf
1212

13-
function time_step!(coupled_model::OceanSeaIceModel, Δt; callbacks=[], compute_tendencies=true, kw...)
13+
function time_step!(coupled_model::OceanSeaIceModel, Δt; callbacks=[], compute_tendencies=true)
1414
ocean = coupled_model.ocean
1515
sea_ice = coupled_model.sea_ice
1616
atmosphere = coupled_model.atmosphere
@@ -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.model, Δt; kw...)
40+
time_step!(ocean, Δt)
4141

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

src/OceanSimulations/ocean_simulation.jl

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ using Statistics: mean
1717
# Some defaults
1818
default_free_surface(grid) = SplitExplicitFreeSurface(grid; cfl=0.7)
1919

20+
estimate_maximum_Δt(grid::RectilinearGrid) = 30minutes # ?
21+
2022
function estimate_maximum_Δt(grid)
2123
arch = architecture(grid)
2224
Δx = mean(xspacings(grid))

test/runtests.jl

+2-3
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,8 @@ if test_group == :bathymetry || test_group == :all
5555
include("test_bathymetry.jl")
5656
end
5757

58-
if test_group == :simulations || test_group == :all
59-
CUDA.set_runtime_version!(v"12.2", local_toolkit = true) # Seems to help in finding the correct CUDA dataset
60-
include("test_simulations.jl")
58+
if test_group == :ocean_sea_ice_model || test_group == :all
59+
include("test_ocean_sea_ice_model.jl")
6160
include("test_diagnostics.jl")
6261
end
6362

test/test_simulations.jl renamed to test/test_ocean_sea_ice_model.jl

+25-5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,27 @@ using ClimaSeaIce.SeaIceThermodynamics: melting_temperature
1111

1212
for arch in test_architectures
1313

14+
λ★, φ★ = 35.1, 50.1
15+
16+
grid = RectilinearGrid(arch, size = 200, x = λ★, y = φ★,
17+
z = (-400, 0), topology = (Flat, Flat, Bounded))
18+
19+
ocean = ocean_simulation(grid)
20+
data = Int[]
21+
pushdata(sim) = push!(data, iteration(sim))
22+
add_callback!(ocean, pushdata)
23+
backend = JRA55NetCDFBackend(4)
24+
atmosphere = JRA55PrescribedAtmosphere(arch; backend)
25+
radiation = Radiation(arch)
26+
coupled_model = OceanSeaIceModel(ocean; atmosphere, radiation)
27+
Δt = 60
28+
for n = 1:3
29+
time_step!(coupled_model, Δt)
30+
end
31+
@test data == [0, 1, 2, 3]
32+
33+
# TODO: do the same for a SeaIceSimulation, and eventually prognostic Atmos
34+
1435
#####
1536
##### Ocean and prescribed atmosphere
1637
#####
@@ -20,11 +41,10 @@ using ClimaSeaIce.SeaIceThermodynamics: melting_temperature
2041
halo = (7, 7, 7),
2142
z = (-6000, 0))
2243

23-
bottom_height = retrieve_bathymetry(grid;
24-
minimum_depth = 10,
25-
dir = "./",
26-
interpolation_passes = 20,
27-
major_basins = 1)
44+
bottom_height = regrid_bathymetry(grid;
45+
minimum_depth = 10,
46+
interpolation_passes = 20,
47+
major_basins = 1)
2848

2949
grid = ImmersedBoundaryGrid(grid, GridFittedBottom(bottom_height); active_cells_map=true)
3050

test/test_ocean_sea_ice_model_parameter_space.jl

-49
This file was deleted.

0 commit comments

Comments
 (0)