int main(int argc, char* argv[])
{
  int i;
  int rank, nproc;
  int isend[3], irecv[3];
  MPI_Init(&argc, &argv);
  MPI_Comm_size(MPI_COMM_WORLD, &nproc);
  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
  for(i = 0; i< nproc; i++){
    isend[i] = i + nproc *rank;
    printf("node %d: isend[%d] = %d\n", rank, i, isend[i]);
  }
  fflush(stdout);
  sleep(2);
printf("Start Send\n");
  MPI_Alltoall(isend, 1, MPI_INTEGER, irecv, 1, MPI_INTEGER, MPI_COMM_WORLD);

  for(i = 0; i< 3; i++)
    printf("node %d: irecv= %d\n", rank, irecv[i]);
  MPI_Finalize();
}

node 0: isend[0] = 0
node 0: isend[1] = 1
node 0: isend[2] = 2
node 1: isend[0] = 3
node 1: isend[1] = 4
node 1: isend[2] = 5
node 2: isend[0] = 6
node 2: isend[1] = 7
node 2: isend[2] = 8
Start Send
node 0: irecv= 0
node 0: irecv= 3
node 0: irecv= 6
Start Send
node 1: irecv= 1
node 1: irecv= 4
node 1: irecv= 7
Start Send
node 2: irecv= 2
node 2: irecv= 5
node 2: irecv= 8