Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Oceananigans"
uuid = "9e8cae18-63c1-5223-a75c-80ca9d6e9a09"
authors = ["Climate Modeling Alliance and contributors"]
version = "0.95.26"
version = "0.95.27"

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Expand Down
20 changes: 11 additions & 9 deletions src/Simulations/run.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ end
"""
aligned_time_step(sim, Δt)

Return a time step 'aligned' with `sim.stop_time`, output writer schedules,
Return a time step 'aligned' with `sim.stop_time`, output writer schedules,
and callback schedules. Alignment with `sim.stop_time` takes precedence.
"""
function aligned_time_step(sim::Simulation, Δt)
Expand All @@ -45,7 +45,7 @@ function aligned_time_step(sim::Simulation, Δt)

# Align time step with output writing and callback execution
aligned_Δt = schedule_aligned_time_step(sim, aligned_Δt)

# Align time step with simulation stop time
time_left = unit_time(sim.stop_time - clock.time)
aligned_Δt = min(aligned_Δt, time_left)
Expand Down Expand Up @@ -94,7 +94,7 @@ function run!(sim; pickup=false)
start_run = time_ns()

if we_want_to_pickup(pickup)
set!(sim, pickup)
pickup!(sim, pickup)
end

sim.initialized = false
Expand All @@ -105,7 +105,7 @@ function run!(sim; pickup=false)
time_step!(sim)
end

for callback in values(sim.callbacks)
for callback in values(sim.callbacks)
finalize!(callback, sim)
end

Expand All @@ -116,6 +116,8 @@ function run!(sim; pickup=false)
return nothing
end

pickup!(sim, pickup) = set!(sim, pickup)

const ModelCallsite = Union{TendencyCallsite, UpdateStateCallsite}

""" Step `sim`ulation forward by Δt. """
Expand All @@ -137,7 +139,7 @@ function time_step!(sim::Simulation)
initial_time_step = !(sim.initialized)
initial_time_step && initialize!(sim)

if initial_time_step && sim.verbose
if initial_time_step && sim.verbose
@info "Executing initial time step..."
start_time = time_ns()
end
Expand All @@ -153,7 +155,7 @@ function time_step!(sim::Simulation)

# Callbacks and callback-like things
for diag in values(sim.diagnostics)
diag.schedule(sim.model) && run_diagnostic!(diag, sim.model)
diag.schedule(sim.model) && run_diagnostic!(diag, sim.model)
end

for callback in values(sim.callbacks)
Expand All @@ -162,7 +164,7 @@ function time_step!(sim::Simulation)
end

for writer in values(sim.output_writers)
writer.schedule(sim.model) && write_output!(writer, sim.model)
writer.schedule(sim.model) && write_output!(writer, sim.model)
end

if initial_time_step && sim.verbose
Expand All @@ -188,7 +190,7 @@ we_want_to_pickup(pickup::Integer) = true
we_want_to_pickup(pickup::String) = true
we_want_to_pickup(pickup) = throw(ArgumentError("Cannot run! with pickup=$pickup"))

"""
"""
initialize!(sim::Simulation, pickup=false)

Initialize a simulation:
Expand Down Expand Up @@ -228,7 +230,7 @@ function initialize!(sim::Simulation)
run_diagnostic!(diag, model)
end

for callback in values(sim.callbacks)
for callback in values(sim.callbacks)
callback.callsite isa TimeStepCallsite && callback(sim)
end

Expand Down
Loading