mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-05 00:41:19 -05:00
2c17544f3f
git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/WSJT/trunk@1 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
29 lines
802 B
Fortran
29 lines
802 B
Fortran
FUNCTION ran1(idum)
|
|
INTEGER idum,IA,IM,IQ,IR,NTAB,NDIV
|
|
REAL ran1,AM,EPS,RNMX
|
|
PARAMETER (IA=16807,IM=2147483647,AM=1./IM,IQ=127773,IR=2836,
|
|
*NTAB=32,NDIV=1+(IM-1)/NTAB,EPS=1.2e-7,RNMX=1.-EPS)
|
|
INTEGER j,k,iv(NTAB),iy
|
|
SAVE iv,iy
|
|
DATA iv /NTAB*0/, iy /0/
|
|
if (idum.le.0.or.iy.eq.0) then
|
|
idum=max(-idum,1)
|
|
do 11 j=NTAB+8,1,-1
|
|
k=idum/IQ
|
|
idum=IA*(idum-k*IQ)-IR*k
|
|
if (idum.lt.0) idum=idum+IM
|
|
if (j.le.NTAB) iv(j)=idum
|
|
11 continue
|
|
iy=iv(1)
|
|
endif
|
|
k=idum/IQ
|
|
idum=IA*(idum-k*IQ)-IR*k
|
|
if (idum.lt.0) idum=idum+IM
|
|
j=1+iy/NDIV
|
|
iy=iv(j)
|
|
iv(j)=idum
|
|
ran1=min(AM*iy,RNMX)
|
|
return
|
|
END
|
|
C (C) Copr. 1986-92 Numerical Recipes Software *(t9,12.
|