RANECU
The Random Number Generator RANECU is a FORTRAN application. RANECU produces uniform random numbers on [0,1]. RANECU is multiplicative linear congruential generator suitable for a 16-bit platform. It combines three simple generators, and has a period exceeding 81012.
It is constructed for more efficient use by providing for a sequence of random numbers and the numbers are returned in a single call. A set of three non-zero integer seeds can be supplied, failing which a default set is employed. If supplied, these three seeds, in order, should lie in the ranges [1,32362], [1,31726] and [1,31656] respectively.
SUBROUTINE
RANECU (RVEC,LEN)
C
Portable random number generator for 16 bit computer.
C
Generates a sequence of LEN pseudo-random numbers, returned in
C
RVEC.
DIMENSION RVEC(*)
SAVE
ISEED1,ISEED2, ISEED3
DATA
ISEED1,ISEED2,ISEED3/1234, 5678, 9876/
C
Default values, used if none supplied via an ENTRY
C
call at RECUIN
DO
100 I = 1,LEN
K=ISEED1/206
ISEED1 = 157*ISEED1-K*06) - K*1
IF(ISEED1.LT.0) ISEED1=ISEED1+32363
K=ISEED2/217
ISEED2 = 146*(ISEED2-K*217)-K*5
IF(ISEED2.LT.O) ISEED2=ISEED2+31727
K=ISEED3/222
ISEED3 = 142*(ISEED3-K*222)-K*133
IF(ISEED3.LT.0) ISEED3=ISEED3+31657
IZ=ISEED1-ISEED2
IF(IZ.GT.706)IZ = Z- 2362
IZ = 1Z+ISEED3
IF(IZ.LT.1)IZ = 1Z+32362
RVEC(I)=REAL(IZ)*3.0899E-5
100 CONTINUE
RETURN
ENTRY RECUIN(IS1, IS2, IS3)
ISEED1=IS1
ISEED2=IS2
ISEED3=IS3
RETURN
ENTRY RECUUT(IS1,IS2,IS3)
IS1=ISEED1
IS2=ISEED2
IS3=ISEED3
RETURN
END