mod_timing Module

Module to provide timing facilities.

Usage

The simplest way is using the module variable.

Using wall time

call tic()
call slow_operation()
call toc("slow operation is done")

or CPU time

call cputic()
call slow_operation()
call cputoc("slow operation is done")

Alternatively, if thread safety is required, you can keep track of the start time yourself.

integer :: start_time
call tic(start_time)
call slow_operation()
call toc("slow operation is done", start_time)

or

real :: start_time
call cputic(start_time)
call slow_operation()
call cputoc("slow operation is done", start_time)


Contents


Variables

TypeVisibilityAttributesNameInitial
integer, private, save:: wall_clock_tic =-1000

Wall clock time at last call of tic(), init -1000 to easily detect incorrect use.

real(kind=dp), private, save:: cpu_clock_tic =-1000.0_dp

CPU time at last call of cputic(), init -1000 to easily detect incorrect use.


Derived Types

type, public :: timer_t

Components

TypeVisibilityAttributesNameInitial
integer, private :: start_time
integer, private :: program_start_time
real(kind=dp), public :: init_time
real(kind=dp), public :: matrix_time
real(kind=dp), public :: evp_time
real(kind=dp), public :: eigenfunction_time
real(kind=dp), public :: datfile_time

Type-Bound Procedures

procedure, public :: start_timer
procedure, public :: end_timer
procedure, public :: get_total_time

Functions

public function new_timer() result(timer)

Arguments

None

Return Value type(timer_t)

private function end_timer(this) result(elapsed_time)

Arguments

TypeIntentOptionalAttributesName
class(timer_t), intent(inout) :: this

Return Value real(kind=dp)

private function get_total_time(this) result(total_time)

Arguments

TypeIntentOptionalAttributesName
class(timer_t), intent(in) :: this

Return Value real(kind=dp)


Subroutines

private subroutine start_timer(this)

Arguments

TypeIntentOptionalAttributesName
class(timer_t), intent(inout) :: this

public subroutine tic(start_time)

Subroutine to start a wall clock timer.

Read more…

Arguments

TypeIntentOptionalAttributesName
integer, intent(out), optional :: start_time

Optional output for the start time. If not present the time is written to a module variable.

public subroutine toc(message, start_time, level)

Subroutine to end a wall clock timer.

Read more…

Arguments

TypeIntentOptionalAttributesName
character(len=*), intent(in) :: message

Message to log along elapsed time.

integer, intent(in), optional :: start_time

Optional starting time. If not present the time recorded in the module variable is used.

character(len=*), intent(in), optional :: level

The level (severity) of the message, default is "debug".

public subroutine cputic(start_time)

Subroutine to start a CPU timer.

Read more…

Arguments

TypeIntentOptionalAttributesName
real, intent(out), optional :: start_time

Optional output for the start time. If not present the time is written to a module variable.

public subroutine cputoc(message, start_time, level)

Subroutine to end a CPU timer.

Read more…

Arguments

TypeIntentOptionalAttributesName
character(len=*), intent(in) :: message

Message to log along elapsed time.

real(kind=dp), intent(in), optional :: start_time

Optional starting time. If not present the time recorded in the module variable is used.

character(len=*), intent(in), optional :: level

The level (severity) of the message, default is "debug".