This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gfortran] PATCH -- Fix segfault in RANDOM_SEED.


This patch fixes a segfault when using the PUT 
argument of RANDOM_SEED.  There, however, is a
major problem with the current PRNG.  This 
simple program appears to trigger an alarmingly
bad sequence of numbers.

   program s
   integer, allocatable :: a(:)
   integer i,n
   real x(10)
   call random_seed(size=n)
   allocate(a(n))
   a = (/ (i, i = 1, n) /)
   call random_seed(put=a)
   call random_number(x)
   do i = 1, 10
      print '(I2,2X,E15.6)', i, x(i)
   end do
   end program s

kargl[212] ./s
 1     0.928994E-07
 2     0.597788E+00
 3     0.935979E-07
 4     0.597788E+00
 5     0.933650E-07
 6     0.597788E+00
 7     0.931322E-07
 8     0.597788E+00
 9     0.938307E-07
10     0.597788E+00


2004-05-23  Steven G. Kargl  <kargls@comcast.net>
    * random.c (random_seed): Use correct variable.

-- 
Steve

Attachment: random.c.diff
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]