title: Problems with MPI_Comm_split and openmpi 1.4.3
body: <p>i have encountered a problem with MPI_Split_comm that seems to occur only if openmpi 1.4.3 is used. Example code:</p>
  
  <pre><code>#include &lt;mpi.h&gt;
  #include &lt;cassert&gt;
  #include &lt;vector&gt;
  
  const size_t n_test=1000000;
  
  class MyComm{
  private:
      MPI_Comm comm;
  
  public:
    int size,rank;
  
    MyComm(){
      comm=MPI_COMM_WORLD;
      MPI_Comm_rank(comm,&amp;rank);
      MPI_Comm_size(comm,&amp;size);
    }
  
    MyComm(const MyComm&amp;);
  
    MyComm(const MyComm&amp; c, int col){
      MPI_Comm_split(c.comm,col,c.rank,&amp;comm);
      MPI_Comm_size(comm,&amp;size);
      MPI_Comm_rank(comm,&amp;rank);
    }
  
    ~MyComm(){
      if(comm!=MPI_COMM_WORLD) MPI_Comm_free(&amp;comm);
    }
  };
  
  void split(){
    std::vector&lt;MyComm*&gt; communicators;
    communicators.push_back(new MyComm());
  
    while(communicators.back()-&gt;size &gt;1){
      int size=communicators.back()-&gt;size;
      int rank=communicators.back()-&gt;rank;
  
      int color= (rank &gt;= size/2) ? 1 : 0;
  
      communicators.push_back(new MyComm(*communicators.back(),color));
  
      if(color==0) assert( communicators.back()-&gt;size==(size-size%2)/2 );
      else assert( communicators.back()-&gt;size==(size+size%2)/2 );
    }
  
    for(size_t i=0;i&lt;communicators.size();++i) delete communicators[i];
  }
  
  int main(int argc, char** argv){
    MPI_Init(&amp;argc,&amp;argv);
  
    for(size_t count=0;count&lt;n_test;++count) split();
  
    MPI_Finalize();
    return 0;
  }
  </code></pre>
  
  <p>The problem is that the sizes of the new communicators are not always correct. The problem does only occur for certain numbers of processes, e.g. 7. Furthermore, it does not occur in every execution. I have compiled the code with g++ and icpc (on Ubuntu 12.04, openmpi 1.4.3) and the error occurs in both executables. The error does not occur if openmpi 1.6.5 or 1.8.3 is used. This might look like a bug in openmpi 1.4.3, but since the behaviour of mpi is unspecified in the case of wrong usage, it might also be a problem with the code. So, my questions are:</p>
  
  <p>1) Can anyone find a mistake in my code?</p>
  
  <p>2) Does anyone know about problems with MPI_Comm_split in openmpi 1.4.3 that have been solved in later versions?</p>
  
  <p>(btw: all MPI routines return MPI_SUCCESS)</p>