#include "mpi.h"
#include <string.h>
#include <stdio.h>
int main( int argc, char **argv){
 char message[20];
 char messaggio[20];
 int myrank;
 MPI_Status status1;
 MPI_Status status2;
 MPI_Init( &argc, &argv );
 MPI_Comm_rank( MPI_COMM_WORLD, &myrank );
 if (myrank == 0){  /* code for process zero */
  strcpy(message,"Hello, there");
  strcpy(messaggio,"Hello, there");
  MPI_Send(message, strlen(message)+1, MPI_CHAR, 1, 99, MPI_COMM_WORLD);
  MPI_Send(messaggio, strlen(message)+1, MPI_CHAR, 2, 98, MPI_COMM_WORLD);
 }
 else if (myrank == 1){ /* code for process one */
  MPI_Recv(message, 20, MPI_CHAR, 0, 99, MPI_COMM_WORLD, &status1);
  printf("(1)received :\"%s\"\n", message);
 }
 else if (myrank == 5){ /* code for process one */
  MPI_Recv(messaggio, 20, MPI_CHAR, 0, 98, MPI_COMM_WORLD, &status2);
  printf("(2)received :\"%s\"\n", messaggio);
 }

 MPI_Finalize();
 return 0;
}
