@@ -23,29 +23,33 @@ Returns a callback to display simulation information.
23
23
Adapted from ClimaTimeSteppers.jl #89.
24
24
"""
25
25
function display_status_callback! (:: Type{tType} ) where {tType}
26
- start_time = UInt64 ( 0.0 )
27
- prev_time = UInt64 ( 0.0 )
28
- prev_t = tType ( 0.0 )
29
- is_first_step = true
26
+ start_time = Ref { UInt64} ( )
27
+ prev_time = Ref { UInt64} ( )
28
+ prev_t = Ref { tType} ( )
29
+ is_not_first_step = Ref {Bool} ()
30
30
31
31
function affect! (integrator)
32
- # time = time_ns() / 1e9
33
- # if is_first_step
34
- # is_first_step = false
35
- # start_time = time
36
- # end
37
-
38
- # t_end = maximum(integrator.tstops.valtree)
39
- # nsteps = floor(Int64, t_end / integrator.dt)
40
-
41
- # @info "$(Dates.format(Dates.now(), "HH:MM:SS:ss u d")) \n\
42
- # Timestep: $(integrator.step) / $(nsteps); Simulation Time: $(integrator.t) seconds \n\
43
- # Walltime: $(round(time - start_time, digits=4)) seconds; \
44
- # Time/Step: $(round((time - start_time) / nsteps, digits=4)) seconds \n"
45
- # # Time Remaining: $(prev_time == 0.0 ? "..." : string(round(Int64, (time - prev_time) / (integrator.t - prev_t) * (t_end - integrator.t))) * " seconds")"
46
-
47
- # prev_t = integrator.t
48
- # prev_time = time
32
+ time = round (UInt64, time_ns () / 1e9 )
33
+ if ! (is_not_first_step[])
34
+ is_not_first_step[] = true
35
+ start_time[] = time
36
+ end
37
+
38
+ t_end = maximum (integrator. tstops. valtree)
39
+ nsteps = floor (Int64, t_end / integrator. dt)
40
+ speed = (time - prev_time[]) / (integrator. t - prev_t[])
41
+ eta = speed * (t_end - integrator. t)
42
+
43
+ println (" $(Dates. format (Dates. now (), " HH:MM:SS:ss u d" )) \n \
44
+ Timestep: $(integrator. step) / $(nsteps) ; \
45
+ Simulation Time: $(integrator. t) seconds \n \
46
+ Walltime: $(round (time - start_time[], digits= 4 )) seconds; \
47
+ Time/Step: $(round ((time - start_time[]) / nsteps, digits= 4 )) seconds \n \
48
+ # Time Remaining: $(eta == Inf ? " ..." :
49
+ string (round ((time - prev_time[]) / (integrator. t - prev_t[]) * (t_end - integrator. t))) * " seconds" ) " )
50
+
51
+ prev_t[] = integrator. t
52
+ prev_time[] = time
49
53
end
50
54
return affect!
51
55
end
0 commit comments