how to use (link) random number generator (53 Views)
Reply
Frequent Advisor
Reggie Chang
Posts: 68
Registered: ‎01-30-2002
Message 1 of 4 (53 Views)
Accepted Solution

how to use (link) random number generator

Hi there,

I'm porting a package written in Fortran from
Windows to HP IA-64. I got HP F90 v2.7.1 on
HP-UX B.11.22 U ia64.

In the package, there are lines like
rannum = rand() and
call seed(i_seed)

I was able to have those two lines on Windows,
but got problem complaining ld: Unsatisfied
symbol "seed_" while linking. (No error for
rand_ at all.) What library should I link?
(f90 -O2 +DD64 +U77 -o executable is my link
command.)

Any opinion is very appreciated.

KTC
Please use plain text.
Honored Contributor
Steven Schweda
Posts: 9,068
Registered: ‎02-23-2005
Message 2 of 4 (53 Views)

Re: how to use (link) random number generator

I haven't used Fortran seriously since it was
spelled FORTRAN, but a quick Google search
for:
fortran rand seed
found (among other things)

http://www.cisl.ucar.edu/zine/96/spring/articles/3.random-3.html

"The FORTRAN 77 Standard [4] does not address
the topic of random number generators. Nor is
there an industry standard. Most vendors
provide random number generators as an
extension to FORTRAN 77, but, without the
benefit of a standard, there is no agreement
between vendors on function names or calling
sequences."

Sounds right to me, and suggests that you've
found some non-portable code.

On the other hand, Fortran 90 seems to offer
the intrinsic procedures RANDOM_NUMBER and
RANDOM_SEED. Perhaps a bit of code updating
is in order.
Please use plain text.
Honored Contributor
OldSchool
Posts: 3,372
Registered: ‎09-09-2004
Message 3 of 4 (53 Views)

Re: how to use (link) random number generator

see the fortran intrinsics in the manual...
RAN, RAND, IRAND and SRAND should have carried forward form F77....

http://docs.hp.com/en/B3908-90015/ch11s05.html#d0e66703

Please use plain text.
Frequent Advisor
Reggie Chang
Posts: 68
Registered: ‎01-30-2002
Message 4 of 4 (53 Views)

Re: how to use (link) random number generator

Thanks for the responses. SRAND call is what I'm looking for.

The link to intrinsic function usage is also very much apprecited.
Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation