DTIME.html 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1999-2017 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation; with the
  7. Invariant Sections being "Funding Free Software", the Front-Cover
  8. Texts being (a) (see below), and with the Back-Cover Texts being (b)
  9. (see below). A copy of the license is included in the section entitled
  10. "GNU Free Documentation License".
  11. (a) The FSF's Front-Cover Text is:
  12. A GNU Manual
  13. (b) The FSF's Back-Cover Text is:
  14. You have freedom to copy and modify this GNU Manual, like GNU
  15. software. Copies published by the Free Software Foundation raise
  16. funds for GNU development. -->
  17. <!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
  18. <head>
  19. <title>The GNU Fortran Compiler: DTIME</title>
  20. <meta name="description" content="The GNU Fortran Compiler: DTIME">
  21. <meta name="keywords" content="The GNU Fortran Compiler: DTIME">
  22. <meta name="resource-type" content="document">
  23. <meta name="distribution" content="global">
  24. <meta name="Generator" content="makeinfo">
  25. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  26. <link href="index.html#Top" rel="start" title="Top">
  27. <link href="Option-Index.html#Option-Index" rel="index" title="Option Index">
  28. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  29. <link href="Intrinsic-Procedures.html#Intrinsic-Procedures" rel="up" title="Intrinsic Procedures">
  30. <link href="EOSHIFT.html#EOSHIFT" rel="next" title="EOSHIFT">
  31. <link href="DSHIFTR.html#DSHIFTR" rel="prev" title="DSHIFTR">
  32. <style type="text/css">
  33. <!--
  34. a.summary-letter {text-decoration: none}
  35. blockquote.smallquotation {font-size: smaller}
  36. div.display {margin-left: 3.2em}
  37. div.example {margin-left: 3.2em}
  38. div.indentedblock {margin-left: 3.2em}
  39. div.lisp {margin-left: 3.2em}
  40. div.smalldisplay {margin-left: 3.2em}
  41. div.smallexample {margin-left: 3.2em}
  42. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  43. div.smalllisp {margin-left: 3.2em}
  44. kbd {font-style:oblique}
  45. pre.display {font-family: inherit}
  46. pre.format {font-family: inherit}
  47. pre.menu-comment {font-family: serif}
  48. pre.menu-preformatted {font-family: serif}
  49. pre.smalldisplay {font-family: inherit; font-size: smaller}
  50. pre.smallexample {font-size: smaller}
  51. pre.smallformat {font-family: inherit; font-size: smaller}
  52. pre.smalllisp {font-size: smaller}
  53. span.nocodebreak {white-space:nowrap}
  54. span.nolinebreak {white-space:nowrap}
  55. span.roman {font-family:serif; font-weight:normal}
  56. span.sansserif {font-family:sans-serif; font-weight:normal}
  57. ul.no-bullet {list-style: none}
  58. -->
  59. </style>
  60. </head>
  61. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  62. <a name="DTIME"></a>
  63. <div class="header">
  64. <p>
  65. Next: <a href="EOSHIFT.html#EOSHIFT" accesskey="n" rel="next">EOSHIFT</a>, Previous: <a href="DSHIFTR.html#DSHIFTR" accesskey="p" rel="prev">DSHIFTR</a>, Up: <a href="Intrinsic-Procedures.html#Intrinsic-Procedures" accesskey="u" rel="up">Intrinsic Procedures</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  66. </div>
  67. <hr>
  68. <a name="DTIME-_002d_002d_002d-Execution-time-subroutine-_0028or-function_0029"></a>
  69. <h3 class="section">9.92 <code>DTIME</code> &mdash; Execution time subroutine (or function)</h3>
  70. <a name="index-DTIME"></a>
  71. <a name="index-time_002c-elapsed-1"></a>
  72. <a name="index-elapsed-time"></a>
  73. <dl compact="compact">
  74. <dt><em>Description</em>:</dt>
  75. <dd><p><code>DTIME(VALUES, TIME)</code> initially returns the number of seconds of runtime
  76. since the start of the process&rsquo;s execution in <var>TIME</var>. <var>VALUES</var>
  77. returns the user and system components of this time in <code>VALUES(1)</code> and
  78. <code>VALUES(2)</code> respectively. <var>TIME</var> is equal to <code>VALUES(1) +
  79. VALUES(2)</code>.
  80. </p>
  81. <p>Subsequent invocations of <code>DTIME</code> return values accumulated since the
  82. previous invocation.
  83. </p>
  84. <p>On some systems, the underlying timings are represented using types with
  85. sufficiently small limits that overflows (wrap around) are possible, such as
  86. 32-bit types. Therefore, the values returned by this intrinsic might be, or
  87. become, negative, or numerically less than previous values, during a single
  88. run of the compiled program.
  89. </p>
  90. <p>Please note, that this implementation is thread safe if used within OpenMP
  91. directives, i.e., its state will be consistent while called from multiple
  92. threads. However, if <code>DTIME</code> is called from multiple threads, the result
  93. is still the time since the last invocation. This may not give the intended
  94. results. If possible, use <code>CPU_TIME</code> instead.
  95. </p>
  96. <p>This intrinsic is provided in both subroutine and function forms; however,
  97. only one form can be used in any given program unit.
  98. </p>
  99. <p><var>VALUES</var> and <var>TIME</var> are <code>INTENT(OUT)</code> and provide the following:
  100. </p>
  101. <table>
  102. <tr><td width="15%"></td><td width="30%"><code>VALUES(1)</code>:</td><td width="40%">User time in seconds.</td></tr>
  103. <tr><td width="15%"></td><td width="30%"><code>VALUES(2)</code>:</td><td width="40%">System time in seconds.</td></tr>
  104. <tr><td width="15%"></td><td width="30%"><code>TIME</code>:</td><td width="40%">Run time since start in seconds.</td></tr>
  105. </table>
  106. </dd>
  107. <dt><em>Standard</em>:</dt>
  108. <dd><p>GNU extension
  109. </p>
  110. </dd>
  111. <dt><em>Class</em>:</dt>
  112. <dd><p>Subroutine, function
  113. </p>
  114. </dd>
  115. <dt><em>Syntax</em>:</dt>
  116. <dd><table>
  117. <tr><td width="80%"><code>CALL DTIME(VALUES, TIME)</code>.</td></tr>
  118. <tr><td width="80%"><code>TIME = DTIME(VALUES)</code>, (not recommended).</td></tr>
  119. </table>
  120. </dd>
  121. <dt><em>Arguments</em>:</dt>
  122. <dd><table>
  123. <tr><td width="15%"><var>VALUES</var></td><td width="70%">The type shall be <code>REAL(4), DIMENSION(2)</code>.</td></tr>
  124. <tr><td width="15%"><var>TIME</var></td><td width="70%">The type shall be <code>REAL(4)</code>.</td></tr>
  125. </table>
  126. </dd>
  127. <dt><em>Return value</em>:</dt>
  128. <dd><p>Elapsed time in seconds since the last invocation or since the start of program
  129. execution if not called before.
  130. </p>
  131. </dd>
  132. <dt><em>Example</em>:</dt>
  133. <dd><div class="smallexample">
  134. <pre class="smallexample">program test_dtime
  135. integer(8) :: i, j
  136. real, dimension(2) :: tarray
  137. real :: result
  138. call dtime(tarray, result)
  139. print *, result
  140. print *, tarray(1)
  141. print *, tarray(2)
  142. do i=1,100000000 ! Just a delay
  143. j = i * i - i
  144. end do
  145. call dtime(tarray, result)
  146. print *, result
  147. print *, tarray(1)
  148. print *, tarray(2)
  149. end program test_dtime
  150. </pre></div>
  151. </dd>
  152. <dt><em>See also</em>:</dt>
  153. <dd><p><a href="CPU_005fTIME.html#CPU_005fTIME">CPU_TIME</a>
  154. </p>
  155. </dd>
  156. </dl>
  157. <hr>
  158. <div class="header">
  159. <p>
  160. Next: <a href="EOSHIFT.html#EOSHIFT" accesskey="n" rel="next">EOSHIFT</a>, Previous: <a href="DSHIFTR.html#DSHIFTR" accesskey="p" rel="prev">DSHIFTR</a>, Up: <a href="Intrinsic-Procedures.html#Intrinsic-Procedures" accesskey="u" rel="up">Intrinsic Procedures</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  161. </div>
  162. </body>
  163. </html>