title: Message Truncated in MPI_Recv
body: <p>I have the adjacency matrix and the following code:</p>
  
  <pre><code>if (is_broadcast_message) {
      MPI_Send(&amp;broadcast_message,1,MPI_INT,j,3,MPI_COMM_WORLD);
      MPI_Send(&amp;message,20,MPI_CHAR,j,3,MPI_COMM_WORLD);
  }
  </code></pre>
  
  <p>Where <code>broadcast_message=128</code>(random number just to know when I'm receiving, that this was a broadcast message )</p>
  
  <p>Message is defined as char[20]. </p>
  
  <pre><code>else if (i have to send only to a node) {
      MPI_Send(&amp;destination,1,MPI_INT,next_hop[destination],3,MPI_COMM_WORLD);
      MPI_Send(&amp;message,20, MPI_CHAR, next_hop[destination],3,MPI_COMM_WORLD);
  }
  </code></pre>
  
  <p>When I'm receiving I first check if <code>recv_payload</code> is <code>128</code> (broadcast value) or other value:</p>
  
  <pre><code>MPI_Recv(&amp;recv_material,1,MPI_INT,MPI_ANY_SOURCE,3,MPI_COMM_WORLD,&amp;status2);
  </code></pre>
  
  <p>If is it 128, then:</p>
  
  <pre><code>MPI_Recv(&amp;message,20,MPI_CHAR,from_d,3,MPI_COMM_WORLD,&amp;status2);
  </code></pre>
  
  <p>and I'm forwarding the message to all the processes</p>
  
  <pre><code>MPI_Send(&amp;message,20,MPI_CHAR,j,3,MPI_COMM_WORLD);
  </code></pre>
  
  <p>If it's not 128, I'm checking if i am the destination :</p>
  
  <pre><code>if(recv_material == rank)
      MPI_Recv(&amp;mesaj,20,MPI_CHAR,from_d,3,MPI_COMM_WORLD,&amp;status2);
  </code></pre>
  
  <p>Else, I'm sending on nexthop[recv_material]</p>
  
  <pre><code>MPI_Send(&amp;mesaj,20,MPI_CHAR,next_hop[recv_material],3,MPI_COMM_WORLD);
  </code></pre>
  
  <p>The problem is that i get the following error and I don't know why : </p>
  
  <pre><code>Fatal error in MPI_Recv: Message truncated, error stack:
  MPI_Recv(186).....................: MPI_Recv(buf=0x7fffbce8f2a4, count=1, MPI_INT
  src=MPI_ANY_SOURCE, tag=3, MPI_COMM_WORLD, status=0x7fffbce8f250) failed
  MPIDI_CH3U_Receive_data_found(129): Message from rank 7 and tag 3 truncated;
  20 bytes   received but buffer size is 4
  </code></pre>