Determines the COUNT of a processor clock since an unspecified time in the past modulo COUNT_MAX, COUNT_RATE determines the number of clock ticks per second. If the platform supports a monotonic clock, that clock is used and can, depending on the platform clock implementation, provide up to nanosecond resolution. If a monotonic clock is not available, the implementation falls back to a realtime clock.
COUNT_RATE is system dependent and can vary depending on the kind of the arguments. For kind=4 arguments (and smaller integer kinds), COUNT represents milliseconds, while for kind=8 arguments (and larger integer kinds), COUNT typically represents micro- or nanoseconds depending on resolution of the underlying platform clock. COUNT_MAX usually equals HUGE(COUNT_MAX)
. Note that the millisecond resolution of the kind=4 version implies that the COUNT will wrap around in roughly 25 days. In order to avoid issues with the wrap around and for more precise timing, please use the kind=8 version.
If there is no clock, or querying the clock fails, COUNT is set to -HUGE(COUNT)
, and COUNT_RATE and COUNT_MAX are set to zero.
When running on a platform using the GNU C library (glibc) version 2.16 or older, or a derivative thereof, the high resolution monotonic clock is available only when linking with the rt library. This can be done explicitly by adding the -lrt
flag when linking the application, but is also done implicitly when using OpenMP.
On the Windows platform, the version with kind=4 arguments uses the GetTickCount
function, whereas the kind=8 version uses QueryPerformanceCounter
and QueryPerformanceCounterFrequency
. For more information, and potential caveats, please see the platform documentation.
Fortran 90 and later
Subroutine
CALL SYSTEM_CLOCK([COUNT, COUNT_RATE, COUNT_MAX])
COUNT | (Optional) shall be a scalar of type INTEGER with INTENT(OUT) . |
COUNT_RATE | (Optional) shall be a scalar of type INTEGER or REAL , with INTENT(OUT) . |
COUNT_MAX | (Optional) shall be a scalar of type INTEGER with INTENT(OUT) . |
PROGRAM test_system_clock INTEGER :: count, count_rate, count_max CALL SYSTEM_CLOCK(count, count_rate, count_max) WRITE(*,*) count, count_rate, count_max END PROGRAM
Next: TAN, Previous: SYSTEM, Up: Intrinsic Procedures [Contents][Index]
© Free Software Foundation
Licensed under the GNU Free Documentation License, Version 1.3.
https://gcc.gnu.org/onlinedocs/gcc-10.2.0/gfortran/SYSTEM_005fCLOCK.html