Languages and Scripting
Showing results for 
Search instead for 
Do you mean 

how to use (link) random number generator

SOLVED
Go to Solution
Highlighted
Frequent Advisor

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
3 REPLIES
Honored Contributor [Founder]

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.
Honored Contributor [Founder]

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

Frequent Advisor

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.