XL Fortran for AIX 8.1

Language Reference

+---------------------------------Fortran 95---------------------------------+


CPU_TIME(TIME)

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.

TIME
Is a scalar of type real. It is an INTENT(OUT) argument that is assigned an approximation to the processor time. The time is measured in seconds. The time returned by CPU_TIME is dependent upon the setting of the XLFRTEOPTS environment variable run-time option cpu_time_type. The valid settings for cpu_time_type are:

usertime
The user time for the current process. For a definition of user time, see the AIX Performance and Tuning Guide.

systime
The system time for the current process. For a definition of system time, see the AIX Performance and Tuning Guide.

alltime
The sum of the user and system time for the current process

total_usertime
The total user time for the current process. The total user time is the sum of the user time for the current process and the total user times for its child processes, if any.

total_systime
The total system time for the current process. The total system time is the sum of the system time for the current process and the total system times for its child processes, if any.

total_alltime
The total user and system time for the current process. The total user and system time is the sum of the user and system time for the current process and the total user and system times for their child processes, if any.

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.

Class

Subroutine

Examples

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.'

If you want to set the cpu_time_type run-time option to usertime, you would type the following command from a ksh or bsh command line:

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'.

Related Information

+-----------------------------End of Fortran 95------------------------------+


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]