Fortran: Difference between revisions
Appearance
Created page with "= Misc = == Timing == system_clock tells the elapsed wall time between two successive calls. <pre> integer(kind=8):: tclock1, tclock2, clock_rate real(kind=8):: elapse_time c..." |
|||
| Line 24: | Line 24: | ||
elapsed_cpu_time = t2 - t1 | elapsed_cpu_time = t2 - t1 | ||
</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 [https://class.coursera.org/scicomp-003/lecture/197 coursera]. | |||
Revision as of 07:52, 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 coursera.