------- Comment #2 from fkrogh#gcc at mathalacarte dot com  2009-08-24 17:34 
-------
I had thought that was the case as well.  But when I started getting some
negative times by subtracting the previous value from the current one in the
first location of the array I looked at the info file and found

    Subsequent invocations of `DTIME' return values accumulated since
     the previous invocation.

I modified the code to compute the times between invocations.  The code now
looks like 

      program test_dtime
      integer(8) :: i, j, k
      real, dimension(2) :: tarray
      real :: result
      real :: accum, tarray1
      real :: ptimes(10)
      call dtime(tarray, result)
      print '(''tarray,result:'', 1P, 3E20.11)', tarray, result
      do i=1,100000000          ! Just a delay
        j = i * i - i
      end do
      call dtime(tarray, result)
      print '(''tarray,result:'', 1P, 3E20.11)', tarray, result
      accum = 0.e0    ! Should accumulate 10 times previous tarray(1)
      call dtime(tarray, result)
      tarray1 = tarray(1)
      do k=1, 10
        do i=1,100000000        ! Just a delay
          j = i * i - i
        end do
        call dtime(tarray, result)
        ptimes(k) = tarray(1) - tarray1
        tarray1 = tarray(1)
        accum = accum + tarray(1)
      end do
      print '(''accum ='', 1P, E20.11 )', accum
      print '(''ptimes ='', 1P, (3E20.11))', ptimes
      end program test_dtime

And the output is

tarray,result:   0.00000000000E+00   9.99000039883E-04   9.99000039883E-04
tarray,result:   3.80941987038E-01   3.00000002608E-03   3.83941978216E-01
accum =   1.34219570160E+01
ptimes =   7.64882981777E-01  -3.78940939903E-01   7.60881841183E-01
  -3.77939820290E-01   7.63881921768E-01  -3.80940914154E-01
   7.63882875443E-01  -3.78940820694E-01   7.61881709099E-01
  -3.78939628601E-01

There is a pattern here, but why?  If dtime is getting overflows in times less
than a few seconds, there is a problem as well.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41157

Reply via email to