title: MPI_Iprobe not setting flag correctly
body: <p>I've recently been having trouble with using MPI_Iprobe. I have attached some code below to try and demonstrate the issue (note: the code I'm using is different, the code is purely to create a minimal reproducible example of my issue).</p>
  <p>What I want to do is make the process with the rank of 0 send a request message to the process with rank 1. Rank 0 can send this message at an arbitrary point in the loop (hence why I have used an if-statement - <code>if(i == 1)</code>). It is possible that rank 0 never sends this message, that's why I'm using Iprobe in <code>handleReplies()</code>. Once rank 1 is is done with the loop (which is almost immediate as it has no work to do within the loop), I want it to call <code>handleReplies()</code> after five seconds. This is to ensure that the process 0 has used <code>send()</code> by the time handleReplies() is called.</p>
  <p>The issue is, that when <code>handleReplies()</code> is called, it should use MPI_Iprobe to set the <code>flag</code> variable to true (ie: 1) as the rank 0 process has sent a message of TAG_REQ. However, for some reason the flag is never set to <code>1</code>, and remains <code>0</code>. As a result, my MPI_Recv in my rank 0 remains blocked.</p>
  <pre><code>int main(int argc, char *argv[]) {
      int rank, size;
      
      // Call MPI_init, MPI_Comm_rank, MPI_Comm_size...
     
      int i = 0;
      while(i &lt;= 3) {
          if(rank == 0) {
              int fav;
              int linked = 1; // the rank send/recv messages from
              
              if(i == 1) { // at some point in the loop, send a request to the linked process
                  printf(&quot;Sending msg request to %d\n&quot;, linked);
                  MPI_Send(&amp;rank, 0, MPI_INT, linked, TAG_REQ, MPI_COMM_WORLD);
             
                  printf(&quot;waiting for receieve\n&quot;);
                  MPI_Recv(&amp;fav, 1, MPI_INT, linked, TAG_REP, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
                  printf(&quot;%d's favourite number is %d\n&quot;, linked, fav);
              }
          }
          i++;
      }
        
      sleep(5); // sleep 5 secs to ensure that the other node is waiting for a reply            
      handleReplies(MPI_COMM_WORLD, 1); // before we quit, handle any replies which may be waiting still
      printf(&quot;[%d] Finished...\n&quot;, rank); 
      MPI_Finalize();
      return 0;
  };
  
  void handleReplies(MPI_Comm comm, int debug) {
      int linked = 0;
      int flag = 0; // gets set to 1 if message received
      MPI_Iprobe(linked, TAG_REQ, comm, &amp;flag, MPI_STATUS_IGNORE);
      printf(&quot;Is there a requesting message: %s\n&quot;, flag ? &quot;yes&quot; : &quot;no&quot;);
      if(flag) {
          int recvVal;
          int fav = 11;
          MPI_Recv(&amp;recvVal, 0, MPI_INT, linked, TAG_REQ, comm, MPI_STATUS_IGNORE);
          MPI_Send(&amp;fav, 1, MPI_INT, linked, TAG_REP, comm);
      }
  }
  </code></pre>
  <p>Below is the output of my code when I run it with 2 processes:</p>
  <pre><code>Sending msg request to 1    // shows that message has been sent
  waiting for receive  // left hanging as no reply ever sent
  Is there a requesting message: no  // 5 seconds after above line (expected &quot;yes&quot; instead of &quot;no&quot;)
  [1] Finished...
  </code></pre>
  <p>after the <code>[1] Finished...</code> it continues to hang as <code>MPI_Send(&amp;fav, 1, MPI_INT, linked, TAG_REP, comm);</code> because <code>flag</code> never gets set to true.</p>
  <p>Why is MPI_Iprobe not picking up that rank 0 sent a message five seconds ago?</p>
  <p>I have also looked at <a href="https://stackoverflow.com/questions/20999299/why-does-mpi-iprobe-return-false-when-message-has-definitely-been-sent">this answer</a> but the issue there seems to be that they're using MPI_Isend instead of MPI_Send.</p>