      subroutine snddat(m,n,nb,lda,ipiv,a,work)
      implicit none

*
*  -- NPAC, Syracuse University --
*     Manish Parashar
*     April 1992
*
*     Routine for collecting factorized matrix at node 0 for checking
*

      integer lda, n, m, nb
      real a(*),work(*)
      real tmp
      integer ipiv(*)
      integer nprocs, me, host
      integer mypanel, panel
      integer i,j,jb, temp
      real resid

      call who0(nprocs,me,host)

      if (me .eq. 0) then
*     ** PUT NODE 0'S PANELS INTO THE WORK ARRAY **
         mypanel = 0
         do 20 j=1,n,nb*nprocs
      	     jb = min (n-j+1,nb)
             do 10 i=1,lda*jb
                 work(mypanel*lda*nb*nprocs+i) = a(mypanel*lda*nb+i)
   10        continue
             mypanel = mypanel + 1
   20    continue

	 if (nprocs.gt.1) then

*     ** NODE 0 RECEIVES PANELS FROM OTHER NODES **

         panel = 0
         do 50 j=1,n,nb
             jb = min(n-j+1,nb)
             temp = mod(panel,nprocs)
             if( temp .ne. 0) then
               call recv0 ( work(panel*nb*lda+1), lda*jb*4, panel)
             endif
             panel = panel + 1
   50    continue
     
	 endif

         call sget1 (n, work, lda, ipiv, lda, tmp, resid )

         print *,"RESIDUAL = ",resid

      else

*     ** OTHER NODES SEND PANELS TO NODE 0 FOR ERROR CHECK **

         mypanel = 0
         do 250 j=1+me*nb,n,nb*nprocs
      	     jb = min (n-j+1,nb)
             call send0(a(mypanel*lda*nb+1),lda*jb*4,
     *                   mypanel*nprocs+me,0)
             mypanel = mypanel + 1
  250    continue
      endif

      return
      end
