Fortran: Difference between revisions

From 太極
Jump to navigation Jump to search
Line 25: Line 25:
</pre>
</pre>


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'' (Coursera); 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 09:17, 24 March 2015

Misc

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.