]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/fortran/doc/gfortran/intrinsic-procedures/cputime.rst
sphinx: add missing trailing newline
[thirdparty/gcc.git] / gcc / fortran / doc / gfortran / intrinsic-procedures / cputime.rst
1 ..
2 Copyright 1988-2022 Free Software Foundation, Inc.
3 This is part of the GCC manual.
4 For copying conditions, see the copyright.rst file.
5
6 .. index:: CPU_TIME, time, elapsed
7
8 .. _cpu_time:
9
10 CPU_TIME --- CPU elapsed time in seconds
11 ****************************************
12
13 .. function:: CPU_TIME(TIME)
14
15 Returns a ``REAL`` value representing the elapsed CPU time in
16 seconds. This is useful for testing segments of code to determine
17 execution time.
18
19 :param TIME:
20 The type shall be ``REAL`` with ``INTENT(OUT)``.
21
22 :return:
23 None
24
25 Standard:
26 Fortran 95 and later
27
28 Class:
29 Subroutine
30
31 Syntax:
32 .. code-block:: fortran
33
34 CALL CPU_TIME(TIME)
35
36 Example:
37 .. code-block:: fortran
38
39 program test_cpu_time
40 real :: start, finish
41 call cpu_time(start)
42 ! put code to test here
43 call cpu_time(finish)
44 print '("Time = ",f6.3," seconds.")',finish-start
45 end program test_cpu_time
46
47 See also:
48 :ref:`SYSTEM_CLOCK`,
49 :ref:`DATE_AND_TIME`