title: C, MPI: Program won't display correct output
body: <p>I have an MPI program that can use 2, 3, 14, 61, .... X number of processes.<br>
  Out of these processes, processes that are ranked with an odd number send messages, whereas the process with rank 0 receives messages and displays them.<br>
  However, my program displays only 1 message when it is run with say 15 or 64 processes.<br>
  This is my code:  </p>
  
  <pre><code>#include "mpi.h"
  #include &lt;stdio.h&gt;
  
  int main( int argc, char * argv[] )
  {
      int rank, i =0;
      int sendMsg = 123;
      int recvMsg = 0;
      int flag = 0;
      int count;
      MPI_Status status;
      MPI_Request request;
      int errs = 0;
      double start = MPI_Wtime();
      MPI_Init( 0, 0 );
  
      MPI_Comm_rank(MPI_COMM_WORLD, &amp;rank);
      if(rank == 0)
      {
          while(!flag)
          {
              MPI_Iprobe( MPI_ANY_SOURCE, 0, MPI_COMM_WORLD, &amp;flag, &amp;status );
  
          }
  
          MPI_Recv( &amp;recvMsg, 1, MPI_INT, MPI_ANY_SOURCE, 0, MPI_COMM_WORLD, &amp;status );
  
          printf("Received message from process %d\n",status.MPI_SOURCE);
  
      }
      else{
          if(rank % 2 != 0){
              printf("Sent from process: %d\n",rank );
              MPI_Isend( &amp;sendMsg, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &amp;request );
              MPI_Wait( &amp;request, &amp;status );
          }
  
      }
  
      MPI_Finalize();
      return errs;
  }
  </code></pre>
  
  <p>This is my output:  </p>
  
  <pre><code>Sent from process: 1
  Sent from process: 5
  Sent from process: 3
  Sent from process: 7
  Received message from process 3
  </code></pre>
  
  <p>As you can see I expected the output to also say that It received messages from processes 1,5, and 7.<br>
  How can I achieve my goal? My program should also terminate. Thank you  </p>
  
  <p>How to run the code in the terminal:  </p>
  
  <pre><code>mpicc main.c -o main -Wall  
  mpirun -np X main
  </code></pre>
  
  <p>Where X is an integer greater than or equal to 2</p>