title: MPI_Sendrecv_replace() dead-lock issue
body: <p>I'm doing my homework whith following assignment: </p>
  
  <blockquote>
    <p>Every process takes a double as an input. Using function
    <code>MPI_Sendrecv_replace()</code> swap all doubles with processes of opposite
    rank (first &amp; last, second &amp; last but one, ...). In every process output recieved number.</p>
  </blockquote>
  
  <p>So here is the code that I wrote.</p>
  
  <pre><code>#include "mpi.h"
  #include &lt;stdio.h&gt;
  #include "pt4.h"
  
  int main(int argc, char *argv[])
  {
      MPI_Init(&amp;argc,&amp;argv);
      int flag;
      MPI_Initialized(&amp;flag);
      if (flag == 0)
          return;
      int rank, size;
      MPI_Comm_size(MPI_COMM_WORLD, &amp;size);
      MPI_Comm_rank(MPI_COMM_WORLD, &amp;rank);
  
      double n;
      pt &gt;&gt; n; // pt is a stream provided by side library (works perfectly fine)
  
      int oppositeRank = (size - 1) - rank;
  
      if (rank != oppositeRank)
      {
          MPI_Status status;
          MPI_Sendrecv_replace(&amp;n, 1, MPI_DOUBLE, oppositeRank, 0, 
                               rank, 0, MPI_COMM_WORLD, &amp;status);
      }
  
      pt &lt;&lt; n;
      MPI_Finalize();
      return 0;
  }
  </code></pre>
  
  <p>Although this code compiles without any problems, it never stops. So the question is why? What am I doing wrong? </p>