]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/fortran/doc/gfortran/intrinsic-procedures/etime.rst
sphinx: add missing trailing newline
[thirdparty/gcc.git] / gcc / fortran / doc / gfortran / intrinsic-procedures / etime.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:: ETIME, time, elapsed
7
8 .. _etime:
9
10 ETIME --- Execution time subroutine (or function)
11 *************************************************
12
13 .. function:: ETIME(VALUES, TIME)
14
15 ``ETIME(VALUES, TIME)`` returns the number of seconds of runtime
16 since the start of the process's execution in :samp:`{TIME}`. :samp:`{VALUES}`
17 returns the user and system components of this time in ``VALUES(1)`` and
18 ``VALUES(2)`` respectively. :samp:`{TIME}` is equal to ``VALUES(1) + VALUES(2)``.
19
20 :param VALUES:
21 The type shall be ``REAL(4), DIMENSION(2)``.
22
23 :param TIME:
24 The type shall be ``REAL(4)``.
25
26 :return:
27 Elapsed time in seconds since the start of program execution.
28
29 Standard:
30 GNU extension
31
32 Class:
33 Subroutine, function
34
35 Syntax:
36 .. code-block:: fortran
37
38 CALL ETIME(VALUES, TIME).
39 TIME = ETIME(VALUES), (not recommended).
40
41 Example:
42 .. code-block:: fortran
43
44 program test_etime
45 integer(8) :: i, j
46 real, dimension(2) :: tarray
47 real :: result
48 call ETIME(tarray, result)
49 print *, result
50 print *, tarray(1)
51 print *, tarray(2)
52 do i=1,100000000 ! Just a delay
53 j = i * i - i
54 end do
55 call ETIME(tarray, result)
56 print *, result
57 print *, tarray(1)
58 print *, tarray(2)
59 end program test_etime
60
61 See also:
62 :ref:`CPU_TIME`