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 Austin<br>
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 ierrMPI = 0
710 call mpi_initialized(initialized, ierrMPI)
711 if (.not. initialized .and. ierrMPI == 0) call mpi_init(ierrMPI)
712 if (ierrMPI /= 0) error stop MODULE_NAME//SK_"@timerMPI_typer(): Failed to initialize the MPI library."
713 timer%resol = real(mpi_wtick(), RKD)
714 timer%start = timer%time()
715 timer%delta = 0._RKD
716 timer%clock = 0._RKD
717 end function
718#endif
719
720!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
721
752#if OMP_ENABLED
753 function timerOMP_typer() result(timer)
754#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
755 !DEC$ ATTRIBUTES DLLEXPORT :: timerOMP_typer
756#endif
757 use omp_lib
758 type(timerOMP_type) :: timer
759 timer%resol = real(omp_get_wtick(), RKD)
760 timer%start = timer%time()
761 timer%delta = 0._RKD
762 timer%clock = 0._RKD
763 end function
764#endif
765
766!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
767
795 function timerSYS_typer() result(timer)
796#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
797 !DEC$ ATTRIBUTES DLLEXPORT :: timerSYS_typer
798#endif
799 type(timerSYS_type) :: timer
800 timer%resol = getResTimerSYS()
801 timer%start = timer%time()
802 timer%delta = 0._RKD
803 timer%clock = 0._RKD
804 end function
805
806!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
807!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
808!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
809
858 function getTime(since) result(timeInSec)
859#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
860 !DEC$ ATTRIBUTES DLLEXPORT :: getTime
861#endif
862 real(RKD), intent(in), optional :: since
863 real(RKD) :: timeInSec
864#if MPI_ENABLED
865 timeInSec = getTimeMPI(since)
866#elif OMP_ENABLED
867 timeInSec = getTimeOMP(since)
868#else
869 timeInSec = getTimeSYS(since)
870#endif
871 end function
872
873!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
874
918 function getTimeCPU(since) result(timeInSec)
919#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
920 !DEC$ ATTRIBUTES DLLEXPORT :: getTimeCPU
921#endif
922 real(RKD), intent(in), optional :: since
923 real(RKD) :: timeInSec
924 call cpu_time(timeInSec)
925 CHECK_ASSERTION(__LINE__, timeInSec >= 0._RKD, SK_"@getTimeCPU(): The CPU does not have a clock.") ! fpp
926 if (present(since)) timeInSec = timeInSec - since
927 end function
928
929!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
930
973 function getTimeDAT(since) result(timeInSec)
974#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
975 !DEC$ ATTRIBUTES DLLEXPORT :: getTimeDAT
976#endif
977 use pm_kind, only: IK, RKD
978 use pm_dateTime, only: getJulianDay
980 real(RKD), intent(in), optional :: since
981 real(RKD) :: timeInSec
982 integer(IK) :: values(8)
983 call date_and_time(values = values)
984 timeInSec = getJulianDay(values) * SECONDS_PER_DAY
985 if (present(since)) timeInSec = timeInSec - since
986 end function
987
988!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
989
1035#if MPI_ENABLED
1036 function getTimeMPI(since) result(timeInSec)
1037#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
1038 !DEC$ ATTRIBUTES DLLEXPORT :: getTimeMPI
1039#endif
1040 use mpi !mpi_f08, only: mpi_wtime
1041 use pm_kind, only: IK, RKD
1042 real(RKD), intent(in), optional :: since
1043 real(RKD) :: timeInSec
1044 timeInSec = mpi_wtime()
1045 if (present(since)) timeInSec = timeInSec - since
1046 end function
1047#endif
1048
1049!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1050
1096#if OMP_ENABLED
1097 function getTimeOMP(since) result(timeInSec)
1098#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
1099 !DEC$ ATTRIBUTES DLLEXPORT :: getTimeOMP
1100#endif
1101 use pm_kind, only: IK, RKD
1102 use omp_lib, only: omp_get_wtime
1103 real(RKD), intent(in), optional :: since
1104 real(RKD) :: timeInSec
1105 timeInSec = omp_get_wtime()
1106 if (present(since)) timeInSec = timeInSec - since
1107 end function
1108#endif
1109
1110!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1111 end do end do
1198 function getTimeSYS(since) result(timeInSec)
1199#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
1200 !DEC$ ATTRIBUTES DLLEXPORT :: getTimeSYS
1201#endif
1202 real(RKD), intent(in), optional :: since
1203 real(RKD) :: timeInSec
1204 real(RKD) :: count_rate
1205 integer(IKD) :: count
1206 !integer(IKD) :: cmax
1207 call system_clock(count, count_rate)!, count_max = cmax)
1208 CHECK_ASSERTION(__LINE__, count > 0_IKD .and. count_rate > 0._RKD, SK_"@getTimeSYS(): The system does not have a clock.") ! .and. cmax > 0_IKD
1209 timeInSec = count / count_rate
1210 if (present(since)) timeInSec = timeInSec - since
1211 end function
1212
1213!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1214!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1215!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1216
1261 function getResTimer() result(resolution)
1262#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
1263 !DEC$ ATTRIBUTES DLLEXPORT :: getResTimer
1264#endif
1265 real(RKD) :: resolution
1266#if MPI_ENABLED
1267 resolution = getResTimerMPI()
1268#elif OMP_ENABLED
1269 resolution = getResTimerOMP()
1270#else
1271 resolution = getResTimerSYS()
1272#endif
1273 end function
1274
1275!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1276
1316 function getResTimerCPU() result(resolution)
1317#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
1318 !DEC$ ATTRIBUTES DLLEXPORT :: getResTimerCPU
1319#endif
1320 real(RKD) :: resolution
1321 real(RKD) :: resolution_
1322 call cpu_time(time = resolution_)
1323 CHECK_ASSERTION(__LINE__, resolution_ >= 0._RKD, SK_"@getResTimerCPU(): The CPU does not have a clock.") ! fpp
1324 do
1325 call cpu_time(time = resolution)
1326 if (resolution == resolution_) cycle
1327 resolution = resolution - resolution_
1328 exit
1329 end do
1330 end function
1331
1332!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1333
1373 pure function getResTimerDAT() result(resolution)
1374#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
1375 !DEC$ ATTRIBUTES DLLEXPORT :: getResTimerDAT
1376#endif
1377 real(RKD) :: resolution
1378 resolution = 0.001_RKD
1379 end function
1380
1381!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1382
1423#if MPI_ENABLED
1424 function getResTimerMPI() result(resolution)
1425#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
1426 !DEC$ ATTRIBUTES DLLEXPORT :: getResTimerMPI
1427#endif
1428 use mpi !mpi_f08, only: mpi_wtick
1429 real(RKD) :: resolution
1430 resolution = real(mpi_wtick(), RKD)
1431 end function
1432#endif
1433
1434!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1435
1476#if OMP_ENABLED
1477 function getResTimerOMP() result(resolution)
1478#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
1479 !DEC$ ATTRIBUTES DLLEXPORT :: getResTimerOMP
1480#endif
1481 use omp_lib, only: omp_get_wtick
1482 real(RKD) :: resolution
1483 resolution = real(omp_get_wtick(), RKD)
1484 end function
1485#endif
1486
1487!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1488
1528 function getResTimerSYS() result(resolution)
1529#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
1530 !DEC$ ATTRIBUTES DLLEXPORT :: getResTimerSYS
1531#endif
1532 real(RKD) :: resolution
1533 call system_clock(count_rate = resolution)
1534 CHECK_ASSERTION(__LINE__, resolution > 0._RKD, SK_"@getResTimerSYS(): The system does not have a clock.") ! fpp
1535 resolution = 1._RKD / resolution
1536 end function
1537
1538!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1539!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1540!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1541
1593 subroutine setIdle(seconds)
1594#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
1595 !DEC$ ATTRIBUTES DLLEXPORT :: setIdle
1596#endif
1597 use pm_kind, only: RKD
1598 real(RKD) , intent(in) :: seconds
1599#if MPI_ENABLED
1600 call setIdleMPI(seconds)
1601#elif OMP_ENABLED
1602 call setIdleOMP(seconds)
1603#else
1604 call setIdleSYS(seconds)
1605#endif
1606 end subroutine
1607
1608!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1609
1658 subroutine setIdleCPU(seconds)
1659#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
1660 !DEC$ ATTRIBUTES DLLEXPORT :: setIdleCPU
1661#endif
1662 use pm_kind, only: RKD
1663 real(RKD) , intent(in) :: seconds
1664 real(RKD) :: since
1665 since = getTimeCPU()
1666 do
1667 if (getTimeCPU() - since > seconds) exit
1668 end do
1669 end subroutine
1670
1671!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1672
1721 subroutine setIdleDAT(seconds)
1722#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
1723 !DEC$ ATTRIBUTES DLLEXPORT :: setIdleDAT
1724#endif
1725 use pm_kind, only: RKD
1726 real(RKD) , intent(in) :: seconds
1727 real(RKD) :: since
1728 since = getTimeDAT()
1729 do
1730 if (getTimeDAT() - since > seconds) exit
1731 end do
1732 end subroutine
1733
1734!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1735
1786#if MPI_ENABLED
1787 subroutine setIdleMPI(seconds)
1788#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
1789 !DEC$ ATTRIBUTES DLLEXPORT :: setIdleMPI
1790#endif
1791 use pm_kind, only: RKD
1792 real(RKD) , intent(in) :: seconds
1793 real(RKD) :: since
1794 since = getTimeMPI()
1795 do
1796 if (getTimeMPI() - since > seconds) exit
1797 end do
1798 end subroutine
1799#endif
1800
1801!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1802
1849#if OMP_ENABLED
1850 subroutine setIdleOMP(seconds)
1851#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
1852 !DEC$ ATTRIBUTES DLLEXPORT :: setIdleOMP
1853#endif
1854 use pm_kind, only: RKD
1855 real(RKD) , intent(in) :: seconds
1856 real(RKD) :: since
1857 since = getTimeOMP()
1858 do
1859 if (getTimeOMP() - since > seconds) exit
1860 end do
1861 end subroutine
1862#endif
1863
1864!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1865
1914 subroutine setIdleSYS(seconds)
1915#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
1916 !DEC$ ATTRIBUTES DLLEXPORT :: setIdleSYS
1917#endif
1918 use pm_kind, only: RKD
1919 real(RKD) , intent(in) :: seconds
1920 real(RKD) :: since
1921 since = getTimeSYS()
1922 do
1923 if (getTimeSYS() - since > seconds) exit
1924 end do
1925 end subroutine
1926
1927!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1928!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1929!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1930
1931end 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:974
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:1037
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:1098
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:1199
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:1374
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:1915
real(RKD) function getResTimerMPI()
Generate and return the time resolution of the MPI intrinsic timer, used in timerMPI_type,...
Definition: pm_timer.F90:1425
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:1788
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:919
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:1722
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:1659
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:1262
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:1317
real(RKD) function getResTimerSYS()
Generate and return the time resolution of the Fortran intrinsic system_clock(), used in timerSYS_typ...
Definition: pm_timer.F90:1529
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:1851
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:754
type(timerSYS_type) function timerSYS_typer()
This is the constructor of the timerSYS_type class.
Definition: pm_timer.F90:796
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:1478
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:1594
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:859
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