ran.f
上传用户:jet_ld
上传日期:2022-07-30
资源大小:1k
文件大小:1k
- real function ranw(idum)
- Parameter (Mbig=2**30-2, Xinvers=1./Mbig)
- data ibit/ 1/
- Integer IX(55)
- save
- if (ibit.ne.0) then
- ibit=0
- cc
- cc fill up the vector ix with some random integers, which are
- cc not all even
- cc
- if (idum.eq.0) pause 'use nonzero value of idum'
- idum=abs(mod(idum,Mbig))
- ibit=0
- Ix(1)=871871
- Do i=2,55
- Ix(i)=mod(Ix(i-1)+idum,Ix(i-1))
- Ix(i)=max(mod(Ix(i),Mbig),idum)
- end do
- j=24
- k=55
- cc
- cc warm up the generator
- cc
- do i=1,1258
- Ix(k)=mod(Ix(k)+Ix(j),Mbig)
- j=j-1
- if (j.eq.0) j=55
- k=k-1
- if (k.eq.0) k=55
- end do
- end if
- cc
- cc this is where execution usually starts:
- cc
- Ix(k)=mod(Ix(k)+Ix(j),Mbig)
- j=j-1
- if (j.eq.0) j=55
- k=k-1
- if (k.eq.0) k=55
- ranw=Ix(k)*Xinvers
- end
-