!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! KISS is a subroutine for generating 32 bit random integers written by !! !! George Marsaglia and Arif Zaman at Florida State. !! !! !! !! To guarantee a long period, the first seed should be between 1 and 2580 !! !! The other two seeds should be 32 bit numbers !! !! !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! module kiss_random ! rcs id string character(*), parameter :: kiss_rcsid='\$Id: kiss.f90,v 1.7 1997/08/20 20:04:29 browngrg Exp \$' integer, parameter :: krkind=selected_int_kind(9) integer(krkind), private :: i=123456789_krkind integer(krkind), private :: j=362436069_krkind integer(krkind), private :: k=521288629_krkind contains integer(krkind) function irand() integer(krkind) :: m,n,p m(p,n)=ieor(p,ishft(p,n)) i=69069_krkind*i+23606797_krkind j=m(m(j,17_krkind),-15_krkind) k=m(iand(m(k,18_krkind),2147483647_krkind),-13_krkind) irand=i+j+k return end function irand subroutine irandset(ii,jj,kk) integer(krkind), intent(in) :: ii,jj,kk i=ii j=jj k=kk return end subroutine irandset real function urand() ! [0,1] urand=abs(real(irand()))/real(huge(2_krkind)) return end function urand real function urandii() ! [0,1] urandii=abs(real(irand()))/real(huge(2_krkind)) return end function urandii real function urandxx() ! (0,1) urandxx=abs(real(irand()))/real(huge(2_krkind)) do while((urandxx<=0.).or.(urandxx>=1.)) urandxx=abs(real(irand()))/real(huge(2_krkind)) end do return end function urandxx real function urandxi() ! (0,1] urandxi=abs(real(irand()))/real(huge(2_krkind)) do while(urandxi<=0.) urandxi=abs(real(irand()))/real(huge(2_krkind)) end do return end function urandxi real function urandix() ! [0,1) urandix=abs(real(irand()))/real(huge(2_krkind)) do while(urandix>=1.) urandix=abs(real(irand()))/real(huge(2_krkind)) end do return end function urandix subroutine irandprint(iunit) integer, intent(in) :: iunit write(iunit,601) '# KISS seeds: ',i,j,k 601 format(a,i12,2x,i12,2x,i12) return end subroutine irandprint end module kiss_random