title: MPI_Scatter allocation for float - MPI,C
body: <p>I'm starting out in MPI. For the homework i'm doing i need produce sum of an input we specify by allocating jobs to different process. My program works fine when I get integer results. e.g 20/20 = 1 or 20/10 = 2. however when I get decimal points 20/9 =2.222, I get into trouble and get wrong results. I'm not quite sure how to get around this. Here is my code for Scattering and producing sum. </p>
  
  <blockquote>
    <p>where  readNumber = value read in (e.g 20) storage = array with values
    (1,2,3,4....20)</p>
  </blockquote>
  
  <pre><code>/*Scatter*/ 
      MPI_Scatter(storage, readNumber/size, MPI_INT, 
  
                           recStorage, readNumber/size, MPI_INT, 0, MPI_COMM_WORLD);
  
      total=0;
      printf("%d \n",readNumber/size);
      for(i=0;i&lt;readNumber/size;i++){
          total=total+recStorage[i];
      }
      printf("rank= %d total= %d \n ",rank,total);
  
  
      /*Reduce*/
  
      MPI_Reduce( &amp;total, &amp;gtotal, send_count, MPI_INT, MPI_SUM, 0,   MPI_COMM_WORLD);
  
  
      if(rank == 0){
        printf("total = %d \n ",gtotal);
      }
  </code></pre>