Skip to content

Commit

Permalink
is @info broken???
Browse files Browse the repository at this point in the history
  • Loading branch information
nefrathenrici committed Sep 7, 2023
1 parent cb6815f commit 0951257
Showing 1 changed file with 25 additions and 21 deletions.
46 changes: 25 additions & 21 deletions src/callbacks/callbacks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,33 @@ Returns a callback to display simulation information.
Adapted from ClimaTimeSteppers.jl #89.
"""
function display_status_callback!(::Type{tType}) where {tType}
start_time = UInt64(0.0)
prev_time = UInt64(0.0)
prev_t = tType(0.0)
is_first_step = true
start_time = Ref{UInt64}()
prev_time = Ref{UInt64}()
prev_t = Ref{tType}()
is_not_first_step = Ref{Bool}()

function affect!(integrator)
# time = time_ns() / 1e9
# if is_first_step
# is_first_step = false
# start_time = time
# end

# t_end = maximum(integrator.tstops.valtree)
# nsteps = floor(Int64, t_end / integrator.dt)

# @info "$(Dates.format(Dates.now(), "HH:MM:SS:ss u d")) \n\
# Timestep: $(integrator.step) / $(nsteps); Simulation Time: $(integrator.t) seconds \n\
# Walltime: $(round(time - start_time, digits=4)) seconds; \
# Time/Step: $(round((time - start_time) / nsteps, digits=4)) seconds \n"
# # Time Remaining: $(prev_time == 0.0 ? "..." : string(round(Int64, (time - prev_time) / (integrator.t - prev_t) * (t_end - integrator.t))) * " seconds")"

# prev_t = integrator.t
# prev_time = time
time = round(UInt64, time_ns() / 1e9)
if !(is_not_first_step[])
is_not_first_step[] = true
start_time[] = time
end

t_end = maximum(integrator.tstops.valtree)
nsteps = floor(Int64, t_end / integrator.dt)
speed = (time - prev_time[]) / (integrator.t - prev_t[])
eta = speed * (t_end - integrator.t)

println("$(Dates.format(Dates.now(), "HH:MM:SS:ss u d")) \n\
Timestep: $(integrator.step) / $(nsteps); \
Simulation Time: $(integrator.t) seconds \n\
Walltime: $(round(time - start_time[], digits=4)) seconds; \
Time/Step: $(round((time - start_time[]) / nsteps, digits=4)) seconds \n\
# Time Remaining: $(eta == Inf ? "..." :
string(round((time - prev_time[]) / (integrator.t - prev_t[]) * (t_end - integrator.t))) * " seconds")")

prev_t[] = integrator.t
prev_time[] = time
end
return affect!
end
Expand Down

0 comments on commit 0951257

Please sign in to comment.