[gfortran] Implementation SYSTEM_CLOCK intrinsic subroutine

Steve Kargl sgk@troutmask.apl.washington.edu
Fri May 14 17:17:00 GMT 2004


On Fri, May 14, 2004 at 06:47:48PM +0200, Helge Avlesen wrote:
> 
> for linux. similar hacks excist for most systems, and the routine
> could default to some unix function if not. this could give roughly
> nano second resolution on gigaherz machines for those who wants to
> time e.g. single loops. in the ultimate implementation the user could
> adjust the resolution of the clock via an environment variable to
> avoid overwrapping for longer measurements.
> 
> just a thought from a non-compiler writer...
> 

If you're timing single loops, then you want to use CPU_TIME(),
which is a measure of CPU usage by the process.  SYSTEM_CLOCK is
the real-time clock of the system.  The implementation of 
SYSTEM_CLOCK has 3 possibility for time depending of your system.
If a system has gettimeofday(3), you get millisecond resolution 
(on FreeBSD this could actually be microsecond resolution).  If
the system does not have gettimeofday(3), then gfortran will
try to use time(3).  Unfortunately, time(3) only gives seconds
resolution.  If neither gettimeofday(3) nor time(3) are present,
you get the Fortran standard specified return values when no clock
is available.

-- 
Steve



More information about the Fortran mailing list