DOUBLE PRECISION FUNCTION ACORN() C C FORTRAN IMPLEMENTATION OF ACORN RANDOM NUMBER GENERATOR OF ORDER C LESS THAN OR EQUAL TO 120 (HIGHER ORDERS CAN BE OBTAINED BY C INCREASING THE PARAMETER VALUE MAXORD) AND MODULUS LESS THAN OR C EQUAL TO 2^60. C C AFTER APPROPRIATE INITIALIZATION OF THE COMMON BLOCK /IACO2/ EACH C CALL TO ACORN GENERATES A SINGLE VARIATE DRAWN FROM A UNIFORM C DISTRIBUTION OVER THE UNIT INTERVAL. C PARAMETER (MAXORD=120, MAXOP1=MAXORD+1) COMMON /IACO2/ KORDEJ, MAXJNT, IXV1(MAXOP1), IXV2(MAXOP1) DO 10 I = 1, KORDEJ IXV1(I + 1) = (IXV1(I + 1) + IXV1(I)) IXV2(I + 1) = (IXV2(I + 1) + IXV2(I)) IF (IXV2(I + 1) .GE. MAXJNT) THEN IXV2(I + 1) = IXV2(I + 1) - MAXJNT IXV1(I + 1) = IXV1(I + 1) + 1 END IF IF (IXV1(I + 1) .GE. MAXJNT) IXV1(I + 1) = IXV1(I + 1) - MAXJNT 10 CONTINUE ACORN = (DBLE(IXV1(KORDEJ + 1)) + & DBLE(IXV2(KORDEJ + 1)) / MAXJNT) / MAXJNT END C ****************************************************************** SUBROUTINE SACORN(ISEED) C C INITIALISES THE ACORN GENERATOR: C C KORDEJ - LESS OR EQUAL MAXORD. C MAXJNT - SHOULD BE 2**30. C IXV1 - ARRAY OF ARBITRARY ODD INTEGERS, EACH LESS THAN MAXJNT. C IXV2 - ARRAY OF ARBITRARY INTEGERS, EACH LESS THAN MAXJNT. C PARAMETER (MAXORD=120, MAXOP1=MAXORD+1) COMMON /IACO2/ KORDEJ, MAXJNT, IXV1(MAXOP1), IXV2(MAXOP1) KORDEJ = 120 MAXJNT = 2**30 IFIRST = MOD(ISEED, MAXJNT) IF (MOD(IFIRST, 2) .EQ. 0) IFIRST = IFIRST - 1 IXV1(1) = IFIRST END