
310 CHAPTER 18. CODE LIBRARY
rngranlux.f
The original RANLUX subroutine coded by Fred James [Jam94] following the theoretical
development by L¨uscher [L
¨
94].
C The references are Lu:scher, Computer Physics Communications 79 (1994) 100
C and James, CPC 79 (1994) 111.
SUBROUTINE RANLUX(RVEC,LENV)
C Subtract-and-borrow random number generator proposed by
C Marsaglia and Zaman, implemented by F. James with the name
C RCARRY in 1991, and later improved by Martin Luescher
C in 1993 to produce "Luxury Pseudorandom Numbers".
C Fortran 77 coded by F. James, 1993
C
C references:
C M. Luscher, Computer Physics Communications 79 (1994) 100
C F. James, Computer Physics Communications 79 (1994) 111
C
C LUXURY LEVELS.
C ------ ------ The available luxury levels are:
C
C level 0 (p=24): equivalent to the original RCARRY of Marsaglia
C and Zaman, very long period, but fails many tests.
C level 1 (p=48): considerable improvement in quality over level 0,
C now passes the gap test, but still fails spectral test.
C level 2 (p=97): passes all known tests, but theoretically still
C defective.
C level 3 (p=223): DEFAULT VALUE. Any theoretically possible
C correlations have very small chance of being observed.
C level 4 (p=389): highest possible luxury, all 24 bits chaotic.
C
C!!! ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C!!! Calling sequences for RANLUX: ++
C!!! CALL RANLUX (RVEC, LEN) returns a vector RVEC of LEN ++
C!!! 32-bit random floating point numbers between ++
C!!! zero (not included) and one (also not incl.). ++
C!!! CALL RLUXGO(LUX,INT,K1,K2) initializes the generator from ++
C!!! one 32-bit integer INT and sets Luxury Level LUX ++
C!!! which is integer between zero and MAXLEV, or if ++
C!!! LUX .GT. 24, it sets p=LUX directly. K1 and K2 ++
C!!! should be set to zero unless restarting at a break++