!
!   simple program to test a random number generator     
!   and the central limit theorem
!

     program central 
     integer,dimension(:),allocatable::histo
      idum=2002                 ! seed for random number generator
      write(6,*) 'number of random numbers to be summed (0=100)'
      read(5,*) n
      write(6,*) 'number of iterations(0=10000)'
      read(5,*) nt
      if(n==0) n=100
      if(nt==0) nt=10000
      allocate(histo(n))
      do i=1,nt
        s=0.0
        do j=1,n
            s=s+ran0(idum)
        enddo
        j=s
        histo(j)=histo(j)+1
      enddo
      open(unit=11,file='histo',status='unknown')
      do i=1,n
        write(11,*) i,histo(i)*1.0/nt
       enddo
       end

      
!
!----------ran0-------------
!
! completely basic (and wrong) random number generator
! replace with your own !
!
      function ran0(idum)
      idum=123456789*idum+987654321
      idum=mod(idum,2**30)
      ran0=idum/(2**30*1.0)
      if(ran0.lt.0.0) ran0=ran0+1.0
      return
      end

