Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!newstop!exodus!exodus-bb!khb From: khb@chiba.Eng.Sun.COM (Keith Bierman fpgroup) Newsgroups: comp.sys.sgi Subject: Re: FORTRAN RAND Function Message-ID: Date: 17 Jan 91 09:23:47 GMT References: <1991Jan17.063559.2704@noose.ecn.purdue.edu> Sender: news@exodus.Eng.Sun.COM Distribution: na Organization: Sun MegaSystems Lines: 37 In-reply-to: paithan@amide.ecn.purdue.edu's message of 17 Jan 91 06:35:59 GMT 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