#include #include int main(int argc, char **argv) { int size; int rank; int value; int root=0; int i; int anytag =0; MPI_Status status; MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &size); MPI_Comm_rank(MPI_COMM_WORLD, &rank); if (rank == 0) { printf("Enter your number to send: "); scanf("%d", &value); printf("Sending out %d, address %u, from process %d\n", value, &value, rank); for (i=1; i < size; i++) { MPI_Send(&value, 1, MPI_INT, i, anytag, MPI_COMM_WORLD); } } else { MPI_Recv(&value, 1, MPI_INT, 0, anytag, MPI_COMM_WORLD, &status); printf("Hello from process %d out of %d, Received: %d, Address:%u\n", rank, size, value, &value); } MPI_Finalize(); return 0; } /* mpirun N sendInt1 Enter your number to send: 1234 Sending out 1234, address 3221223644, from process 0 Hello from process 3 out of 6, Received: 1234, Address:3221223900 Hello from process 1 out of 6, Received: 1234, Address:3221223900 Hello from process 2 out of 6, Received: 1234, Address:3221223900 Hello from process 5 out of 6, Received: 1234, Address:3221223900 Hello from process 4 out of 6, Received: 1234, Address:3221223900 */