title: MPI_Sendrecv deadlock
body: <p>Could anyone help me to fix the bug in the following simple MPI prog. I was trying to use MPI_Sendrecv to send the "c" value from rank 1 to 2, and they print it from rank 2. 
  But, the following code ends with a deadlock. 
  What is the mistake, how to correctly use MPI_Sendrecv (in this situation)</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include"mpi.h"
  
  int main (int argc, char **argv)
  {
          int size, rank;
          MPI_Init(&amp;argc,&amp;argv);
          MPI_Comm_size(MPI_COMM_WORLD,&amp;size);
          MPI_Comm_rank(MPI_COMM_WORLD,&amp;rank);
          printf("Hi dear, I am printing from rank %d\n",rank);
  
          double a, b, c;
          MPI_Status status, status2;
  
          if (rank == 0)
          {
                  a = 10.1;
                  MPI_Send(&amp;a,1,MPI_DOUBLE,1,99,MPI_COMM_WORLD);
          }
          if (rank == 1)
          {
                  b = 20.1;
                  MPI_Recv(&amp;a,1,MPI_DOUBLE,0,99,MPI_COMM_WORLD,&amp;status);
                  c = a + b;
                  printf("\nThe value of c is %f \n",c);
          }
          MPI_Sendrecv(&amp;c,1,MPI_DOUBLE,2,100,
                       &amp;c,1,MPI_DOUBLE,1,100,MPI_COMM_WORLD,&amp;status2);
  
          MPI_Barrier(MPI_COMM_WORLD);
          if(rank == 2)
          {
                 printf("\n Printing from rank %d, c is %f\n",rank, c);
          }
  
  
          MPI_Finalize();
          return 0;
  </code></pre>