RANDOM

Run-Time Subroutine: Returns a pseudorandom number greater than or equal to zero and less than one from the uniform distribution.

Module: USE DFLIB

Syntax

CALL RANDOM (ranval)

ranval
(Output) REAL(4). Pseudorandom number, 0 <= ranval < 1, from the uniform distribution.

A given seed always produces the same sequence of values from RANDOM.

If SEED is not called before the first call to RANDOM, RANDOM begins with a seed value of one. If a program must have a different pseudorandom sequence each time it runs, pass the constant RND$TIMESEED (defined in DFLIB.F90 in the \DF98\INCLUDE subdirectory) to SEED before the first call to RANDOM.

All the random procedures (RANDOM, RAN, and RANDOM_NUMBER, and the portability functions DRAND, DRANDM, RAND, IRANDM, RAND, and RANDOM) use the same algorithms and thus return the same answers. They are all compatible and can be used interchangeably. (The algorithm used is a "Prime Modulus M Multiplicative Linear Congruential Generator," a modified version of the random number generator by Park and Miller in "Random Number Generators: Good Ones Are Hard to Find," CACM, October 1988, Vol. 31, No. 10.)

Compatibility

CONSOLE STANDARD GRAPHICS QUICKWIN GRAPHICS WINDOWS DLL LIB

See Also: RANDOM_NUMBER, SEED, DRAND and DRANDM, IRAND and IRANDM, RAN, RAND

Example

 USE DFLIB
 REAL(4) ran

 CALL SEED(1995)
 CALL RANDOM(ran)