Languages and Scripting
Showing results for 
Search instead for 
Did you mean: 

how to use (link) random number generator

Go to solution
Reggie Chang
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

Any opinion is very appreciated.

Steven Schweda
Honored Contributor

Re: how to use (link) random number generator

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

"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

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

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....

Reggie Chang
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.