title: MPI Gather different Size
body: <p>I have a cluster of 10 computers and 2 variables in c++
   - result : size int 100;
   - result_final : (only on host) size int 1000;
  how can I gather the pieces of 'result' and create 'result_final' as their size differs.
  Thank you!</p>
  
  <pre><code>int *rcounts = (int *) malloc(commSize * sizeof(int));
  int *displs = (int *) malloc(commSize * sizeof(int));
  for (i = 0; i &lt; commSize; ++i) {
      displs[i] = commRank * result_size * size;
      rcounts[i] = result_size * size;
  }
  MPI_Gatherv(h_result, result_size * size, MPI_INT, h_result_final, rcounts,
          displs, MPI_INT, 0, MPI_COMM_WORLD);
  </code></pre>