[comp.sys.sgi] FORTRAN RAND Function

khb@chiba.Eng.Sun.COM (Keith Bierman fpgroup) (01/17/91)

In article <1991Jan17.063559.2704@noose.ecn.purdue.edu> paithan@amide.ecn.purdue.edu (Dilip Paithankar) writes:

   ------
	   PROGRAM RANDOM
   C       Program to generate 25 random numbers.
	   INTEGER ISEED
	   DOUBLE PRECISION X
	   DO 10 J = 1, 25
	   CALL SRAND(ISEED)
	   X = RAND ()
	   WRITE (*,'(1X,''X IS '',G14.6)') X
     10    CONTINUE
	   STOP
	   END
   ------

Do you really, really want to reinitalize the random number generator
every time through the loop ? As long as you provide the same ISEED, I
would expect rand() to produce the same result (whatever it might
happen to be). 

In addition, it is usually poor form to use (reference) a variable
before it is defined .... which would appear to be the case for ISEED.

I don't have my SGI docs handy, so I don't know off-hand if proper
usage is ala Sun. If so, it should be rand(iflag) where iflag is 1,0,
or a seed.

btw: unix rand isn't a very good random number generator, in case
     that happens to matter...

cheers
--
----------------------------------------------------------------
Keith H. Bierman    kbierman@Eng.Sun.COM | khb@chiba.Eng.Sun.COM
SMI 2550 Garcia 12-33			 | (415 336 2648)   
    Mountain View, CA 94043