This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
g77/F90 date_and_time() intrinsic
- To: egcs at cygnus dot com
- Subject: g77/F90 date_and_time() intrinsic
- From: Kevin Maguire <K dot Maguire at dl dot ac dot uk>
- Date: Fri, 15 Jan 1999 11:34:42 +0000 (GMT)
- Cc: dave at psrv dot psrv dot com
- Reply-To: K dot Maguire at dl dot ac dot uk
Hi
Consider the following: (egcs-1.1.1 Linux/x86)
% cat egcs-timer.f
character*8 dt
character*10 tm
character*5 zn
integer tt(8)
CALL Date_and_Time(dt,tm,zn,tt)
print *,dt
print *,tm
print *,zn
print *,tt
end
% g77 egcs-timer.f
% ./a.out
19990115
111938.953
+0000
1999 1 15 0 11 19 38 953109
^^^^^^
% ./a.out
19990115
112017.207
+0000
1999 1 15 0 11 20 17 207858
^^^^^^
The F90 standard says something like:
VALUE(8) : the milliseconds, in the range 0 to 999, or -HUGE(0) if there
is no clock.
There is a clock, and I see in datetime_.c
vals[7] = 0; /* no STDC way to get this */
/* GNUish way; maybe use `ftime' on other systems. */
#if HAVE_GETTIMEOFDAY
{
struct timeval tp;
struct timezone tzp;
if (! gettimeofday (&tp, &tzp))
vals[7] = tp.tv_usec;
}
#endif
My man page says for gettimeofday:
int gettimeofday(struct timeval *tv, struct timezone *tz);
#include <sys/time.h>
#include <unistd.h>
gettimeofday and settimeofday can set the time as well as a timezone.
tv is a timeval struct, as specified in /usr/include/sys/time.h:
struct timeval {
long tv_sec; /* seconds */
long tv_usec; /* microseconds */
};
So don't we need to convert this to milliseconds to satisfy the
standard.
Incidentally the egcs/g77 info doc says the same thing:
---
VALUES
The year, month of the year, day of the month, time difference in
minutes from UTC, hour of the day, minutes of the hour and
milliseconds of the second in successive values of the array.
On systems where a millisecond timer isn't available, the millisecond
value is returned as zero.
---
Cheers
Kevin
--
/\___/\ ==============================================
| o o | Kevin Maguire Computational Scientist
__\_^_/__ DCI CLRC Daresbury Laboratory
(__/ \__) e-mail: K.Maguire@dl.ac.uk
_| : |_ Tel: 01925 603221 Fax: 01925 603634
(__\___/__) ==============================================