This is the mail archive of the 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]

RE: GNU Fortran inquiry


> I must use a random generator.
> So, I use the following intrinsic function : rand(seed).
> Netherveless, a given seed always produces the same sequence of
> values from rand.

Assumed i don't missunderstand you repective your english wording:

According to my understandig how the Unix Fortran (i.e. Non
standard Fortran-77) intrinsic "rand" works, you had to call the
seed initialisation routine "srand" with the seed value. Then
succsessive calls of "rand" will give you a sequence of pseudo random
numbers for this seed.

That way, the sequence

   Call srand(seed_value)

   do j= 1,10
     Write(*,*) rand()

will give you ten "random numbers" for the seed seed_value.

Of course, the sequences will be identical if you use the same
seed_value. That the way the things are (and should be) wired.
Otherwise you have no change to reproduce your simulation, for
debugging purpose of the program, for example.

> I would like to know if it is possible to use a constant to seed
> with the current time.

Yes, but Tex motto applies: User had to work it out. But i doubt,
you mean it this way.

If you had to use "much" random numbers, you had to check, if
the periodicity intervall of the  pseudo random number generator
used, is sufficient for this.

Hope that i don't had missinterpret your question!

  Peter Schorsch

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