      SUBROUTINE CUBEINIT ( LDA, M, N, NB )
c     opens cube to specified dimensions
*
*     Scalar arguments ...
      INTEGER      NB, N, M, LDA
*
*
*  .. Local Scalars ..
      INTEGER      DIM, NUMPANELS, temp(4), i,jj, start, stop
      INTEGER      proc, panel, jb, nodes, me ,host
      double precision time, mflops
      character*20 tracefile
*
*     ------------------------------------------------------
*     open communication channels and load node program 
*     into all nodes
*     ------------------------------------------------------
*
c     write(*,*) 'Enter name for tracefile:'
c     read(*,*) tracefile

      if (nb.eq.n) then
	 dim = 0
      else
      write(*,*) 'Enter DIM (0-7)'
      read(*,*) dim
      endif

      write(*,*) 'Enter starting nb: '
      read(*,*) start
      write(*,*) 'Enter stopping nb: '
      read(*,*) stop

c     dim = 6
      nodes = 2**dim
      write ( 6, * ) 'cube dimension:',dim,'   nodes:',nodes

c     call traceenable(tracefile,0)

      call open0 ( nodes, me, host )
      call load0 ( 'node', -1)
      call setarc0 (nodes, 3, 0, 1)
      print *,' TOPOLOGY:  UNIDIRECTIONAL RING '

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

      numpanels = (n+nb-1)/nb
*     ** broadcast n, m, lda, nb to the nodes **
      temp(1) = n
      temp(2) = m
      temp(3) = lda
      temp(4) = nb

      call bcast0 (temp,16,16000,host)

*     receive timing back from node 0 **

      call recv0(time,8,16001)

      mflops = ((1./3.)*LDA*LDA*LDA)/(1.0e6*time)
      print *,lda,nodes,nb,"TIME= ",time,"MFLOPS = ",mflops
     
      call close0(1)

      return
      end
