- }
- if ((pivot+1) == rank) {
- int src= rank - 1;
- err = MPI_Recv(&msg, 1, MPI_INT, src, tag1, MPI_COMM_WORLD, &status); /* Receive a message */
- printf("[%d] Received 1st message '%d' from process [%d] \n", rank,msg, src);
- msg++;
- printf("[%d] increment message's value to '%d'\n", rank,msg);
- printf("[%d] About to send back message '%d' to process [%d] \n", rank,msg, src);
- err = MPI_Send(&msg, 1, MPI_INT, src, tag2, MPI_COMM_WORLD);
- }
- }
- err = MPI_Finalize(); /* Terminate MPI */
- return 0;
+ }
+ if ((pivot + 1) == rank) {
+ int src = rank - 1;
+ err = MPI_Recv(&msg, 1, MPI_INT, src, tag1, MPI_COMM_WORLD, &status); /* Receive a message */
+ printf("[%d] Received 1st message '%d' from process [%d] \n", rank,
+ msg, src);
+ msg++;
+ printf("[%d] increment message's value to '%d'\n", rank, msg);
+ printf("[%d] About to send back message '%d' to process [%d] \n",
+ rank, msg, src);
+ err = MPI_Send(&msg, 1, MPI_INT, src, tag2, MPI_COMM_WORLD);
+ }
+ }
+ err = MPI_Finalize(); /* Terminate MPI */
+ return 0;