#include // for input/output #include //for mpi routines #define BUFSIZE 10 //The size of the messege being passed main( int argc, char** argv) { int rank; //the rank of this process float sendbuf[BUFSIZE], recvbuf[BUFSIZE]; int tag = 0; MPI_Status status; //not important here MPI_Init(&argc, &argv); //Initializing mpi MPI_Comm_rank(MPI_COMM_WORLD, &rank); //Getting my rank if( rank == 0 ) { printf("Hello world! I am proc 0, waiting for message from proc 1\n"); //recieve from proc 1 MPI_Recv(recvbuf, BUFSIZE, MPI_FLOAT, 1, tag, MPI_COMM_WORLD, &status); //send to the proc 1 MPI_Send(sendbuf, BUFSIZE, MPI_FLOAT, 1, tag, MPI_COMM_WORLD); } else if( rank == 1) { printf("Hello world! I am proc 1, waiting for message from proc 0\n"); //recieve from the proc 0 MPI_Recv(recvbuf, BUFSIZE, MPI_FLOAT, 0, tag, MPI_COMM_WORLD, &status); //send to the proc 0 MPI_Send(sendbuf, BUFSIZE, MPI_FLOAT, 0, tag, MPI_COMM_WORLD); } printf("Proc %d finished!!\n", rank); MPI_Finalize(); return 0; }