This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Random Number Generator
- From: Toon Moene <toon at moene dot indiv dot nluug dot nl>
- To: Emil Block <blime at his dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Fri, 02 Aug 2002 21:41:43 +0200
- Subject: Re: Random Number Generator
- Organization: Moene Computational Physics, Maartensdijk, The Netherlands
- References: <3D4AB78B.B9163FC4@his.com>
Emil Block wrote:
> Does anyone know why a call to RAND with G77 returns a different value
> than a call to RAND with F77 using the same seed? The computer is a SUN
> Sparc with OS 2.7. The same code is compiled in one case with G77 and in
> the other case with F77.
>
> G77 rand (iseed) returns 0.563463211
> F77 rand (iseed) returns 0.843506
>
> where iseed = 1375.
It would help if you could figure out how the Sun Fortran run time library
does this.
G77's actually does:
srand(iseed);
return rand();
--
Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290
Saturnushof 14, 3738 XG Maartensdijk, The Netherlands
Maintainer, GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
Join GNU Fortran 95: http://g95.sourceforge.net/ (under construction)