[testsuite gfortran] partial fix for secnds*.f
Dominique Dhumieres
dominiq@lps.ens.fr
Thu May 10 22:17:00 GMT 2007
Fix the erratic failures of the tests secnds.f and secnds-1.f:
(1) do the appropriate shifts for timings around midnight,
(2) use some tolerances for the timing comparisons, the chosen
value: 8ms, is approximately 24.0*3600.0-nearest(24.0*3600.0,-1.0).
I don't have write access to SVN.
I am submitting this patch for analysis, but I have found a remaining
problem on Linux at midnight:
nearest(t1, -1.) dat1 nearest(t1a, 1.)
secnds.f 86398.625 -1.3740234 86398.641
secnds-1.f 86399.992 0.0000000 86400.008
apparently date_and_time is zero at midnight while secnds() is
86400. I don't know if this a bug in one of the intrinsic or if
this the intended behavior. It will be easy to use an additional 'if'
to handle the case, but I'ld prefer to know if the behavior is the
expected one. This problem can only be tested once a day!
2007-04-01 Dominique d'Humières <dominiq@lps.ens.fr>
* secnds.f : Fix the midnight jump and add some tolerances for
the tests
* secnds-1.f: Likewise
--- gcc-4.3-20070505/gcc/testsuite/gfortran.dg/secnds.f Sat Apr 28 04:10:46 2007
+++ gcc-4.3-20070504/gcc/testsuite/gfortran.dg/secnds.f Thu May 10 20:57:14 2007
@@ -6,14 +6,18 @@ C Contributed by Paul Thomas <pault@gcc
C
character*20 dum1, dum2, dum3
real t1, t1a, t2, t2a
- real*8 dat1, dat2
+ real*4 dat1, dat2
integer i, j, values(8)
t1 = secnds (0.0)
call date_and_time (dum1, dum2, dum3, values)
t1a = secnds (0.0)
dat1 = 0.001*real (values(8)) + real (values(7)) +
& 60.0*real (values(6)) + 3600.0* real (values(5))
- if (((dat1 - t1) < 0.) .or. ((dat1 - t1) > (t1a - t1))) call abort ()
+ ! handle midnight shift
+ if ((t1a - t1) < -12.0*3600.0 ) t1 = t1 - 24.0*3600.0
+ if ((t1a - dat1) < -12.0*3600.0 ) dat1 = dat1 - 24.0*3600.0
+ if ((dat1 < nearest(t1, -1.)) .or. (dat1 > nearest(t1a, 1.)))
+ & call abort ()
do j=1,10000
do i=1,10000
end do
@@ -23,5 +27,8 @@ C
t2 = secnds (t1)
dat2 = 0.001*real (values(8)) + real (values(7)) +
& 60.0*real (values(6)) + 3600.0* real (values(5))
- if (((dat2 - dat1) < t2a) .or. ((dat2 - dat1) > t2)) call abort ()
+ ! handle midnight shift
+ if ((dat2 - dat1) < -12.0*3600.0 ) dat1 = dat1 - 24.0*3600.0
+ if (((dat2 - dat1) < t2a - 0.008) .or.
+ & ((dat2 - dat1) > t2 + 0.008)) call abort ()
end
--- gcc-4.3-20070505/gcc/testsuite/gfortran.dg/secnds-1.f Sat Apr 28 04:10:46 2007
+++ gcc-4.3-20070504/gcc/testsuite/gfortran.dg/secnds-1.f Thu May 10 20:59:05 2007
@@ -1,23 +1,30 @@
C { dg-do run }
-C { dg-options "-ffloat-store" }
-C Tests fix for PR29099 - SECNDS intrinsic wrong result with no delay.
+C { dg-options "-O0 -ffloat-store" }
+C Tests fix for PR14994 - SECNDS intrinsic not supported.
C
C Contributed by Paul Thomas <pault@gcc.gnu.org>
C
character*20 dum1, dum2, dum3
real t1, t1a, t2, t2a
- real*8 dat1, dat2
+ real*4 dat1, dat2
integer i, j, values(8)
t1 = secnds (0.0)
call date_and_time (dum1, dum2, dum3, values)
t1a = secnds (0.0)
dat1 = 0.001*real (values(8)) + real (values(7)) +
& 60.0*real (values(6)) + 3600.0* real (values(5))
- if (((dat1 - t1) < 0.) .or. ((dat1 - t1) > (t1a - t1))) call abort ()
+ ! handle midnight shift
+ if ((t1a - t1) < -12.0*3600.0 ) t1 = t1 - 24.0*3600.0
+ if ((t1a - dat1) < -12.0*3600.0 ) dat1 = dat1 - 24.0*3600.0
+ if ((dat1 < nearest(t1, -1.)) .or. (dat1 > nearest(t1a, 1.)))
+ & call abort ()
t2a = secnds (t1a)
call date_and_time (dum1, dum2, dum3, values)
t2 = secnds (t1)
dat2 = 0.001*real (values(8)) + real (values(7)) +
& 60.0*real (values(6)) + 3600.0* real (values(5))
- if (((dat2 - dat1) < t2a) .or. ((dat2 - dat1) > t2)) call abort ()
+ ! handle midnight shift
+ if ((dat2 - dat1) < -12.0*3600.0 ) dat1 = dat1 - 24.0*3600.0
+ if (((dat2 - dat1) < t2a - 0.008) .or.
+ & ((dat2 - dat1) > t2 + 0.008)) call abort ()
end
More information about the Fortran
mailing list