title: MPI_ERR_TRUNCATE: On Broadcast
body: <p>I have an <code>int</code> I intend to broadcast from root (<code>rank==(FIELD=0)</code>). </p>
  
  <pre><code>int winner
  
  if (rank == FIELD) {
      winner = something;
  }
  
  MPI_Barrier(MPI_COMM_WORLD);
  MPI_Bcast(&amp;winner, 1, MPI_INT, FIELD, MPI_COMM_WORLD);
  MPI_Barrier(MPI_COMM_WORLD);
  if (rank != FIELD) {
      cout &lt;&lt; rank &lt;&lt; " informed that winner is " &lt;&lt; winner &lt;&lt; endl;
  }
  </code></pre>
  
  <p>But it appears I get </p>
  
  <pre><code>[JM:6892] *** An error occurred in MPI_Bcast
  [JM:6892] *** on communicator MPI_COMM_WORLD
  [JM:6892] *** MPI_ERR_TRUNCATE: message truncated
  [JM:6892] *** MPI_ERRORS_ARE_FATAL: your MPI job will now abort
  </code></pre>
  
  <p>Found that I can increase the buffer size in <code>Bcast</code></p>
  
  <pre><code>MPI_Bcast(&amp;winner, NUMPROCS, MPI_INT, FIELD, MPI_COMM_WORLD);
  </code></pre>
  
  <p>Where <code>NUMPROCS</code> is number of running processes. (actually seems like I just need it to be 2). Then it runs, but gives unexpected output ... </p>
  
  <pre><code>1 informed that winner is 103
  2 informed that winner is 103
  3 informed that winner is 103
  5 informed that winner is 103
  4 informed that winner is 103
  </code></pre>
  
  <p>When I <code>cout</code> the <code>winner</code>, it should be <code>-1</code></p>