Skip to content

Commit a43a486

Browse files
Add ETA print to time-step output (#1351)
Co-authored-by: Spencer Bryngelson <sbryngelson@gmail.com>
1 parent cf81f25 commit a43a486

4 files changed

Lines changed: 40 additions & 14 deletions

File tree

src/post_process/m_start_up.fpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,16 +139,27 @@ contains
139139
impure subroutine s_perform_time_step(t_step)
140140
141141
integer, intent(inout) :: t_step
142+
integer :: eta_hh, eta_mm, eta_ss
143+
real(wp) :: eta_sec
142144
143145
if (proc_rank == 0) then
144146
if (cfl_dt) then
145-
print '(" [", I3, "%] Saving ", I8, " of ", I0, " Time Avg = ", ES16.6, " Time/step = ", ES12.6, "")', &
146-
& int(ceiling(100._wp*(real(t_step - n_start)/(n_save)))), t_step, n_save, wall_time_avg, wall_time
147+
eta_sec = wall_time_avg*real(n_save - 1 - t_step, wp)
148+
eta_hh = int(eta_sec)/3600
149+
eta_mm = mod(int(eta_sec), 3600)/60
150+
eta_ss = mod(int(eta_sec), 60)
151+
print '(" [", I3, "%] Saving ", I8, " of ", I0, " Time Avg = ", ES16.6, " Time/step = ", ES12.6, " ETA (HH:MM:SS) = ", I0, ":", I2.2, ":", I2.2)', &
152+
& int(ceiling(100._wp*(real(t_step - n_start)/(n_save)))), t_step, n_save, wall_time_avg, wall_time, eta_hh, &
153+
& eta_mm, eta_ss
147154
else
148-
print '(" [", I3, "%] Saving ", I8, " of ", I0, " @ t_step = ", I8, " Time Avg = ", ES16.6, " Time/step = ", ES12.6, "")', &
155+
eta_sec = wall_time_avg*real((t_step_stop - t_step)/t_step_save, wp)
156+
eta_hh = int(eta_sec)/3600
157+
eta_mm = mod(int(eta_sec), 3600)/60
158+
eta_ss = mod(int(eta_sec), 60)
159+
print '(" [", I3, "%] Saving ", I8, " of ", I0, " @ t_step = ", I8, " Time Avg = ", ES16.6, " Time/step = ", ES12.6, " ETA (HH:MM:SS) = ", I0, ":", I2.2, ":", I2.2)', &
149160
& int(ceiling(100._wp*(real(t_step - t_step_start)/(t_step_stop - t_step_start + 1)))), &
150161
& (t_step - t_step_start)/t_step_save + 1, (t_step_stop - t_step_start)/t_step_save + 1, t_step, &
151-
& wall_time_avg, wall_time
162+
& wall_time_avg, wall_time, eta_hh, eta_mm, eta_ss
152163
end if
153164
end if
154165

src/post_process/p_main.fpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ program p_main
1010

1111
implicit none
1212

13-
integer :: t_step !< Iterator for the main time-stepping loop
13+
integer :: t_step, nt_step !< Iterator for the main time-stepping loop
1414
!> Generic storage for the name(s) of the flow variable(s) that will be added to the formatted database file(s)
1515
character(LEN=name_len) :: varname
1616
real(wp) :: pres
@@ -47,8 +47,13 @@ program p_main
4747

4848
wall_time = abs(finish - start)
4949

50-
if (t_step >= 2) then
51-
wall_time_avg = (wall_time + (t_step - 2)*wall_time_avg)/(t_step - 1)
50+
if (cfl_dt) then
51+
nt_step = t_step - n_start + 1
52+
else
53+
nt_step = (t_step - t_step_start)/t_step_save + 1
54+
end if
55+
if (nt_step >= 2) then
56+
wall_time_avg = (wall_time + (nt_step - 2)*wall_time_avg)/(nt_step - 1)
5257
else
5358
wall_time_avg = 0._wp
5459
end if

src/simulation/m_start_up.fpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,8 @@ contains
606606

607607
integer, intent(inout) :: t_step
608608
real(wp), intent(inout) :: time_avg
609-
integer :: i
609+
integer :: i, eta_hh, eta_mm, eta_ss
610+
real(wp) :: eta_sec
610611

611612
if (cfl_dt) then
612613
if (cfl_const_dt .and. t_step == 0) call s_compute_dt()
@@ -635,14 +636,23 @@ contains
635636

636637
if (cfl_dt) then
637638
if (proc_rank == 0 .and. mod(t_step - t_step_start, t_step_print) == 0) then
638-
print '(" [", I3, "%] Time ", ES16.6, " dt = ", ES16.6, " @ Time Step = ", I8, " Time Avg = ", ES16.6, " Time/step = ", ES12.6, "")', &
639-
& int(ceiling(100._wp*(mytime/t_stop))), mytime, dt, t_step, wall_time_avg, wall_time
639+
eta_sec = wall_time_avg*(t_stop - mytime)/max(dt, tiny(dt))
640+
eta_hh = int(eta_sec)/3600
641+
eta_mm = mod(int(eta_sec), 3600)/60
642+
eta_ss = mod(int(eta_sec), 60)
643+
print '(" [", I3, "%] Time ", ES16.6, " dt = ", ES16.6, " @ Time Step = ", I8, " Time Avg = ", ES16.6, " Time/step = ", ES12.6, " ETA (HH:MM:SS) = ", I0, ":", I2.2, ":", I2.2)', &
644+
& int(ceiling(100._wp*(mytime/t_stop))), mytime, dt, t_step, wall_time_avg, wall_time, eta_hh, eta_mm, eta_ss
640645
end if
641646
else
642647
if (proc_rank == 0 .and. mod(t_step - t_step_start, t_step_print) == 0) then
643-
print '(" [", I3, "%] Time step ", I8, " of ", I0, " @ t_step = ", I8, " Time Avg = ", ES12.6, " Time/step= ", ES12.6, "")', &
648+
eta_sec = wall_time_avg*real(t_step_stop - t_step, wp)
649+
eta_hh = int(eta_sec)/3600
650+
eta_mm = mod(int(eta_sec), 3600)/60
651+
eta_ss = mod(int(eta_sec), 60)
652+
print '(" [", I3, "%] Time step ", I8, " of ", I0, " @ t_step = ", I8, " Time Avg = ", ES12.6, " Time/step= ", ES12.6, " ETA (HH:MM:SS) = ", I0, ":", I2.2, ":", I2.2)', &
644653
& int(ceiling(100._wp*(real(t_step - t_step_start)/(t_step_stop - t_step_start + 1)))), &
645-
& t_step - t_step_start + 1, t_step_stop - t_step_start + 1, t_step, wall_time_avg, wall_time
654+
& t_step - t_step_start + 1, t_step_stop - t_step_start + 1, t_step, wall_time_avg, wall_time, eta_hh, &
655+
& eta_mm, eta_ss
646656
end if
647657
end if
648658

src/simulation/m_time_steppers.fpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,8 +586,8 @@ contains
586586

587587
wall_time = abs(finish - start)
588588

589-
if (t_step >= 2) then
590-
wall_time_avg = (wall_time + (t_step - 2)*wall_time_avg)/(t_step - 1)
589+
if (t_step - t_step_start >= 2) then
590+
wall_time_avg = (wall_time + (t_step - t_step_start - 2)*wall_time_avg)/(t_step - t_step_start - 1)
591591
else
592592
wall_time_avg = 0._wp
593593
end if

0 commit comments

Comments
 (0)