      SUBROUTINE RANDOM(R,SEED)
C  	SEED is used on the first call, regardless of its value.
C  	After that it is used only if SEED(1) positive.
C       The two elements of R are treated as 16-bit omponents of a 32-bit 
C       integer, with R(1) being the low 16 bits.  This big integer is 
C       updated by the formula RNEW=MOD(LAMBDA*ROLD+ALPHA,2**32).  Note 
C       that R(2) will be usable as a sequence of uniformly distributed 
C       integers in (0,65535), but R(1) will have a period of 65536.
      LOGICAL FIRST(1)
      INTEGER R(2),RLOCAL(2),SEED(2),ALPHA,LAMBDA,L
	PARAMETER(ALPHA=5,LAMBDA=69)
	SAVE FIRST,RLOCAL
	DATA FIRST/.TRUE./
      IF (FIRST(1).OR.SEED(1).GT.0) THEN
        RLOCAL(1)=iabs(SEED(1))
        RLOCAL(2)=iabs(SEED(2))
        FIRST(1)=.FALSE.
      ENDIF
      L=ALPHA
      DO 10 I=1,2
        N=LAMBDA*RLOCAL(I)+L
        L=N/2**16
        N=MOD(N,2**16)
        RLOCAL(I)=N
        R(I)=N
10    CONTINUE
      RETURN
      END

