RAN(3F) — FORTRAN LIBRARY ROUTINES
NAME
ran − return a random number between 0 and 1
SYNOPSIS
real function ran (i)
integer∗4 i
DESCRIPTION
Repeated calls to ran generate random numbers with a uniform distribution.
NOTES
To use this VMS routine, you need the −lV77 option. If you use −lV77, then invoking idate() or time() gets the VMS version.
This is an extremely poor algorithm. See lcrans (3m) instead.
The range includes 0.0 and excludes 1.0. The algorithm is a multiplicative, congruential type, general random number generator. In general, the value of i is set once during execution of the calling program. The initial value of i should be a large odd integer. Each call to ran returns the next random number in the sequence.
To get a different sequence of random numbers each time you run the calling program, you must set the argument i to a different initial value for each run.
Usage:
real r, ran
integer i
i = ...
...
r = ran(i)
Example:
demo$ cat ran1.f
∗ ran1.f -- Generate random numbers.
integer i, n
real r(10)
i = 760013
do n = 1, 10
r(n) = ran ( i )
end do
write ( ∗, "( 5 f11.6 )" ) r
end
demo$ f77 −silent ran1.f −lV77
demo$ a.out
0.222058 0.299851 0.390777 0.607055 0.653188
0.060174 0.149466 0.444353 0.002982 0.976519
demo$
FILES
libF77.a, libV77.a
SEE ALSO
lcrans, addrans, and shufrans in the Numerical Computation Guide.
Sun Release 4.1 — Last change: 2 February 1993