When timing a FORTRAN program i usually just use the command call cpu_time(t)
.
Then i stumbled across call system_clock([count,count_rate,count_max])<
I find itime
(see gfortran manual) to be a good alternative to system_clock
for timing fortran programs. It is very easy to use:
integer, dimension(3) :: time
call itime(time)
print *, 'Hour: ', time(1)
print *, 'Minute:', time(2)
print *, 'Second:', time(3)
cpu_time() usually has a resolution of about 0.01 second on Intel compatible CPUs. This means that a smaller time interval may count as zero time. Most current compilers for linux make the resolution of system_clock() depend on the data types of the arguments, so integer(int64) will give better than 1 microsecond resolution, as well as permitting counting over a significant time interval. gfortran for Windows was changed recently (during 2015) so as to make system_clock() equivalent to query_performance calls. ifort Windows, however, still shows about 0.01 resolution for system_clock, even after omp_get_wtime was changed to use query_performance. I would discount previous comments about measuring cpu_time or system_clock resolution in clock ticks, particularly if that may be thought to relate to CPU or data buss ticks, such as rdtsc instruction could report.
I find secnds() to be the easiest way to get wall time. Its usage is almost identical to cpu_time().
real(8)::t1,delta
t1=secnds(0.0)
!Do stuff
delta=seconds(t1)
These two intrinsics report different types of time. system_clock reports "wall time" or elapsed time. cpu_time reports time used by the CPU. On a multi-tasking machine these could be very different, e.g., if your process shared the CPU equally with three other processes and therefore received 25% of the CPU and used 10 cpu seconds, it would take about 40 seconds of actual elapsed or wall clock time.