cpu_time
- Date:
10-12-2011
NAME
CPU_TIME - Returns the processor time
SYNOPSIS
CALL CPU_TIME ([TIME=]time)
REAL time
STANDARDS
Fortran
DESCRIPTION
The CPU_TIME intrinsic subroutine returns the user time if successful. This intrinsic subroutine accepts the following argument:
- time
Must be a scalar and of type real. It is an output argument. The type of the argument is not restricted to any particular kind type.
The name of this intrinsic cannot be passed as an argument. The time returned by this intrinsic subroutine is user time on all systems.
A call to CPU_TIME must be done once and before the first timing loop to initialize the time structure. CPU_TIME includes time accumulated by the the current process.
RETURN VALUES
CPU_TIME yields -1.0 if the time cannot be returned.
EXAMPLES
The following program uses the CPU_TIME intrinsic subroutine:
PROGRAM CPUTIMETEST
REAL RTIME(2)
CHARACTER(LEN=400) :: EXPRIGHT2
CHARACTER(LEN=800) :: EXPRIGHT
INTEGER :: J
CALL CPU_TIME(RTIME(1))
IF (RTIME(1) .EQ. -1.0) THEN
PRINT *,'CPU_TIME NOT WORKING, QUIT'
PRINT *,'RTIME(1) =',RTIME(1)
STOP 'UNSUCCESSFUL'
ENDIF
CALL CPU_TIME(RTIME(1))
DO J = 1, 400
EXPRIGHT2(J:J) = " "
ENDDO
CALL CPU_TIME(RTIME(2))
PRINT *,'ELAPSED CPUTIME TIME=',RTIME(2) - RTIME(1)
CALL CPU_TIME(RTIME(1))
DO J = 1, 800
EXPRIGHT(J:J) = " "
ENDDO
CALL CPU_TIME(RTIME(2))
PRINT *,'ELAPSED CPUTIME TIME=',RTIME(2) - RTIME(1)
END
This program generated the following output:
ELAPSED CPUTIME TIME= 7.61700000000004E-5
ELAPSED CPUTIME TIME= 7.722000000000284E-5