!--------------------------------------------------------! !Random number generator based on algorithm 'mzran' by ! !Marsiglia and Zaman, Computers in Physics, 8, 107 (1994)! !--------------------------------------------------------! !rand() generates a random number in the range [0,1) ! !initrand(w) reads 4 integer seeds from 'seed.in', ! !writes new random seeds to the same file if w/=0. ! !--------------------------------------------------------! !-----------------------! real(8) function rand() !-----------------------! implicit none integer :: iir,jjr,kkr,nnr,mzran common/brand/iir,jjr,kkr,nnr,mzran mzran=iir-kkr if (mzran < 0) mzran=mzran+2147483579 iir=jjr; jjr=kkr; kkr=mzran nnr=69069*nnr+1013904243 mzran=mzran+nnr rand=0.5d0+mzran*0.23283064d-9 end function rand !-----------------! !----------------------! subroutine initrand(w) !----------------------! implicit none integer :: iir,jjr,kkr,nnr,mzran common/brand/iir,jjr,kkr,nnr,mzran integer :: w real(8) :: rand open(1,file='seed.in',status='old') read(1,*)iir read(1,*)jjr read(1,*)kkr read(1,*)nnr close(1) iir=abs(iir)+1; jjr=abs(jjr)+1; kkr=abs(kkr)+1 if (w /= 0) then open(1,file='seed.in',status='replace') write(1,*)abs(int((rand()-0.5d0)/0.23283064d-9)) write(1,*)abs(int((rand()-0.5d0)/0.23283064d-9)) write(1,*)abs(int((rand()-0.5d0)/0.23283064d-9)) write(1,*)abs(int((rand()-0.5d0)/0.23283064d-9)) close(1) end if end subroutine initrand !-----------------------!