ParaMonte Fortran 2.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
pm_timer::timer_type Interface Reference

This is the abstract base derived type that serves as a simple container template for other timer classes in the ParaMonte library. More...

Inheritance diagram for pm_timer::timer_type:

Public Member Functions

procedure(getTime_proc), deferred, nopass time
 See getTime_proc. More...
 
procedure(setIdle_proc), deferred, nopass wait
 See setIdle_proc. More...
 
type(timerMPI_type) type(timerOMP_type) type(timerSYS_type) function timer_typer ()
 This is the constructor of the timer_type class.
More...
 

Public Attributes

real(RKD) start
 The protected scalar real of kind double precision RKD provided as a convenience for the user to contain the start time of the timer since the processor epoch (a processor-dependent past time) in seconds.
More...
 
real(RKD) clock
 The scalar real of kind double precision RKD provided as a convenience for the user to contain the total time in seconds elapsed since the start of the timer.
The clock time can be readily can be computed as timer%clock = timer%time(since = timer%start).
More...
 
real(RKD) delta
 The scalar real of kind double precision RKD provided as a convenience for the user to contain the delta time in seconds since the last timing (last timer call).
The delta time can be readily can be computed as timer%delta = timer%time(since = timer%start) - timer%clock where timer%clock is the last clock read as timer%clock = timer%time(since = timer%start).
More...
 
real(RKD) resol
 The protected scalar real of kind double precision RKD provided as a convenience for the user to contain the time in seconds between the timer clock tics.
More...
 

Detailed Description

This is the abstract base derived type that serves as a simple container template for other timer classes in the ParaMonte library.

Timer classes derived from based on this abstract type minimally contain components to store,

  1. the start time of a timer in seconds (since the processor-dependent epoch).
  2. the clock in seconds (optionally computed since the start of the timer).
  3. the delta elapsed time (optionally computed since the last call to the timer in seconds).
  4. the resolution of the timer in seconds.

See the documentation of timer_typer for the non-default class constructor interface for this type.
See also the documentation details of pm_timer.


Possible calling interfaces

use pm_timer, only: timer_type
class(timer_type), allocatable :: timer
timer = timer_type()
This module contains the timer procedures and derived types to facilitate timing applications at runt...
Definition: pm_timer.F90:99
This is the abstract base derived type that serves as a simple container template for other timer cla...
Definition: pm_timer.F90:212
See also
timer_type
timerDAT_type
timerMPI_type
timerOMP_type
timerSYS_type


Example usage

1program example
2
3 use pm_kind, only: IK, LK, SK, RKD
4 use pm_io, only: display_type
5 use pm_timer, only: timer_type
6
7 implicit none
8
9 class(timer_type), allocatable :: timer
10 logical(LK) :: failed
11 integer :: i
12
13 type(display_type) :: disp
14 disp = display_type(file = "main.out.F90")
15
16 call disp%skip()
17 call disp%show("timer = timer_type()")
18 timer = timer_type()
19 call showtimerComponents()
20 call disp%skip()
21
22 call disp%skip()
23 call disp%show("timer%clock = timer%time()")
24 timer%clock = timer%time()
25 call showtimerComponents()
26 call disp%skip()
27
28 call disp%skip()
29 call disp%show("timer%delta = timer%time(since = timer%start)")
30 timer%delta = timer%time(since = timer%start)
31 call showtimerComponents()
32 call disp%skip()
33
34 call disp%skip()
35 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
36 call disp%show("!Idle for a certain number of seconds.")
37 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
38 call disp%skip()
39
40 call disp%skip()
41 call disp%show("timer = timer_type()")
42 timer = timer_type()
43 call disp%show("call timer%wait(seconds = 0.1_RKD)")
44 call timer%wait(seconds = 0.1_RKD)
45 call disp%show("timer%delta = timer%time() - timer%start")
46 timer%delta = timer%time() - timer%start
47 call showtimerComponents()
48 call disp%skip()
49
50contains
51
52 impure subroutine showtimerComponents()
53 call disp%show("timer%start")
54 call disp%show( timer%start )
55 call disp%show("timer%clock")
56 call disp%show( timer%clock )
57 call disp%show("timer%delta")
58 call disp%show( timer%delta )
59 call disp%show("timer%resol")
60 call disp%show( timer%resol )
61 end subroutine
62
63end program example
This is a generic method of the derived type display_type with pass attribute.
Definition: pm_io.F90:11726
This is a generic method of the derived type display_type with pass attribute.
Definition: pm_io.F90:11508
This module contains classes and procedures for input/output (IO) or generic display operations on st...
Definition: pm_io.F90:252
type(display_type) disp
This is a scalar module variable an object of type display_type for general display.
Definition: pm_io.F90:11393
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
Definition: pm_kind.F90:268
integer, parameter LK
The default logical kind in the ParaMonte library: kind(.true.) in Fortran, kind(....
Definition: pm_kind.F90:541
integer, parameter IK
The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in C-Fortran Interoper...
Definition: pm_kind.F90:540
integer, parameter RKD
The double precision real kind in Fortran mode. On most platforms, this is an 64-bit real kind.
Definition: pm_kind.F90:568
integer, parameter SK
The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in C-Fortran Intero...
Definition: pm_kind.F90:539
Generate and return an object of type display_type.
Definition: pm_io.F90:10282

Example Unix compile command via Intel ifort compiler
1#!/usr/bin/env sh
2rm main.exe
3ifort -fpp -standard-semantics -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
4./main.exe

Example Windows Batch compile command via Intel ifort compiler
1del main.exe
2set PATH=..\..\..\lib;%PATH%
3ifort /fpp /standard-semantics /O3 /I:..\..\..\include main.F90 ..\..\..\lib\libparamonte*.lib /exe:main.exe
4main.exe

Example Unix / MinGW compile command via GNU gfortran compiler
1#!/usr/bin/env sh
2rm main.exe
3gfortran -cpp -ffree-line-length-none -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
4./main.exe

Example output
1
2timer = timer_type()
3timer%start
4+2447035.7986874138
5timer%clock
6+0.0000000000000000
7timer%delta
8+0.0000000000000000
9timer%resol
10+0.10000000000000001E-8
11
12
13timer%clock = timer%time()
14timer%start
15+2447035.7986874138
16timer%clock
17+2447035.7987159160
18timer%delta
19+0.0000000000000000
20timer%resol
21+0.10000000000000001E-8
22
23
24timer%delta = timer%time(since = timer%start)
25timer%start
26+2447035.7986874138
27timer%clock
28+2447035.7987159160
29timer%delta
30+0.39528124034404755E-4
31timer%resol
32+0.10000000000000001E-8
33
34
35!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
36!Idle for a certain number of seconds.
37!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38
39
40timer = timer_type()
41call timer%wait(seconds = 0.1_RKD)
42timer%delta = timer%time() - timer%start
43timer%start
44+2447035.7987408568
45timer%clock
46+0.0000000000000000
47timer%delta
48+0.10002901032567024
49timer%resol
50+0.10000000000000001E-8
51
52
Test:
test_pm_timer
Todo:
Critical Priority: The start component of this derived type must become protected as soon as Fortran 2023 is supported by the compilers.


Final Remarks


If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.

  1. If you use any parts or concepts from this library to any extent, please acknowledge the usage by citing the relevant publications of the ParaMonte library.
  2. If you regenerate any parts/ideas from this library in a programming environment other than those currently supported by this ParaMonte library (i.e., other than C, C++, Fortran, MATLAB, Python, R), please also ask the end users to cite this original ParaMonte library.

This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.

Author:
Amir Shahmoradi, March 22, 2012, 2:21 PM, National Institute for Fusion Studies, The University of Texas at Austin

Definition at line 212 of file pm_timer.F90.

Member Function/Subroutine Documentation

◆ time()

procedure(getTime_proc), deferred, nopass pm_timer::timer_type::time

◆ timer_typer()

type(timerMPI_type) type(timerOMP_type) type(timerSYS_type) function pm_timer::timer_type::timer_typer

This is the constructor of the timer_type class.

Upon return, the constructor initializes all components of the timer object.
See also the documentation details of pm_timer.

Returns
timer : The output scalar object of class timer_type.
Specifically, the output of type,
  1. timerMPI_type if the ParaMonte library is built with preprocessor macro MPI_ENABLED defined.
  2. timerOMP_type if the ParaMonte library is built with preprocessor macro OMP_ENABLED defined.
  3. timerSYS_type if the ParaMonte library is built is serial mode.


Possible calling interfaces

use pm_timer, only: timer_type
class(timer_type), allocatable :: timer
timer = timer_type()
Remarks
See the documentation of timer_type for example usage.


Final Remarks


If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.

  1. If you use any parts or concepts from this library to any extent, please acknowledge the usage by citing the relevant publications of the ParaMonte library.
  2. If you regenerate any parts/ideas from this library in a programming environment other than those currently supported by this ParaMonte library (i.e., other than C, C++, Fortran, MATLAB, Python, R), please also ask the end users to cite this original ParaMonte library.

This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.

Author:
Amir Shahmoradi, March 22, 2012, 00:00 AM, National Institute for Fusion Studies, The University of Texas at Austin

Definition at line 556 of file pm_timer.F90.

◆ wait()

procedure(setIdle_proc), deferred, nopass pm_timer::timer_type::wait

Member Data Documentation

◆ clock

real(RKD) pm_timer::timer_type::clock

The scalar real of kind double precision RKD provided as a convenience for the user to contain the total time in seconds elapsed since the start of the timer.
The clock time can be readily can be computed as timer%clock = timer%time(since = timer%start).

Definition at line 215 of file pm_timer.F90.

◆ delta

real(RKD) pm_timer::timer_type::delta

The scalar real of kind double precision RKD provided as a convenience for the user to contain the delta time in seconds since the last timing (last timer call).
The delta time can be readily can be computed as timer%delta = timer%time(since = timer%start) - timer%clock where timer%clock is the last clock read as timer%clock = timer%time(since = timer%start).

Definition at line 217 of file pm_timer.F90.

◆ resol

real(RKD) pm_timer::timer_type::resol

The protected scalar real of kind double precision RKD provided as a convenience for the user to contain the time in seconds between the timer clock tics.

Warning
The object of class timer_type must be initialized with the constructor (e.g., timer = timer_type()) to appropriately set the object resol component to the clock time resolution.

Definition at line 219 of file pm_timer.F90.

◆ start

real(RKD) pm_timer::timer_type::start

The protected scalar real of kind double precision RKD provided as a convenience for the user to contain the start time of the timer since the processor epoch (a processor-dependent past time) in seconds.

Warning
The object of class timer_type must be initialized with the constructor (e.g., timer = timer_type()) to appropriately set the object start component to the processor epoch.

Definition at line 213 of file pm_timer.F90.


The documentation for this interface was generated from the following file: