[patch, fortran, testsuite] Replace secnds*.f 20-ms tolerance with bracketing

Jerry DeLisle jvdelisle@verizon.net
Sat Feb 10 01:22:00 GMT 2007


Brooks Moses wrote:
> On my computer, on most regression checks, I usually get a random 
> failure in one of the secnds*.f test cases.  The problem is that a pass 
> in the testcase requires that subsequent calls to secnds() and 
> date_and_time() return the same time to within a 20ms tolerance, and on 
> slower systems this arbitrary tolerance value is too small.
> 
> Rather than just increasing the tolerance, I replaced it with a bracket; 
> now, this calls secnds() before and after the date_and_time() call in 
> order to establish a range, and check that the result of date_and_time() 
> is within that range.  This way, we know that any failures are genuine 
> out-of-order errors, rather than just out-of-tolerance glitches.
> 
> ---------------------------------------------------------------
> 2006-02-09  Brooks Moses  <brooks.moses@codesourcery.com>
> 
>     * gfortran.dg/secnds.f: Replace time tolerance with a
>     before-and-after bracket.
>     * gfortran.dg/secnds-1.f: Likewise.
> 
> ---------------------------------------------------------------
> 
> Tested on i686-pc-linux-gnu.  Ok for trunk?
> 
> - Brooks
> 
> 
> ------------------------------------------------------------------------
> 
> Index: gcc/testsuite/gfortran.dg/secnds-1.f
> ===================================================================
> --- gcc/testsuite/gfortran.dg/secnds-1.f	(revision 121705)
> +++ gcc/testsuite/gfortran.dg/secnds-1.f	(working copy)
> @@ -1,24 +1,23 @@
>  C { dg-do run }
> +C { dg-options "-ffloat-store" }
>  C Tests fix for PR29099 - SECNDS intrinsic wrong result with no delay.
> -C Note1: The test uses +/-20ms accuracy in the check that
> -C date_and_time and secnds give the same values.
>  C
>  C Contributed by Paul Thomas  <pault@gcc.gnu.org>
>  C
>        character*20 dum1, dum2, dum3
> -      real t1, t2
> +      real t1, t1a, t2, t2a
>        real dat1, dat2
> -      real dt
>        integer i, j, values(8)
> -      dt = 40e-3
>        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 (int ((dat1 - t1 + dt * 0.5) / dt) .ne. 0) call abort ()
> +      if (((dat1 - t1) < 0.) .or. ((dat1 - t1) > (t1a - t1))) 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))
> -      t2 = secnds (t1)
> -      if (int ((dat1-dat2 + t2 + dt * 0.5) / dt) .ne. 0.0) call abort ()
> +      if (((dat2 - dat1) < t2a) .or. ((dat2 - dat1) > t2)) call abort ()
>        end
> Index: gcc/testsuite/gfortran.dg/secnds.f
> ===================================================================
> --- gcc/testsuite/gfortran.dg/secnds.f	(revision 121705)
> +++ gcc/testsuite/gfortran.dg/secnds.f	(working copy)
> @@ -1,29 +1,27 @@
>  C { dg-do run }
> -C { dg-options "-O0" }
> +C { dg-options "-O0 -ffloat-store" }
>  C Tests fix for PR14994 - SECNDS intrinsic not supported.
> -C Note1: The test uses +/-20ms accuracy in the check that
> -C date_and_time and secnds give the same values.
>  C
>  C Contributed by Paul Thomas  <pault@gcc.gnu.org>
>  C
>        character*20 dum1, dum2, dum3
> -      real t1, t2
> +      real t1, t1a, t2, t2a
>        real dat1, dat2
> -      real dt
>        integer i, j, values(8)
> -      dt = 40e-3
>        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 (int ((dat1 - t1 + dt * 0.5) / dt) .ne. 0) call abort ()
> +      if (((dat1 - t1) < 0.) .or. ((dat1 - t1) > (t1a - t1))) call abort ()
>        do j=1,10000
>          do i=1,10000
>          end do
>        end do
> +      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))
> -      t2 = secnds (t1)
> -      if (int ((dat1-dat2 + t2 + dt * 0.5) / dt) .ne. 0.0) call abort ()
> +      if (((dat2 - dat1) < t2a) .or. ((dat2 - dat1) > t2)) call abort ()
>        end

This is OK.  ;)

Jerry



More information about the Fortran mailing list