SF_TIMER
Description
SciFortran module for timers
Quick access
- Routines:
eta(),progress(),start_progress(),start_timer(),stop_progress(),stop_timer(),t_start(),t_stop()
Used modules
sf_mpi: SciFortran MPI interface
Subroutines and functions
- interface sf_timer/start_progress([title, unit])
Generic interface to start a timer, to be stopped with
stop_progress. It is an alias ofstart_timer, whose arguments are documented there.At the moment of the call the timer records three clocks: the wall clock (
system_clock, orMPI_Wtimewhen compiled with MPI and MPI is initialized), the CPU time (cpu_time) and the date and time (date_and_time). It also resets the state used byetaandprogress, which need therefore a started timer. Timers can be nested, the last started being the first to be stopped, up to 1000 at the same time: the program stops otherwise.All the output of the timer, i.e. the
title, the messages ofetaandprogress, and the elapsed time printed bystop_progress, is written to the unitunit. The default is the standard output (unit 6), plus the rank of the process when compiled with MPI, so that each process writes to its own unit; unit 5 is replaced by 6.- Options:
title [character(len=*)] – optional: title, printed on the unit of the timer
unit [integer] – optional: output unit of the timer, default 6 (+ MPI rank)
- interface sf_timer/stop_progress([msg])
Generic interface to stop the most recently started timer, see
start_progress. It is an alias ofstop_timer, whose argument is documented there.The elapsed CPU time and, in parentheses, the elapsed wall-clock time are printed on the unit of the timer, both as
hhh:mm:ss.mmm, followed bymsgif present:CPU time (wall time): hhh:mm:ss.mmm (hhh:mm:ss.mmm) : msg. The timer is then released.- Options:
msg [character(len=*)] – optional: message, printed after the elapsed time
- function sf_timer/t_start()
This function starts a timer, to be read with
t_stop, to measure the time elapsed between two calls, e.g. for profiling. It is independent ofstart_timer. Timers can be nested, the last started being the first to be stopped, up to 1000 at the same time: the program stops otherwise. The wall clock isMPI_Wtimewhen compiled with MPI and MPI is initialized,system_clockotherwise. The returned value is always zero.- Result:
pr_t [real] – always 0
- function sf_timer/t_stop()
This function stops the timer most recently started with
t_start, releases it, and returns the time elapsed since its start, in seconds.- Result:
pr_t [real] – time elapsed since the matching t_start, in seconds
- subroutine sf_timer/start_timer([title, unit])
- Options:
title [character(len=*)] – optional: title, printed on the unit of the timer
unit [integer] – optional: output unit of the timer, default 6 (+ MPI rank)
- subroutine sf_timer/stop_timer([msg])
- Options:
msg [character(len=*)] – optional: message, printed after the elapsed time
- subroutine sf_timer/eta(i, l[, step, method])
This subroutine prints the Expected Time of Arrival (ETA) of a loop of
Literations, to be called at every iterationi. It requires a timer started withstart_timer, and it writes on the unit of that timer.The ETA is the average time per iteration spent so far, times the number of iterations, minus the elapsed time. It is printed only when the completion percentage reaches a multiple of
step, asNNN% |ETA: hhh:mm:ss.mmm; at 10%, 50% and 100% the date and time are appended. The internal state is reset wheni==L, so that the routine can be used for the next loop. The clock used is selected by the first character ofmethod:c(default) forcpu_time,dfordate_and_time, anything else, e.g.s, forsystem_clock(wall time).- Parameters:
i [integer] – current iteration
l [integer] – total number of iterations
- Options:
step [integer] – optional: print every step percent, default 10
method [character(len=*)] – optional: clock, ‘c’ cpu_time (default), ‘d’ date_and_time, ‘s’ system_clock
- subroutine sf_timer/progress(i, imax[, method])
This subroutine prints a progress bar with the Expected Time of Arrival (ETA), to be called at every iteration
iof a loop ofimaxiterations. It requires a timer started withstart_timer, and it writes on the unit of that timer.The bar has 50 characters, and it is updated in place on the same line, followed by the ETA computed as in
eta:NNN% |***** | ETA h:mm:ss.mmm. The line is terminated by the last call,i==imax. The clock used is selected by the first character ofmethod:c(default) forcpu_time,dfordate_and_time, anything else, e.g.s, forsystem_clock(wall time).- Parameters:
i [integer] – current iteration
imax [integer] – total number of iterations
- Options:
method [character(len=*)] – optional: clock, ‘c’ cpu_time (default), ‘d’ date_and_time, ‘s’ system_clock