title: OpenMPI MPI_Barrier problems
body: <p>I having some synchronization issues using the OpenMPI implementation of MPI_Barrier:</p>
  
  <pre><code>int rank;
  int nprocs;
  
  int rc = MPI_Init(&amp;argc, &amp;argv);
  
  if(rc != MPI_SUCCESS) {
      fprintf(stderr, "Unable to set up MPI");
      MPI_Abort(MPI_COMM_WORLD, rc);
  }
  
  MPI_Comm_size(MPI_COMM_WORLD, &amp;nprocs);
  MPI_Comm_rank(MPI_COMM_WORLD, &amp;rank);
  
  
  printf("P%d\n", rank);
  fflush(stdout);
  
  MPI_Barrier(MPI_COMM_WORLD);
  
  printf("P%d again\n", rank);
  
  MPI_Finalize();
  </code></pre>
  
  <p>for mpirun -n 2 ./a.out</p>
  
  <p>output should be:
  P0
  P1
  ... </p>
  
  <p>output is <em>sometimes</em>: 
  P0
  P0 again
  P1
  P1 again</p>
  
  <p>what's going on? </p>