/* file: hello.c compile: cc -64 hello.c -lmpi run: mpirun -np 2 ./a.out */ #include "mpi.h" main( argc, argv ) int argc; char **argv; { char message[20]; int myrank; MPI_Status status; MPI_Init( &argc, &argv ); MPI_Comm_rank( MPI_COMM_WORLD, &myrank ); if (myrank == 0) /* code for process zero */ { strcpy(message,"Hello, there"); MPI_Send(message, strlen(message)+1, MPI_CHAR, 1, 99, MPI_COMM_WORLD); } else /* code for process one */ { MPI_Recv(message, 20, MPI_CHAR, 0, 99, MPI_COMM_WORLD, &status); printf("rank%d received :%s\n", myrank, message); } MPI_Finalize(); }