Skip to content

Commit a55eecc

Browse files
committed
improve real time timing output
1 parent 55e7361 commit a55eecc

File tree

3 files changed

+55
-10
lines changed

3 files changed

+55
-10
lines changed

src/simulation/m_global_parameters.fpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ module m_global_parameters
2727

2828
implicit none
2929

30-
real(wp) :: time = 0
30+
real(wp) :: wall_time = 0
31+
real(wp) :: wall_time_avg = 0
3132

3233
! Logistics
3334
integer :: num_procs !< Number of processors

src/simulation/m_start_up.fpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,19 +1105,23 @@ contains
11051105

11061106
if (cfl_dt) then
11071107
if (proc_rank == 0 .and. mod(t_step - t_step_start, t_step_print) == 0) then
1108-
print '(" [", I3, "%] Time ", ES16.6, " dt = ", ES16.6, " @ Time Step = ", I8, "")', &
1108+
print '(" [", I3, "%] Time ", ES16.6, " dt = ", ES16.6, " @ Time Step = ", I8, " Time Avg = ", ES16.6, " Time/step = ", ES12.6, "")', &
11091109
int(ceiling(100._wp*(mytime/t_stop))), &
11101110
mytime, &
11111111
dt, &
1112-
t_step
1112+
t_step, &
1113+
wall_time_avg, &
1114+
wall_time
11131115
end if
11141116
else
11151117
if (proc_rank == 0 .and. mod(t_step - t_step_start, t_step_print) == 0) then
1116-
print '(" [", I3, "%] Time step ", I8, " of ", I0, " @ t_step = ", I0, "")', &
1118+
print '(" [", I3, "%] Time step ", I8, " of ", I0, " @ t_step = ", I8, " Time Avg = ", ES12.6, " Time/step= ", ES12.6, "")', &
11171119
int(ceiling(100._wp*(real(t_step - t_step_start)/(t_step_stop - t_step_start + 1)))), &
11181120
t_step - t_step_start + 1, &
11191121
t_step_stop - t_step_start + 1, &
1120-
t_step
1122+
t_step, &
1123+
wall_time_avg, &
1124+
wall_time
11211125
end if
11221126
end if
11231127

src/simulation/m_time_steppers.fpp

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -404,13 +404,18 @@ contains
404404
!> 1st order TVD RK time-stepping algorithm
405405
!! @param t_step Current time step
406406
impure subroutine s_1st_order_tvd_rk(t_step, time_avg)
407-
407+
#ifdef _CRAYFTN
408+
!DIR$ OPTIMIZE (-haggress)
409+
#endif
408410
integer, intent(in) :: t_step
409411
real(wp), intent(inout) :: time_avg
410412

411413
integer :: i, j, k, l, q !< Generic loop iterator
412414

415+
real(wp) :: start, finish
416+
413417
! Stage 1 of 1
418+
call cpu_time(start)
414419
call nvtxStartRange("TIMESTEP")
415420

416421
call s_compute_rhs(q_cons_ts(1)%vf, q_T_sf, q_prim_vf, bc_type, rhs_vf, pb_ts(1)%sf, rhs_pb, mv_ts(1)%sf, rhs_mv, t_step, time_avg, 1)
@@ -509,12 +514,24 @@ contains
509514

510515
call nvtxEndRange
511516

517+
call cpu_time(finish)
518+
519+
wall_time = abs(finish - start)
520+
521+
if (t_step >= 2) then
522+
wall_time_avg = (wall_time + (t_step - 2)*wall_time_avg)/(t_step - 1)
523+
else
524+
wall_time_avg = 0._wp
525+
end if
526+
512527
end subroutine s_1st_order_tvd_rk
513528

514529
!> 2nd order TVD RK time-stepping algorithm
515530
!! @param t_step Current time-step
516531
impure subroutine s_2nd_order_tvd_rk(t_step, time_avg)
517-
532+
#ifdef _CRAYFTN
533+
!DIR$ OPTIMIZE (-haggress)
534+
#endif
518535
integer, intent(in) :: t_step
519536
real(wp), intent(inout) :: time_avg
520537

@@ -738,12 +755,22 @@ contains
738755

739756
call cpu_time(finish)
740757

758+
wall_time = abs(finish - start)
759+
760+
if (t_step >= 2) then
761+
wall_time_avg = (wall_time + (t_step - 2)*wall_time_avg)/(t_step - 1)
762+
else
763+
wall_time_avg = 0._wp
764+
end if
765+
741766
end subroutine s_2nd_order_tvd_rk
742767

743768
!> 3rd order TVD RK time-stepping algorithm
744769
!! @param t_step Current time-step
745770
impure subroutine s_3rd_order_tvd_rk(t_step, time_avg)
746-
771+
#ifdef _CRAYFTN
772+
!DIR$ OPTIMIZE (-haggress)
773+
#endif
747774
integer, intent(IN) :: t_step
748775
real(wp), intent(INOUT) :: time_avg
749776

@@ -1070,7 +1097,14 @@ contains
10701097
call nvtxEndRange
10711098
call cpu_time(finish)
10721099

1073-
time = time + (finish - start)
1100+
wall_time = abs(finish - start)
1101+
1102+
if (t_step >= 2) then
1103+
wall_time_avg = (wall_time + (t_step - 2)*wall_time_avg)/(t_step - 1)
1104+
else
1105+
wall_time_avg = 0._wp
1106+
end if
1107+
10741108
end if
10751109
end subroutine s_3rd_order_tvd_rk
10761110

@@ -1102,7 +1136,13 @@ contains
11021136

11031137
call cpu_time(finish)
11041138

1105-
time = time + (finish - start)
1139+
wall_time = abs(finish - start)
1140+
1141+
if (t_step >= 2) then
1142+
wall_time_avg = (wall_time + (t_step - 2)*wall_time_avg)/(t_step - 1)
1143+
else
1144+
wall_time_avg = 0._wp
1145+
end if
11061146

11071147
end subroutine s_strang_splitting
11081148

0 commit comments

Comments
 (0)