ParaMonte Fortran 2.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
pm_timer.F90
Go to the documentation of this file.
1!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
3!!!! !!!!
4!!!! ParaMonte: Parallel Monte Carlo and Machine Learning Library. !!!!
5!!!! !!!!
6!!!! Copyright (C) 2012-present, The Computational Data Science Lab !!!!
7!!!! !!!!
8!!!! This file is part of the ParaMonte library. !!!!
9!!!! !!!!
10!!!! LICENSE !!!!
11!!!! !!!!
12!!!! https://github.com/cdslaborg/paramonte/blob/main/LICENSE.md !!!!
13!!!! !!!!
14!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
15!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
16
96
97!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
98
100
101#if CHECK_ENABLED
102#define CHECK_ASSERTION(LINE,ASSERTION,MSG) \
103block; \
104use pm_err, only: getFine; \
105use pm_val2str, only: getStr; \
106use pm_err, only: setAsserted; \
107call setAsserted(ASSERTION,getFine(__FILE__,LINE)//MODULE_NAME//MSG); \
108end block;
109#else
110#define CHECK_ASSERTION(LINE,ASSERTION,MSG) continue;
111#endif
112
113 use pm_kind, only: SK, LK, IKD, RKD
114
115 implicit none
116
117 character(*, SK), parameter :: MODULE_NAME = "@pm_timer"
118
119!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
120
129 abstract interface
130 function getTime_proc(since) result(timeInSec)
131 use pm_kind, only: RKD
132 real(RKD), intent(in), optional :: since
133 real(RKD) :: timeInSec
134 end function
135 end interface
136
137 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
138
153 abstract interface
154 subroutine setIdle_proc(seconds)
155 use pm_kind, only: RKD
156 real(RKD), intent(in) :: seconds
157 end subroutine
158 end interface
159
160 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
161
212 type, abstract :: timer_type
213 real(RKD) :: start
215 real(RKD) :: clock
217 real(RKD) :: delta
219 real(RKD) :: resol
221 contains
222 procedure(getTime_proc), nopass, deferred :: time
223 procedure(setIdle_proc), nopass, deferred :: wait
224 end type
225
226 interface timer_type
227 module procedure :: timer_typer
228 end interface
229
230!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
231
271 type, extends(timer_type) :: timerCPU_type
272 contains
273 procedure, nopass :: time => getTimeCPU
274 procedure, nopass :: wait => setIdleCPU
275 end type
276
277 interface timerCPU_type
278 module procedure :: timerCPU_typer
279 end interface
280
281!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
282
322 type, extends(timer_type) :: timerDAT_type
323 contains
324 procedure, nopass :: time => getTimeDAT
325 procedure, nopass :: wait => setIdleDAT
326 end type
327
328 interface timerDAT_type
329 module procedure :: timerDAT_typer
330 end interface
331
332!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
333
376#if MPI_ENABLED
377 type, extends(timer_type) :: timerMPI_type
378 contains
379 procedure, nopass :: time => getTimeMPI
380 procedure, nopass :: wait => setIdleMPI
381 end type
382
383 interface timerMPI_type
384 module procedure :: timerMPI_typer
385 end interface
386#endif
387
388!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
389
432#if OMP_ENABLED
433 type, extends(timer_type) :: timerOMP_type
434 contains
435 procedure, nopass :: time => getTimeOMP
436 procedure, nopass :: wait => setIdleOMP
437 end type
438
439 interface timerOMP_type
440 module procedure :: timerOMP_typer
441 end interface
442#endif
443
444!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
445
446 !!> \brief
447 !!> This s the derived type for generating objects containing information about the system clock count.
448 !!>
449 !!> \final{Count_type}
450 !!>
451 !!> \author
452 !!> Amir Shahmoradi, March 22, 2012, 00:00 AM, National Institute for Fusion Studies, The University of Texas at Austin
453 !type :: SysClockCount_type
454 ! integer(IKD) :: start = 0_IKD !< The scalar `integer` of kind double precision \IKD containing the processor-dependent starting clock counts of the system.
455 ! integer(IKD) :: clock = 0_IKD !< The scalar `integer` of kind double precision \IKD containing the total processor clock counts since `start`.
456 ! integer(IKD) :: delta = 0_IKD !< The scalar `integer` of kind double precision \IKD containing total processor clock count since the last clock count measurement.
457 ! integer(IKD) :: max = 0_IKD !< The scalar `integer` of kind double precision \IKD containing maximum value that the processor count may take, or `0` if there is no clock.
458 ! integer(IKD) :: rate = 0_IKD !< The scalar `integer` of kind double precision \IKD containing number of clock counts per second, or `0` if there is no clock.
459 !end type
460
461 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
462
502 type, extends(timer_type) :: timerSYS_type
503 !type(SysClockCount_type) :: Count !< An object of type [SysClockCount_type](@ref pm_timer::SysClockCount_type) containing information about the system clock.
504 contains
505 procedure, nopass :: time => getTimeSYS
506 procedure, nopass :: wait => setIdleSYS
507 end type
508
509 interface timerSYS_type
510 module procedure :: timerSYS_typer
511 end interface
512
513!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
514!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
515!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
516
517contains
518
519!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
520!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
521!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
522
556 function timer_typer() result(timer)
557#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
558 !DEC$ ATTRIBUTES DLLEXPORT :: timer_typer
559#endif
560#if MPI_ENABLED
561 type(timerMPI_type) :: timer
562 timer = timerMPI_type()
563#elif OMP_ENABLED
564 type(timerOMP_type) :: timer
565 timer = timerOMP_type()
566#else
567 type(timerSYS_type) :: timer
568 timer = timerSYS_type()
569#endif
570 end function
571
572!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
573
601 function timerCPU_typer() result(timer)
602#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
603 !DEC$ ATTRIBUTES DLLEXPORT :: timerCPU_typer
604#endif
605 type(timerCPU_type) :: timer
606 timer%resol = getResTimerCPU()
607 timer%start = timer%time()
608 timer%delta = 0._RKD
609 timer%clock = 0._RKD
610 end function
611
612!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
613
641 function timerDAT_typer() result(timer)
642#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
643 !DEC$ ATTRIBUTES DLLEXPORT :: timerDAT_typer
644#endif
645 type(timerDAT_type) :: timer
646 timer%resol = 0.001_RKD
647 timer%start = timer%time()
648 timer%delta = 0._RKD
649 timer%clock = 0._RKD
650 end function
651
652!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
653
688#if MPI_ENABLED
689 function timerMPI_typer() result(timer)
690#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
691 !DEC$ ATTRIBUTES DLLEXPORT :: timerMPI_typer
692#endif
693 use mpi !mpi_f08, only: mpi_initialized, mpi_init, mpi_wtick
694 type(timerMPI_type) :: timer
695 logical :: initialized
696 integer :: ierrMPI
697!#if CHECK_ENABLED
698! block
699! use pm_err, only: setAsserted
700! use pm_val2str, only: getStr
701! logical :: initialized, finalized
702! integer :: ierrMPI
703! call mpi_initialized(initialized, ierrMPI)
704! call setAsserted(ierrMPI /= 0 .and. initialized, MODULE_NAME//SK_"@timerMPI_typer(): The MPI library must be initialized before attempting to call the MPI timer.")
705! call mpi_finalized(finalized, ierrMPI)
706! call setAsserted(ierrMPI /= 0 .and. finalized, MODULE_NAME//SK_"@timerMPI_typer(): The MPI library must not be finalized prior to calling the MPI timer.")
707! end block
708!#endif
709 call mpi_initialized(initialized, ierrMPI)
710 if (.not. initialized .and. ierrMPI == 0) call mpi_init(ierrMPI)
711 if (ierrMPI /= 0) error stop MODULE_NAME//SK_"@timerMPI_typer(): Failed to initialize the MPI library."
712 timer%resol = real(mpi_wtick(), RKD)
713 timer%start = timer%time()
714 timer%delta = 0._RKD
715 timer%clock = 0._RKD
716 end function
717#endif
718
719!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
720
751#if OMP_ENABLED
752 function timerOMP_typer() result(timer)
753#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
754 !DEC$ ATTRIBUTES DLLEXPORT :: timerOMP_typer
755#endif
756 use omp_lib
757 type(timerOMP_type) :: timer
758 timer%resol = real(omp_get_wtick(), RKD)
759 timer%start = timer%time()
760 timer%delta = 0._RKD
761 timer%clock = 0._RKD
762 end function
763#endif
764
765!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
766
794 function timerSYS_typer() result(timer)
795#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
796 !DEC$ ATTRIBUTES DLLEXPORT :: timerSYS_typer
797#endif
798 type(timerSYS_type) :: timer
799 timer%resol = getResTimerSYS()
800 timer%start = timer%time()
801 timer%delta = 0._RKD
802 timer%clock = 0._RKD
803 end function
804
805!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
806!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
807!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
808
857 function getTime(since) result(timeInSec)
858#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
859 !DEC$ ATTRIBUTES DLLEXPORT :: getTime
860#endif
861 real(RKD), intent(in), optional :: since
862 real(RKD) :: timeInSec
863#if MPI_ENABLED
864 timeInSec = getTimeMPI(since)
865#elif OMP_ENABLED
866 timeInSec = getTimeOMP(since)
867#else
868 timeInSec = getTimeSYS(since)
869#endif
870 end function
871
872!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
873
917 function getTimeCPU(since) result(timeInSec)
918#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
919 !DEC$ ATTRIBUTES DLLEXPORT :: getTimeCPU
920#endif
921 real(RKD), intent(in), optional :: since
922 real(RKD) :: timeInSec
923 call cpu_time(timeInSec)
924 CHECK_ASSERTION(__LINE__, timeInSec >= 0._RKD, SK_"@getTimeCPU(): The CPU does not have a clock.") ! fpp
925 if (present(since)) timeInSec = timeInSec - since
926 end function
927
928!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
929
972 function getTimeDAT(since) result(timeInSec)
973#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
974 !DEC$ ATTRIBUTES DLLEXPORT :: getTimeDAT
975#endif
976 use pm_kind, only: IK, RKD
977 use pm_dateTime, only: getJulianDay
979 real(RKD), intent(in), optional :: since
980 real(RKD) :: timeInSec
981 integer(IK) :: values(8)
982 call date_and_time(values = values)
983 timeInSec = getJulianDay(values) * SECONDS_PER_DAY
984 if (present(since)) timeInSec = timeInSec - since
985 end function
986
987!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
988
1034#if MPI_ENABLED
1035 function getTimeMPI(since) result(timeInSec)
1036#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
1037 !DEC$ ATTRIBUTES DLLEXPORT :: getTimeMPI
1038#endif
1039 use mpi !mpi_f08, only: mpi_wtime
1040 use pm_kind, only: IK, RKD
1041 real(RKD), intent(in), optional :: since
1042 real(RKD) :: timeInSec
1043 timeInSec = mpi_wtime()
1044 if (present(since)) timeInSec = timeInSec - since
1045 end function
1046#endif
1047
1048!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1049
1095#if OMP_ENABLED
1096 function getTimeOMP(since) result(timeInSec)
1097#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
1098 !DEC$ ATTRIBUTES DLLEXPORT :: getTimeOMP
1099#endif
1100 use pm_kind, only: IK, RKD
1101 use omp_lib, only: omp_get_wtime
1102 real(RKD), intent(in), optional :: since
1103 real(RKD) :: timeInSec
1104 timeInSec = omp_get_wtime()
1105 if (present(since)) timeInSec = timeInSec - since
1106 end function
1107#endif
1108
1109!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1110 end do end do
1197 function getTimeSYS(since) result(timeInSec)
1198#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
1199 !DEC$ ATTRIBUTES DLLEXPORT :: getTimeSYS
1200#endif
1201 real(RKD), intent(in), optional :: since
1202 real(RKD) :: timeInSec
1203 real(RKD) :: count_rate
1204 integer(IKD) :: count
1205 !integer(IKD) :: cmax
1206 call system_clock(count, count_rate)!, count_max = cmax)
1207 CHECK_ASSERTION(__LINE__, count > 0_IKD .and. count_rate > 0._RKD, SK_"@getTimeSYS(): The system does not have a clock.") ! .and. cmax > 0_IKD
1208 timeInSec = count / count_rate
1209 if (present(since)) timeInSec = timeInSec - since
1210 end function
1211
1212!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1213!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1214!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1215
1260 function getResTimer() result(resolution)
1261#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
1262 !DEC$ ATTRIBUTES DLLEXPORT :: getResTimer
1263#endif
1264 real(RKD) :: resolution
1265#if MPI_ENABLED
1266 resolution = getResTimerMPI()
1267#elif OMP_ENABLED
1268 resolution = getResTimerOMP()
1269#else
1270 resolution = getResTimerSYS()
1271#endif
1272 end function
1273
1274!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1275
1315 function getResTimerCPU() result(resolution)
1316#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
1317 !DEC$ ATTRIBUTES DLLEXPORT :: getResTimerCPU
1318#endif
1319 real(RKD) :: resolution
1320 real(RKD) :: resolution_
1321 call cpu_time(time = resolution_)
1322 CHECK_ASSERTION(__LINE__, resolution_ >= 0._RKD, SK_"@getResTimerCPU(): The CPU does not have a clock.") ! fpp
1323 do
1324 call cpu_time(time = resolution)
1325 if (resolution == resolution_) cycle
1326 resolution = resolution - resolution_
1327 exit
1328 end do
1329 end function
1330
1331!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1332
1372 pure function getResTimerDAT() result(resolution)
1373#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
1374 !DEC$ ATTRIBUTES DLLEXPORT :: getResTimerDAT
1375#endif
1376 real(RKD) :: resolution
1377 resolution = 0.001_RKD
1378 end function
1379
1380!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1381
1422#if MPI_ENABLED
1423 function getResTimerMPI() result(resolution)
1424#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
1425 !DEC$ ATTRIBUTES DLLEXPORT :: getResTimerMPI
1426#endif
1427 use mpi !mpi_f08, only: mpi_wtick
1428 real(RKD) :: resolution
1429 resolution = real(mpi_wtick(), RKD)
1430 end function
1431#endif
1432
1433!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1434
1475#if OMP_ENABLED
1476 function getResTimerOMP() result(resolution)
1477#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
1478 !DEC$ ATTRIBUTES DLLEXPORT :: getResTimerOMP
1479#endif
1480 use omp_lib, only: omp_get_wtick
1481 real(RKD) :: resolution
1482 resolution = real(omp_get_wtick(), RKD)
1483 end function
1484#endif
1485
1486!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1487
1527 function getResTimerSYS() result(resolution)
1528#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
1529 !DEC$ ATTRIBUTES DLLEXPORT :: getResTimerSYS
1530#endif
1531 real(RKD) :: resolution
1532 call system_clock(count_rate = resolution)
1533 CHECK_ASSERTION(__LINE__, resolution > 0._RKD, SK_"@getResTimerSYS(): The system does not have a clock.") ! fpp
1534 resolution = 1._RKD / resolution
1535 end function
1536
1537!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1538!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1539!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1540
1592 subroutine setIdle(seconds)
1593#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
1594 !DEC$ ATTRIBUTES DLLEXPORT :: setIdle
1595#endif
1596 use pm_kind, only: RKD
1597 real(RKD) , intent(in) :: seconds
1598#if MPI_ENABLED
1599 call setIdleMPI(seconds)
1600#elif OMP_ENABLED
1601 call setIdleOMP(seconds)
1602#else
1603 call setIdleSYS(seconds)
1604#endif
1605 end subroutine
1606
1607!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1608
1657 subroutine setIdleCPU(seconds)
1658#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
1659 !DEC$ ATTRIBUTES DLLEXPORT :: setIdleCPU
1660#endif
1661 use pm_kind, only: RKD
1662 real(RKD) , intent(in) :: seconds
1663 real(RKD) :: since
1664 since = getTimeCPU()
1665 do
1666 if (getTimeCPU() - since > seconds) exit
1667 end do
1668 end subroutine
1669
1670!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1671
1720 subroutine setIdleDAT(seconds)
1721#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
1722 !DEC$ ATTRIBUTES DLLEXPORT :: setIdleDAT
1723#endif
1724 use pm_kind, only: RKD
1725 real(RKD) , intent(in) :: seconds
1726 real(RKD) :: since
1727 since = getTimeDAT()
1728 do
1729 if (getTimeDAT() - since > seconds) exit
1730 end do
1731 end subroutine
1732
1733!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1734
1785#if MPI_ENABLED
1786 subroutine setIdleMPI(seconds)
1787#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
1788 !DEC$ ATTRIBUTES DLLEXPORT :: setIdleMPI
1789#endif
1790 use pm_kind, only: RKD
1791 real(RKD) , intent(in) :: seconds
1792 real(RKD) :: since
1793 since = getTimeMPI()
1794 do
1795 if (getTimeMPI() - since > seconds) exit
1796 end do
1797 end subroutine
1798#endif
1799
1800!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1801
1848#if OMP_ENABLED
1849 subroutine setIdleOMP(seconds)
1850#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
1851 !DEC$ ATTRIBUTES DLLEXPORT :: setIdleOMP
1852#endif
1853 use pm_kind, only: RKD
1854 real(RKD) , intent(in) :: seconds
1855 real(RKD) :: since
1856 since = getTimeOMP()
1857 do
1858 if (getTimeOMP() - since > seconds) exit
1859 end do
1860 end subroutine
1861#endif
1862
1863!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1864
1913 subroutine setIdleSYS(seconds)
1914#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
1915 !DEC$ ATTRIBUTES DLLEXPORT :: setIdleSYS
1916#endif
1917 use pm_kind, only: RKD
1918 real(RKD) , intent(in) :: seconds
1919 real(RKD) :: since
1920 since = getTimeSYS()
1921 do
1922 if (getTimeSYS() - since > seconds) exit
1923 end do
1924 end subroutine
1925
1926!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1927!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1928!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1929
1930end module pm_timer ! LCOV_EXCL_LINE
Generate and return the Julian Date (Julian Day Number JDN + the fractional part of the day) from the...
Generate and return a decorated string resulting from the concatenation of getFile(FILE) and getLine(...
Definition: pm_err.F90:382
Verify the input assertion holds and if it does not, print the (optional) input message on stdout and...
Definition: pm_err.F90:735
This is the abstract interface of the setTime static type-bound procedure component of timer_type abs...
Definition: pm_timer.F90:130
This is the abstract interface of the wait static type-bound procedure component of timer_type abstra...
Definition: pm_timer.F90:154
Generate and return the conversion of the input value to an output Fortran string,...
Definition: pm_val2str.F90:167
This module contains classes and procedures for computing, manipulating, and styling dates and times.
integer(IK), parameter SECONDS_PER_DAY
The constant scalar of type integer of kind IK containing the number of seconds per day.
This module contains classes and procedures for reporting and handling errors.
Definition: pm_err.F90:52
character(*, SK), parameter MODULE_NAME
Definition: pm_err.F90:58
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 IKD
The double precision integer kind in Fortran mode. On most platforms, this is a 64-bit integer kind.
Definition: pm_kind.F90:564
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
This module contains the timer procedures and derived types to facilitate timing applications at runt...
Definition: pm_timer.F90:99
real(RKD) function getTimeDAT(since)
Generate and return the calendrical clock time in units of seconds since the specified time since or ...
Definition: pm_timer.F90:973
real(RKD) function getTimeMPI(since)
Generate and return the MPI clock time in units of seconds since the specified time since or since an...
Definition: pm_timer.F90:1036
real(RKD) function getTimeOMP(since)
Generate and return the OpenMP clock time in units of seconds since the specified time since or since...
Definition: pm_timer.F90:1097
type(timerCPU_type) function timerCPU_typer()
This is the constructor of the timerCPU_type class.
Definition: pm_timer.F90:602
real(RKD) function getTimeSYS(since)
Generate and return the system clock time in units of seconds since the specified time since or since...
Definition: pm_timer.F90:1198
pure real(RKD) function getResTimerDAT()
Generate and return the time resolution of the Fortran intrinsic date_and_time(), used in timerDAT_ty...
Definition: pm_timer.F90:1373
subroutine setIdleSYS(seconds)
Set the processor in sleep mode for the input requested number of seconds via the Fortran intrinsic s...
Definition: pm_timer.F90:1914
real(RKD) function getResTimerMPI()
Generate and return the time resolution of the MPI intrinsic timer, used in timerMPI_type,...
Definition: pm_timer.F90:1424
subroutine setIdleMPI(seconds)
Set the processor in sleep mode for the input requested number of seconds via the MPI intrinsic timer...
Definition: pm_timer.F90:1787
real(RKD) function getTimeCPU(since)
Generate and return the CPU time in units of seconds since the specified time since or since an arbit...
Definition: pm_timer.F90:918
subroutine setIdleDAT(seconds)
Set the processor in sleep mode for the input requested number of seconds via the Fortran intrinsic d...
Definition: pm_timer.F90:1721
subroutine setIdleCPU(seconds)
Set the processor in sleep mode for the input requested number of seconds via the Fortran intrinsic c...
Definition: pm_timer.F90:1658
real(RKD) function getResTimer()
Generate and return the time resolution by the build-time default timer of the ParaMonte library as u...
Definition: pm_timer.F90:1261
type(timerMPI_type) type(timerOMP_type) type(timerSYS_type) function timer_typer()
This is the constructor of the timer_type class.
Definition: pm_timer.F90:557
real(RKD) function getResTimerCPU()
Generate and return the time resolution of the Fortran intrinsic cpu_time(), used in timerCPU_type,...
Definition: pm_timer.F90:1316
real(RKD) function getResTimerSYS()
Generate and return the time resolution of the Fortran intrinsic system_clock(), used in timerSYS_typ...
Definition: pm_timer.F90:1528
subroutine setIdleOMP(seconds)
Set the processor in sleep mode for the input requested number of seconds via the OpenMP intrinsic ti...
Definition: pm_timer.F90:1850
type(timerMPI_type) function timerMPI_typer()
This is the constructor of the timerMPI_type class.
Definition: pm_timer.F90:690
type(timerOMP_type) function timerOMP_typer()
This is the constructor of the timerOMP_type class.
Definition: pm_timer.F90:753
type(timerSYS_type) function timerSYS_typer()
This is the constructor of the timerSYS_type class.
Definition: pm_timer.F90:795
type(timerDAT_type) function timerDAT_typer()
This is the constructor of the timerDAT_type class.
Definition: pm_timer.F90:642
real(RKD) function getResTimerOMP()
Generate and return the time resolution of the OpenMP intrinsic timer, used in timerOMP_type,...
Definition: pm_timer.F90:1477
subroutine setIdle(seconds)
Set the processor in sleep mode for the input requested number of seconds via the default timer of th...
Definition: pm_timer.F90:1593
real(RKD) function getTime(since)
Generate and return the time in units of seconds since the specified time since or since an arbitrary...
Definition: pm_timer.F90:858
This module contains the generic procedures for converting values of different types and kinds to For...
Definition: pm_val2str.F90:58
This is the timerCPU_type class, containing attributes and static methods for setting up a timer base...
Definition: pm_timer.F90:271
This is the timerDAT_type class, containing attributes and static methods for setting up a timer base...
Definition: pm_timer.F90:322
This is the timerMPI_type class, containing attributes and static methods for setting up a timer base...
Definition: pm_timer.F90:377
This is the timerMPI_type class, containing attributes and static methods for setting up a timer base...
Definition: pm_timer.F90:433
This is the timerSYS_type class, containing attributes and static methods for setting up a timer base...
Definition: pm_timer.F90:502
This is the abstract base derived type that serves as a simple container template for other timer cla...
Definition: pm_timer.F90:212