SYSTEM_CLOCK(COUNT, COUNT_RATE, COUNT_MAX)

Purpose

Returns numeric data from a real-time clock.

Class

Subroutine

Argument type and attributes

COUNT (optional)
is an INTENT(OUT) argument that must be scalar and of type integer. The initial value of COUNT depends on the current value of the processor clock in a range from 0 to COUNT_MAX. COUNT increments by one for each clock count until it reaches the value of COUNT_MAX. At the next clock count after COUNT_MAX, the value of COUNT resets to zero.
COUNT_RATE (optional)
is an INTENT(OUT) argument that must be scalar and of type integer or type real. When using the default centisecond resolution, COUNT_RATE refers to the number of processor clock counts per second or to zero if there is no clock.
IBM extension begins If you specify a microsecond resolution using –qsclk=micro, the value of COUNT_RATE is 1 000 000 clock counts per second. IBM extension ends
COUNT_MAX (optional)
is an INTENT(OUT) argument that must be scalar and of type integer. When using the default centisecond resolution, COUNT_MAX is the maximum number of clock counts for a given processor clock.
IBM extension begins If you specify a microsecond resolution using -qsclk=micro and COUNT_MAX is of type INTEGER(4), the value of COUNT_MAX is 1 799 999 999 clock counts, or about 30 minutes.
If you specify a microsecond resolution using -qsclk=micro and COUNT_MAX is of type INTEGER(8), the value of COUNT_MAX is 86 399 999 999 clock counts, or about 24 hours. IBM extension ends

Examples

IBM extension begins In the following example, the clock is a 24-hour clock. After the call to SYSTEM_CLOCK, the COUNT contains the day time expressed in clock ticks per second. The number of ticks per second is available in the COUNT_RATE. The COUNT_RATE value is implementation dependent.

     INTEGER, DIMENSION(8) :: IV
     TIME_SYNC: DO
     CALL DATE_AND_TIME(VALUES=IV)
     IHR  = IV(5)
     IMIN = IV(6)
     ISEC = IV(7)
     CALL SYSTEM_CLOCK(COUNT=IC, COUNT_RATE=IR, COUNT_MAX=IM)
     CALL DATE_AND_TIME(VALUES=IV)

     IF ((IHR == IV(5)) .AND. (IMIN == IV(6)) .AND. &
       (ISEC == IV(7))) EXIT TIME_SYNC

     END DO TIME_SYNC

     IDAY_SEC = 3600*IHR + IMIN*60 + ISEC
     IDAY_TICKS = IDAY_SEC * IR

     IF (IDAY_TICKS /= IC) THEN
       STOP 'clock error'
     ENDIF
     END
IBM extension ends