Skip to content
Closed
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d0f58e5
Added the latest version of ClimaOcean
taimoorsohail Mar 3, 2025
70460ba
beginning of a mwe
taimoorsohail Mar 6, 2025
827c210
Added MWE for checkpointer and changes src code to add checkpointer f…
taimoorsohail Mar 6, 2025
3d7938e
simplify
taimoorsohail Mar 7, 2025
d75d6a8
delete revise mwe
taimoorsohail Mar 7, 2025
a131894
drop Revise, use ClimaSeaIce 0.2.1
navidcy Mar 7, 2025
ac24c59
Merge branch 'main' into checkpointer
navidcy Mar 7, 2025
3cb0f8c
don't hardcode path
navidcy Mar 7, 2025
9f331ff
Merge branch 'checkpointer' of github.com:taimoorsohail/ClimaOcean.jl…
navidcy Mar 7, 2025
de3bb6e
Updated the checkpointer file
taimoorsohail Mar 7, 2025
1b64465
Added OutputWriters for checkpointing
taimoorsohail Mar 7, 2025
7cc6515
Added OutputWriters for checkpointing
taimoorsohail Mar 7, 2025
66ceae2
merge main
taimoorsohail Mar 7, 2025
beaf23a
fixes
navidcy Mar 7, 2025
0d63a60
Fixed ClimaOcean precompiling bug in OutputWriters
taimoorsohail Mar 7, 2025
d7e9c74
Merge branch 'checkpointer' of github.com:taimoorsohail/ClimaOcean.jl…
taimoorsohail Mar 7, 2025
15a676f
Added atmosphere time to callback for debugging
taimoorsohail Mar 7, 2025
579c091
Tried to sync the atmosphere time step (not working)
taimoorsohail Mar 7, 2025
698a32b
Merge branch 'main' into checkpointer
navidcy Mar 7, 2025
2f69dda
Update time_step_ocean_sea_ice_model.jl
taimoorsohail Mar 7, 2025
96bc511
Merge branch 'main' into checkpointer
navidcy Mar 9, 2025
85ffc5c
Fixed merge conflicts
taimoorsohail Mar 11, 2025
b51543e
Fixed merge conflict
taimoorsohail Mar 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 108 additions & 0 deletions examples/checkpointer_mwe.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
using ClimaOcean
using Oceananigans
using Oceananigans.Units
using CFTime
using Dates
using Printf

arch = CPU()

Nx = 144
Ny = 60
Nz = 40

depth = 6000meters
z_faces = exponential_z_faces(; Nz, depth)

grid = LatitudeLongitudeGrid(arch;
size = (Nx, Ny, Nz),
halo = (7, 7, 7),
z = z_faces,
latitude = (-75, 75),
longitude = (0, 360))

ocean = ocean_simulation(grid)

# date = DateTimeProlepticGregorian(1993, 1, 1)
# set!(ocean.model, T=ECCOMetadata(:temperature; dates=date),
# S=ECCOMetadata(:salinity; dates=date))

radiation = Radiation(arch)

atmosphere = JRA55PrescribedAtmosphere(arch; backend=JRA55NetCDFBackend(41))

coupled_model = OceanSeaIceModel(ocean; atmosphere, radiation)

simulation = Simulation(coupled_model; Δt=10, stop_iteration=10)

wall_time = Ref(time_ns())

function progress(sim)
ocean = sim.model.ocean
u, v, w = ocean.model.velocities
T = ocean.model.tracers.T

Tmax = maximum(interior(T))
Tmin = minimum(interior(T))

umax = (maximum(abs, interior(u)),
maximum(abs, interior(v)),
maximum(abs, interior(w)))

step_time = 1e-9 * (time_ns() - wall_time[])

msg = @sprintf("Iter: %d, simulation time: %s, atmosphere time: %s, Δt: %s", iteration(sim), prettytime(sim), prettytime(atmosphere.clock.time), prettytime(sim.Δt))
msg *= @sprintf(", max|u|: (%.2e, %.2e, %.2e) m s⁻¹, extrema(T): (%.2f, %.2f) ᵒC, wall time: %s",
umax..., Tmax, Tmin, prettytime(step_time))

@info msg

wall_time[] = time_ns()
end

simulation.callbacks[:progress] = Callback(progress, IterationInterval(1))

outputs = merge(ocean.model.tracers, ocean.model.velocities)

ocean.output_writers[:surface] = JLD2OutputWriter(ocean.model, outputs;
schedule = IterationInterval(2),
filename = "checkpointer_mwe_surface",
indices = (:, :, grid.Nz),
with_halos = true,
overwrite_existing = true,
array_type = Array{Float32})

output_dir = "."
prefix = "checkpointer_mwe"

ocean.output_writers[:checkpoint] = Checkpointer(ocean.model;
schedule = IterationInterval(4),
prefix = prefix,
# cleanup = true,
dir = output_dir,
verbose = true,
overwrite_existing = true)

coupled_checkpointer = Checkpointer(coupled_model;
schedule = IterationInterval(4),
prefix = prefix,
dir = output_dir,
verbose = true,
overwrite_existing = true)

# @show simulation

# run!(simulation)

@info "simulation run for 10 iterations; you should have a checkpointer at 8"

checkpoint_file = prefix * "_iteration8.jld2"

set!(simulation, checkpoint_file)

coupled_model = OceanSeaIceModel(simulation.model.ocean; atmosphere, radiation)

simulation = Simulation(coupled_model; Δt=10, stop_iteration=20)
simulation.callbacks[:progress] = Callback(progress, IterationInterval(1))

run!(simulation)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"cells": [],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 5
}
Loading
Loading