Jump to content

Fortran: Difference between revisions

From 太極
Brb (talk | contribs)
Brb (talk | contribs)
Line 5: Line 5:
== Timing ==
== Timing ==
system_clock tells the elapsed wall time between two successive calls.
system_clock tells the elapsed wall time between two successive calls.
<pre>
<syntaxhighlight lang='fortran'>
integer(kind=8):: tclock1, tclock2, clock_rate
integer(kind=8):: tclock1, tclock2, clock_rate
real(kind=8):: elapse_time
real(kind=8):: elapse_time
Line 15: Line 15:
call system_clock(tclock2, clock_rate)
call system_clock(tclock2, clock_rate)
elapse_time = float(tclock2 - tclock1) / float(clock_rate)
elapse_time = float(tclock2 - tclock1) / float(clock_rate)
</pre>
</syntaxhighlight>


cpu_time tells the CPU time used between two successive calls
cpu_time tells the CPU time used between two successive calls
<pre>
<syntaxhighlight lang='fortran'>
real(kind=8):: t1, t2, elapsed_cpu_time
real(kind=8):: t1, t2, elapsed_cpu_time
call cpu_time(t1)
call cpu_time(t1)
Line 26: Line 26:
call cpu_time(t2)
call cpu_time(t2)
elapsed_cpu_time = t2 - t1
elapsed_cpu_time = t2 - t1
</pre>
</syntaxhighlight>


Since Unix provides a timing command called '''time''', we can compare the system time and cpu time reported by Fortran's functions and Unix's time command; e.g. '''time ./a.out''' where a.out is the executable file written by a Fortran code. See an example from '''the High Performance Scientific Computing''' (University of Washington); the [http://faculty.washington.edu/rjl/uwhpsc-coursera/index.html web lecture] and the [https://class.coursera.org/scicomp-003/lecture/197 video lecture].
Since Unix provides a timing command called '''time''', we can compare the system time and cpu time reported by Fortran's functions and Unix's time command; e.g. '''time ./a.out''' where a.out is the executable file written by a Fortran code. See an example from '''the High Performance Scientific Computing''' (University of Washington); the [http://faculty.washington.edu/rjl/uwhpsc-coursera/index.html web lecture] and the [https://class.coursera.org/scicomp-003/lecture/197 video lecture].

Revision as of 12:46, 16 November 2015

Misc

Change stack size

In Compaq Visual Fortran, go to Project Settings -> Win32 Release -> Link. In the Project Options text box, add something like /stack:0x989680 (the decimal value is 10000000 or 10MB).

Timing

system_clock tells the elapsed wall time between two successive calls.

integer(kind=8):: tclock1, tclock2, clock_rate
real(kind=8):: elapse_time

call system_clock(tclock1)

<code to be timed>

call system_clock(tclock2, clock_rate)
elapse_time = float(tclock2 - tclock1) / float(clock_rate)

cpu_time tells the CPU time used between two successive calls

real(kind=8):: t1, t2, elapsed_cpu_time
call cpu_time(t1)

<code to be timed>

call cpu_time(t2)
elapsed_cpu_time = t2 - t1

Since Unix provides a timing command called time, we can compare the system time and cpu time reported by Fortran's functions and Unix's time command; e.g. time ./a.out where a.out is the executable file written by a Fortran code. See an example from the High Performance Scientific Computing (University of Washington); the web lecture and the video lecture.