      PROGRAM CHOLNODE
*     ** node program to do cholesky factorization **
      implicit integer (a-z)
      real nflops
      real a(720000), work(300000)
      double precision clock0, time, mflops
      integer lda,m, n, nprocs, info, start, stop, temp(2)
      integer me, host, iarch, iord, idir, nb
      integer proc, mydone, mycols, mypanel
      integer idata(2)
      character*20 filename

      COMMON /LOCN/ PROC, MYDONE, MYCOLS, MYPANEL

      call open0 ( nprocs, me, host )
      call setarc0 (nprocs,iarch,iord,idir)

*
*     ** RECEIVE DATA FROM THE HOST **

      call bcast0(temp,8,16500,host)
      start = temp(1)
      stop = temp(2)

      do 200 nb=start,stop

      call rcvdat(n,m,lda,nb,a)

*     ** BEGIN MAIN ITERATION LOOP FOR QR DECOMPOSITION **

c     call tracenode(30000,0,1)
c     call tracelevel(3,3,0)

      lds = n

      call prof_reset()
      idata(1) = n
      idata(2) = nb

      call hlltbk(n,lda,nb,a,work,info)

      nflops = (1./3.)*n*n*n
      call prof_record("filename",2,idata,nflops)

c     call traceexit()

*     **** SEND DATA BACK TO NODE 0 AND COMPUTE RESIDUAL ****

      call snddat(m,n,nb,lda,a,work)

c     if (me .eq. 0) then
c     mflops = ((1./3.)*LDA*LDA*LDA)/(1.0e6*time)
c     write(*,16) lda,nb,time,mflops
c  16 format(i4,5x,i4,5x,f9.3,5x,f9.3)
c     endif

  200 continue

      time = 0.0d0
      if (me.eq.0) call send0(time,8,16001,host)

      call close0(1)

      end
