c**********************************************************************
      subroutine inside ( x0, y0, px, py, n, insde) 
 
c check if point X0,Y0 inside polygon PX,PY
c INSDE = 0 if point outside
c       = +/-1 if inside
c       = 2 if on perimeter

      implicit real*8 (a-h,o-z)
      dimension px(n), py(n)

      insde=0 
      if (n .eq. 0) return

      do ii = 1,n-1
        pxmx=px(ii)-x0
        pymy = py(ii)-y0
        pxmx1=px(ii+1)-x0
        pymy1=py(ii+1)-y0

        call cross (pxmx, pymy, pxmx1, pymy1, isicr)

        if (isicr .eq. 4) goto 6
        insde=insde+isicr
      enddo

        pxmx =  px(n)-x0
        pymy =  py(n)-y0
        pxmx1 = px(1)-x0
        pymy1 = py(1)-y0

        call cross (pxmx, pymy, pxmx1, pymy1, isicr)

      if (isicr .eq. 4) goto 6

      insde=abs(int(real(insde+isicr)/2.0d0))

      return

  6   insde=2

      return
      end 

