cpu_time(x): CPU Elapsed Time

CPU elapsed time in seconds.

Declaration

Sintaxe

retval = cpu_time(x)
pure subroutine cpu_time(x)

Argumentos

x the input value should be of type real with intent(out).

Valores de retorno

Nenhum.

Descrição

cpu_time(time) returns a real value representing the elapsed CPU time in seconds. If tine source is available, time will be reported with microsecond resolution. If no time source is available, TIME is set to -1.0.

This is useful for testing segments of code to determine computation time.

For cpu_time(time) the absolute value is meaningless, only differences between subsequent calls to this subroutine, as shown in the example below, should be used.

Tipos

Supported input parameter types is real with intent(out).

pure subroutine cpu_time(t)
real(dp), intent(out) :: t
call c_cpu_time(t)
end subroutine

Exemplos

program intrinsics_cpu_time
    implicit none
	real(dp) :: t1, t2
	call cpu_time(t1)
	print *, "Some computation"
    call cpu_time(t2)
    print *, "Total time: ", t2-t1
end program

Resultado:

Some computation
20

Veja Também