Intel® Fortran Compiler

Developer Guide and Reference

ID 767251
Date 3/31/2025
Public
Document Table of Contents

SYSTEM_CLOCK

Intrinsic Subroutine: Returns data from a real-time clock. SYSTEM_CLOCK returns the number of seconds from 00:00 Coordinated Universal Time (CUT) on 1 JAN 1970. The number is returned with no bias. To get the elapsed time, you must call SYSTEM_CLOCK twice, and subtract the starting time value from the ending time value.

CALL SYSTEM_CLOCK ([count] [, count_rate] [, count_max])

count

(Output; optional) Must be scalar and of type integer with a kind type parameter greater than 1. It is set to a value based on the current value of the processor clock. The value is increased by one for each clock count until the value count_max is reached, and is reset to zero at the next count. count lies in the range 0 to count_max.

count_rate

(Output; optional) Must be scalar and of type integer or real. It is set to the number of processor clock counts per second.

If the type is INTEGER(1), count_rate is 0. If the type is INTEGER(2), count_rate is 1000. If the type is INTEGER(4) or REAL(4), count_rate is 10000. If the type is INTEGER(8), REAL(8), or REAL(16), count_rate is 1000000.

If the count argument is also supplied, the value returned for count_rate is determined by the integer kind of count, not count_rate.

count_max

(Output; optional) Must be scalar and of type integer of any kind type. It is set to the value HUGE(INT(0,KIND(count))).

If the type of count_rate or count_max is INTEGER(1), count_rate and count_max are zero, indicating that there is no clock available to Intel® Fortran with an 8-bit range. If count is INTEGER(1), a compile time message is issued indicating that the kind type is too small.

The values of count_rate and count_max are valid only for calls to SYSTEM_CLOCK where count is the same-sized integer (or INTEGER(8) for the case where count_rate is REAL(16)).

NOTE:
Fortran 2023 requires all integer arguments to SYSTEM_CLOCK to be at least default integer (kind=4), and all integer arguments must have the same kind type parameter value. The compiler will diagnose this if the standard version being compiled for is at least Fortran 2023, but not earlier versions of the standard.

Example

Consider the following:

  integer(8) :: ic8, crate8, cmax8
  integer(4) :: ic4, crate4, cmax4
  call system_clock(count=ic8, count_rate=crate8, count_max=cmax8)
  call system_clock(count=ic4, count_rate=crate4, count_max=cmax4)
  print *, ic8, crate8, cmax8
  print *, ic4, crate4, cmax4
  end

This program was run on October 16, 2024 at 16:20:00 EDT and produced the following output:

    1729109531530646      1000000 9223372036854775807
  1733835306   10000 2147483647