From: wmitchel@fergie.dnet.ge.com (Bill Mitchell) Subject: Re: Fortran TIMING Date: 30 Apr 1993 20:54:10 GMT
In article <C690F1.745@tierzucht-mariensee.fal-braunschweig.de>, Eildert Groeneveld <eg@tierzucht-mariensee.fal-braunschweig.dbp.de> writes:
|> we have ported some rather substantial Fortran code to
|> Linux. On the whole, it worked great. However, I do need
|> some timing routines. Does there exist a BSD compatibility
|> library that has DTIME, FDATE etc (from FORTRAN that is).
|> Also, I sorely missing IEOR from FORTRAN.
|>
|> Any pointers would be appeciated.
|>
|> Eildert Groeneveld
I'm not sure if this is exactly what you're looking for for timing
(and I don't know about the date), but here's a little subroutine
that is callable from both fortran and C that I use for measuring
CPU time.
==========cut here
/* measure execution time in seconds */
/* Bill Mitchell 10/9/92 */
/* */
/* Use unix routine"times"to measure */
/* user execution time between */
/* calls to second in seconds. */
/* Callable from FORTRAN and C. */
/* Returns double precsion (real*8) */
/* in FORTRAN and double in C. */
/* FORTRAN callable version */
static int holdtime,flagtime=1;
double second_()
{
/* just call C version */
double second();
return second();
}
/* C callable version */
double second()
{
#include <sys/types.h>
#include <sys/times.h>
#include <sys/param.h>
clock_t times();
clock_t t;
struct tms t1;
/* call "times" */
t=times(&t1);
/* user time in 1/HZ seconds is in tms_utime */
/* HZ is in sys/param.h */
return ((double)t1.tms_utime)/HZ;
}
============cut here
-- -- BillWilliam F. Mitchell | wmitchell@atl.ge.com Martin Marietta Adv. Tech. Labs | na.mitchell@na-net.ornl.gov