#include #include #include "mpi.h" int main(int argc, char **argv) { int rank, size; MPI_Status status; double pi; int i, count; MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &size); count = 1; if (rank == 0) { MPI_Recv(&pi, 1, MPI_DOUBLE, 1, 10, MPI_COMM_WORLD, &status); printf("Data received from process 1:\n"); printf("%.20f\n", pi); } else { if (rank == 1) { pi = M_PI; MPI_Send(&pi, count, MPI_DOUBLE, 0, 10, MPI_COMM_WORLD); } } MPI_Finalize(); return 0; } /* MPICH version on the workstations: mpicc.mpich passOneMPI.c -lm mpirun.mpich -np 2 -all-local a.out (Enter password once) Data received from process 1: 3.14159265358979311600 CRAY SV1: cc passOneMPI.c mpirun -np 2 a.out Data received from process 1: 3.14159265358979000000 */