[Bug fortran/15619] New: random_seed(get) affects sequence of numbers

pbrook at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Mon May 24 01:45:00 GMT 2004


Calling the random_seed intrinsic to get the seed should affects the following 
sequence of numbers. I'm not sure if this is explicitly illegal, but it's 
definitely very surprising behaviour. 
The following program should print two identical lines: 
program prog 
  integer, allocatable :: a(:) 
  integer i,n 
  real w, x, y, z 
  call random_seed(size=n) 
  allocate(a(n)) 
  call random_seed(get=a) 
  call random_number(w) 
  call random_number(x) 
  call random_seed(put=a) 
  call random_number(y) 
  call random_seed(get=a) 
  call random_number(z) 
  print *, w, x 
  print *, y, z 
end program

-- 
           Summary: random_seed(get) affects sequence of numbers
           Product: gcc
           Version: tree-ssa
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pbrook at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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



More information about the Gcc-bugs mailing list