*******************************************************************************
C                                DSTPBC.F
C This subroutine calculates the distance between two points in a periodic 
C cell.
*******************************************************************************
      subroutine dstpbc(x1,x2,dbox,dst,sgn)
      include 'pimc_sqr3sc.dcl'
c      small=1.e-10
      dst=abs(x1-x2)
      if(dst.lt.small) dst=small
      sgn=(x1-x2)/dst  
      if(dst.gt.dbox/2.) then
         sgn=-sgn  
         dst=dbox-dst
      end if
      return
      end


