randomizing the seed - unintuitive behaviour

Kamaraju Kusumanchi kamaraju@gmail.com
Sun Feb 27 06:08:00 GMT 2005


consider the following program
program random
implicit none
  real :: x
  call random_seed();
  call random_number(x);
  write(*,*) x
end program random

When I run this program, I want to output different random numbers for
each run. This does not happen with gfortran.

$gfortran random.f90

$./a.out
  0.1264991

$./a.out
  0.1264991

$./a.out
  0.1264991

I agree that this behaviour is standard conforming. But it is counter
intuitive. I tried intel compiler (ifort 8.1). It does what I want to
do.

$ifort random.f90

$./a.out
  0.3770227

$./a.out
  0.7290102

$./a.out
  8.0997661E-02

$./a.out
  0.1369602

Do the experts consider this as a bug or is it a feature?

thanks
raju

-- 
Kamaraju S Kusumanchi
Cornell University
http://people.cornell.edu/pages/kk288/
http://groups.yahoo.com/group/flumech/



More information about the Fortran mailing list