}
for (i = 1; i < size; i++) {
-#ifdef DEBUG
- fprintf(stderr, "receive sorted data chunk from node %d\n", i);
-#endif /* DEBUG */
- err = MPI_Recv(arrays[i], chunk_size, MPI_DOUBLE, i, TAG_SORTED,
- MPI_COMM_WORLD, &status);
+ err = MPI_Recv(arrays[i], chunk_size, MPI_DOUBLE,
+ MPI_ANY_SOURCE, TAG_SORTED, MPI_COMM_WORLD,
+ &status);
if (err != 0) {
fprintf(stderr,
- "error receiving sorted block from %d\n", i);
+ "error receiving sorted block from %d\n",
+ status.MPI_SOURCE);
exit(EXIT_FAILURE);
}
#ifdef DEBUG
+ fprintf(stderr, "received sorted data chunk from node %d\n",
+ status.MPI_SOURCE);
printarray(stderr, chunk_size, arrays[i], NUM_SHOWN);
fprintf(stderr, "check: sum of %d elements = %g\n",
chunk_size, checkarray(chunk_size, arrays[i]));