@@ -22,49 +22,38 @@ include("callback_helpers.jl")
22
22
Returns a callback to display simulation information.
23
23
Adapted from ClimaTimeSteppers.jl #89.
24
24
"""
25
- function display_status_callback! ()
26
- prev_t = 0.0
27
- t = 0.0
28
- t_end = 0.0
29
-
30
- start_time = 0.0
31
- prev_time = 0.0
32
- time = 0.0
33
- eta = 0.0
34
- speed = 0.0
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
+ eta = tType (0.0 )
30
+ speed = tType (0.0 )
35
31
is_first_step = true
36
32
37
- step = 0
38
-
39
-
40
- function initialize (_, _, _, integrator)
41
- end
42
-
43
33
function affect! (integrator)
44
- t_end = integrator. p. simulation. t_end
45
- nsteps = ceil (Int, t_end / integrator. dt)
46
- # speed = wallclock time / simulation time
47
- # Print ETA = speed * remaining simulation time
34
+ t_end = maximum (integrator. tstops. valtree)
35
+ nsteps = ceil (Int64, t_end / integrator. dt)
48
36
t = integrator. t
37
+ step = ceil (Int64, t / integrator. dt)
49
38
time = time_ns () / 1e9
50
39
speed = (time - prev_time) / (t - prev_t)
51
40
eta = speed * (t_end - t)
52
- step += 1
41
+ eta_string = eta == Inf ? " ..." : string (round (Int64, eta)) * " seconds"
42
+
53
43
if is_first_step
54
- # @info "Time Remaining: ..."
55
44
is_first_step = false
56
45
start_time = time
57
- else
58
- @info " $(Dates. format (Dates. now (), " HH:MM:SS:ss u-d" )) \n \
59
- Timestep: $(step) / $(nsteps) ; Simulation Time: $(t) seconds \n \
60
- Walltime: $(round (time - start_time, digits= 2 )) seconds; \
61
- Time/Step: $(round (speed * integrator. dt, digits= 2 )) seconds"
62
- # Time Remaining: $(Int64(round(eta))) seconds"
63
46
end
47
+ @info " $(Dates. format (Dates. now (), " HH:MM:SS:ss u d" )) \n \
48
+ Timestep: $(step) / $(nsteps) ; Simulation Time: $(t) seconds \n \
49
+ Walltime: $(round (time - start_time, digits= 2 )) seconds; \
50
+ Time/Step: $(round (speed * integrator. dt, digits= 2 )) seconds \n \
51
+ Time Remaining: $eta_string "
52
+
64
53
prev_t = t
65
54
prev_time = time
66
55
end
67
- return initialize, affect!
56
+ return affect!
68
57
end
69
58
70
59
function dss_callback! (integrator)
0 commit comments