Returns the CPU time, in seconds, taken by the current process and, possibly, all the child processes in all of the threads. A call to CPU_TIME will give the processor time taken by the process from the start of the program. The time measured only accounts for the amount of time that the program is actually running, and not the time that a program is suspended or waiting.
Subroutine
This is the default measure of time for CPU_TIME if you have not set the cpu_time_type run-time option.
You can set the cpu_time_type run-time option using the setrteopts procedure. Each change to the cpu_time_type setting will affect all subsequent calls to CPU_TIME.
Example 1:
! The default value for cpu_time_type is used
REAL T1, T2
... ! First chunk of code to be timed
CALL CPU_TIME(T1)
... ! Second chunk of code to be timed
CALL CPU_TIME(T2)
print *, 'Time taken for first chunk of code: ', T1, 'seconds.'
print *, 'Time taken for both chunks of code: ', T2, 'seconds.'
print *, 'Time for second chunk of code was ', T2-T1, 'seconds.'
export XLFRTEOPTS=cpu_time_type=usertime
Example 2:
! Use setrteopts to set the cpu_time_type run-time option as many times
! as you need to
CALL setrteopts ('cpu_time_type=alltime')
CALL stallingloop
CALL CPU_TIME(T1)
print *, 'The sum of the user and system time is', T1, 'seconds'.
CALL setrteopts ('cpu_time_type=usertime')
CALL stallingloop
CALL CPU_TIME(T2)
print *, 'The total user time from the start of the program is', T2, 'seconds'.