[comp.sys.sgi] fortran callable timer

glennrp@BRL.ARPA (Glenn Randers-Pehrson, TBD) (10/30/87)

Here are second.f and clockf.c, which give you a FORTRAN callable
"second" subroutine:

	CALL SECOND (CPUTIME)

You have to call second at least once every 4295 seconds or it will
lose some time.

------cut here; second.f follows -------
      subroutine second (time)
c
c     returns elapsed system+user cpu time in seconds, accurate to
c     1/60th second.  If more than 4295 seconds elapse between calls
c     to second, n*4295 seconds will not be recorded.
c
      real lasttime,thistime
      save lasttime, s4295
      data lasttime /0.0/, s4295 /0.0/
      call clockf(now)
      thistime=now/1 000 000.
      if(thistime.lt.lasttime) s4295 = s4295 + 4295.
      lasttime=thistime
      time = s4295 + thistime
      return
      end
------cut here; clockf.c follows -------
fortran clockf(thistime)

/* returns unsigned integer, counting from 0 to (2**32 - 1) microseconds
 * in approximately 1/60th second steps, representing elapsed system+user
 * time.  If more than 4295 seconds elapse between calls to clockf,
 * n*4295 seconds will not be recorded. */

long *thistime;
{
	long clock();
	*thistime = clock();
}