next up previous
Next: Communication using send/receive Up: Redistribution of block-cyclic data Previous: Unpacking the data

Detailed communication code


Communicating the Data 2

  do istep=0,k-1
     j = istep*b2size/k
     call mpi_irecv (tbuf2(j), b2size, MPI_PACKED,
                     MPI_ANY_SOURCE, tag, comm,
                     reqobj, ierr)
  end do

  do istep=0,k-1
     gindex = p*istep + myrank
   
     PACK DATA INTO tbuf1, FIND pos 

     dest = gindex/k
     call mpi_send (tbuf1, pos, MPI_PACKED,
                    dest, tag, comm, ierr)
  end do

  do istep=0,k-1
     call mpi_waitany (k, reqobj, indx, status, ierr)
     pos = (indx-1)*b2size/k

     UNPACK DATA FROM tbuf2

  end do



David W Walker
Mon Jan 20 11:10:22 GMT 1997