Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

GMTIME and Leap Seconds

cjosefy
Beginner
860 Views
Ignoring the Year 2000 issues with gmtime, it states in the Intel Fortran Libraries reference that gmtime returns this:

tarray(1) Seconds (0-59)

So, does it not handle leap seconds?

Thanks,

Chris

0 Kudos
8 Replies
Steven_L_Intel1
Employee
860 Views
How would it know to add a leap second?

The ANSI C definition of gmtime agrees with the Intel documentation.

Message Edited by sblionel on 06-07-2005 11:27 AM

0 Kudos
cjosefy
Beginner
860 Views
My reading of the ANSI C standard shows this:

The range and precision of times representable in

clock_t and time_t are

implementation-defined. The

tm structure shall contain at least the following members,

in any order. The semantics of the members and their normal ranges are expressed in the

comments.

268)

int tm_sec; //

seconds after the minute [0, 60]

int tm_min; //

minutes after the hour [0, 59]

int tm_hour; //

hours since midnight [0, 23]

int tm_mday; //

day of the month [1, 31]

int tm_mon; //

months since January [0, 11]

int tm_year; //

years since 1900

int tm_wday; //

days since Sunday [0, 6]

int tm_yday; //

days since January 1 [0, 365]

int tm_isdst; //

Daylight Saving Time flag

268) The range [0, 60] for

tm_sec allows for a positive leap second.

This seems to be consistent with what is in time.h,.

Message Edited by cjosefy on 06-07-2005 10:44 AM

0 Kudos
Steven_L_Intel1
Employee
860 Views
The references I have show 0-59, but I'm unclear as to how the routine would know there's a leap-second. In any event, whatever the C gmtime returns, the Fortran one would too.
0 Kudos
cjosefy
Beginner
860 Views
Well the declaration of gmtime in time.h say [0-60] on my RHEL 3 machine. However, I don't know how the routine would now that there is a leap second. I just wanted to know if it was possible to return a 60 to the FORTRAN routine. My reference from above is

ISO/IEC 9899:TC2

Committee Draft May 6, 2005 WG14/N1124

The ANSI C Programming Language by Kernighan and Ritchie says it can be [0,61]

Message Edited by cjosefy on 06-09-2005 01:50 PM

0 Kudos
Steven_L_Intel1
Employee
860 Views
I don't know how gmtime would know to return a 60 there. I assumed it just divided the system clock by fixed values to come up with the proper elements.
0 Kudos
cjosefy
Beginner
860 Views
From my reading, it seems that the time functions get the time from the time zone files on the system. POSIX standards say to ignore leap seconds, and that it the default behavior on Linux. However, there are time zone files with the leap seconds in them, and if your system uses those, then your functions still work but are not POSIX compliant. For example, on my system the time zone files /usr/share/zoneinfo/GMT doesn't have leap seconds, but /usr/share/zoneinfo/right/GMT does.
0 Kudos
Steven_L_Intel1
Employee
860 Views
I suggest you pose this as a query to Intel Premier Support and see what answer you get. I'm pretty sure that the Fortran gmtime is just a wrapper around the C gmtime.
0 Kudos
cjosefy
Beginner
860 Views
I'll do that. In my experience FORTRAN gmtime gives years that are 100 off from the correct year. However, C gmtime gives the correct year.
0 Kudos
Reply