      SUBROUTINE send_mesh
      
      INCLUDE 'irreg.h'
      
      integer i,conn,j,k,offset
      integer index,temp
c$$$  integer l
      integer mesh_n(0:nm)
c$$$      integer node_info(0:npm,0:11)
      integer n_index(0:n6m)
      integer proc_info(0:np)
c$$$      real n_coord(0:dm,0:n6m),scoord(0:n18m),coord_buffer(0:n18m)

      common /makesend/ mesh_n,n_index
      
      
CC    Read the data from the files n_coord, n_info and n_count
c$$$      
c$$$      open(unit=45,file='n_info',form='formatted',
c$$$     &     access='sequential',status='old')
c$$$      
c$$$      open(unit=46,file='n_count',form='formatted',
c$$$     &     access='sequential',status='old')
c$$$      
c$$$      open(unit=47,file='n_coord',form='formatted',
c$$$     &     access='sequential',status='old')
c$$$      
c$$$      open(unit=48,file='np_coord',form='formatted',
c$$$     &     access='sequential',status='old')
c$$$      
c----------------------------------------------------------------------------
c--------------------GETTHE MESH DATA AND SEND IT TO NODES------------------
c----------------------------------------------------------------------------
      
C-----------getthe no. of neighbours per node
c$$$      
c$$$      
c$$$      do i= 0,nm
c$$$         read(45,*)mesh_n(i)
c$$$      enddo
c$$$      
C-----------getthe total number of neighbours per processor
      
      do i=0,nm
         k = i/nprocs
         proc_info(k)=proc_info(k)+mesh_n(i)
      enddo
      
      conn = ((6*(nm+1))-1)     ! total connectivity
c$$$      
c$$$      do i=0,conn
c$$$         read(46,*)n_index(i)
c$$$      enddo
      
c     do i=0,conn
c     print *,'n_index ',n_index(i)
c     enddo
      
      
CC    Do the communication
      
      do i=0,(nprocs-1)
         
c     print *,'Proc info is ',proc_info(i)
         offset=i*np
            if (iswap .ne. 0)
     $           Call kxswap(mesh_n(offset),
     $           mesh_n(offset),4,np)
         status=kxwrit(mesh_n(offset),4*np,i,100)
            if (iswap .ne. 0)
     $           Call kxswap(mesh_n(offset),
     $           mesh_n(offset),4,np)
      enddo

CC    wait for the nodes to acknowledge receipt
ccc      print *,"Waiting for Acknowledgement 1"
      do i=0,(nprocs-1)
         status=kxread(temp,4,i,99)
      end do
      print *,"Host Passed Acknowledgement 1 stage"
      
c     sending the indices of the neighbours
      
      index = 0
      do i=0,(nprocs-1)
         do j=0,npm
            offset = mesh_n(j+(np*i))
ccc      print *,'i is,offset is',i,offset
            if (iswap .ne. 0)
     $           Call kxswap(n_index(index),
     $           n_index(index),4,offset)
            status=kxwrit(n_index(index),4*offset,i,110)
            if (iswap .ne. 0)
     $           Call kxswap(n_index(index),
     $           n_index(index),4,offset)
            index = index+offset
         enddo
      enddo

CC    wait for the nodes to acknowledge receipt
ccc      print *,"Waiting for Acknowledgement 2"
      do i=0,(nprocs-1)
         status=kxread(temp,4,i,99)
      end do
      print *,"Host Passed Acknowledgement 2 stage"
      
         return
         end
