************************************************************************
C                          DISTRIB_GRSOL.F
C Calculate histograms for the radial distribution function.
C Uses ratint,locate.
************************************************************************
      subroutine distrib(x,y,dhistogram)
      include 'pimc_sqr3sc.dcl'
      dimension dhistogram(nhistx,nhisty)
      dimension x(2*m,nat),y(2*m,nat)
      
      stepx=xdim/float(nhistx)
      stepy=ydim/float(nhisty)
      do islice=1,m
         do i=1,nat
            tx1=x(islice,i)
            ty1=y(islice,i)
            do k=1,nhistx
               bin1x=stepx*float(k-1)
               bin2x=stepx*float(k)
               do l=1,nhisty
                  bin1y=stepy*float(l-1)
                  bin2y=stepy*float(l)
                  if(tx1.gt.bin1x.and.tx1.le.bin2x) then
                     if(ty1.gt.bin1y.and.ty1.le.bin2y) then
                        dhistogram(k,l)=dhistogram(k,l)+1.
                        goto 10
                     end if
                  end if
               end do
            end do
c            print*,'point not found'
 10         continue
         end do
      end do
      return
      end


