#include #include "mpi.h" /************************************************************ This is a simple send/receive program in MPI ************************************************************/ int main(argc,argv) int argc; char *argv[]; { int myid; int tag,tag1,source,destination,destination1,count; int buffer; MPI_Status status; MPI_Init(&argc,&argv); MPI_Comm_rank(MPI_COMM_WORLD,&myid); tag=1234; tag1=12345; source=0; destination=1; destination1=3; count=1; if(myid == source){ buffer=5678; MPI_Send(&buffer,count,MPI_INT,destination,tag,MPI_COMM_WORLD); printf("processor %d sent %d\n",myid,buffer); } if(myid == destination){ MPI_Recv(&buffer,count,MPI_INT,source,tag1,MPI_COMM_WORLD,&status); printf("processor %d got %d\n",myid,buffer); } printf("Processor %d \n",myid); printf("Processor %d \n",myid); MPI_Finalize(); }