      program test
      implicit none
      integer npoints,i
      double precision x(100),y(100),z(100),A,B,D,
     &  ran2,fatbeta
      A=0.009d0
      B=0.01d0
      D=0.2d0
      npoints=100
      do i=1,npoints
        x(i)=3000.0d0*ran2()
        y(i)=20.0d0*ran2()
        z(i)=-D-A*x(i)-B*y(i)
      enddo
      A=1.0d0
      B=1.0d0
      D=1.0d0
      call planarfit(npoints,x,y,z,A,B,D,fatbeta)
      write(*,*)A,B,D,fatbeta
      end
