title: From MPI_Scatter to MPI_Scatterv
body: <p>This is a part of the code:</p>
  
  <pre><code>#include&lt;mpi.h&gt;
  #include&lt;stdio.h&gt;
  int main(int argc, char *argv[])
  {
  int numtask;
  double *Matr_Init,*Matr_Fin;
  int i, myrank, root=0;
  MPI_Init(&amp;argc,&amp;argv);
  MPI_Comm_rank(MPI_COMM_WORLD, &amp;myrank);
  MPI_Comm_size(MPI_COMM_WORLD, &amp;numtask);
  double Rows[numtask];
  
  int sendcount[numtask],reccount[numtask],source,displs[numtask];
  //Procesul cu rankul root aloca spatiul si initializeaza matrice initiala
  if(myrank==root)
  {
      for (i = 0; i&lt;numtask; i++){
          sendcount[i]=(i+2)*numtask;
          reccount[i]=sendcount[i];
          //if(i==0)
          displs[i]=numtask;
          //else
          //displs[i]=sendcount[i]+displs[i-1];
      }
      Matr_Init=(double*)malloc(numtask*numtask*sizeof(double));
      Matr_Fin=(double*)malloc(numtask*numtask*sizeof(double));
      for(int i=0;i&lt;numtask*numtask;i++)
        Matr_Init[i]=rand()/1000000000.0;
      printf("Tipar datele initiale\n");
      for(int i=0;i&lt;numtask;i++)
      {
          printf("\n");
          for(int j=0;j&lt;numtask;j++)
             printf("Matr_Init[%d,%d]=%5.2f ",i,j,Matr_Init[i*numtask+j]);
      }
      printf("\n");
      MPI_Barrier(MPI_COMM_WORLD);
  }
  else MPI_Barrier(MPI_COMM_WORLD);
  
  MPI_Scatterv(Matr_Init, sendcount, displs, MPI_DOUBLE, Rows, numtask, MPI_DOUBLE, root, MPI_COMM_WORLD);
  
  printf("\n");
  printf("Resultatele f-tiei MPI_Scatter pentru procesul cu rankul %d \n", myrank);
  for (i=0; i&lt;sendcount[myrank]; ++i) 
      printf("Rows[%d]=%5.2f ",i, Rows[i]);
  printf("\n");       
  MPI_Barrier(MPI_COMM_WORLD);    
  MPI_Finalize();
  return 0;
  }
  </code></pre>
  
  <p>Output is:
      Tipar datele initiale</p>
  
  <pre><code>Matr_Init[0,0]= 1.80 Matr_Init[0,1]= 0.85 Matr_Init[0,2]= 1.68 Matr_Init[0,3]= 1.71 
  Matr_Init[1,0]= 1.96 Matr_Init[1,1]= 0.42 Matr_Init[1,2]= 0.72 Matr_Init[1,3]= 1.65 
  Matr_Init[2,0]= 0.60 Matr_Init[2,1]= 1.19 Matr_Init[2,2]= 1.03 Matr_Init[2,3]= 1.35 
  Matr_Init[3,0]= 0.78 Matr_Init[3,1]= 1.10 Matr_Init[3,2]= 2.04 Matr_Init[3,3]= 1.97 
  
  Resultatele f-tiei MPI_Scatter pentru procesul cu rankul 0 
  Rows[0]= 1.96 Rows[1]= 0.42 Rows[2]= 0.72 Rows[3]= 1.65 Rows[4]= 0.00 Rows[5]= 0.00 Rows[6]= 0.00 Rows[7]= 0.00 
  [compute-0-1.local:18772] *** An error occurred in MPI_Scatterv
  [compute-0-1.local:18772] *** on communicator MPI_COMM_WORLD
  [compute-0-1.local:18772] *** MPI_ERR_TRUNCATE: message truncated
  [compute-0-1.local:18772] *** MPI_ERRORS_ARE_FATAL (your MPI job will now abort)
  --------------------------------------------------------------------------
  mpirun has exited due to process rank 3 with PID 18774 on
  node compute-0-1 exiting without calling "finalize". This may
  have caused other processes in the application to be
  terminated by signals sent by mpirun (as reported here).
  --------------------------------------------------------------------------
  [hpc.usm.md:09043] 2 more processes have sent help message help-mpi-errors.txt /     mpi_errors_are_fatal
  [hpc.usm.md:09043] Set MCA parameter "orte_base_help_aggregate" to 0 to see all help / error messages
  </code></pre>
  
  <p>Question is: I dont realy understand the input options of MPI_Scatterv function. Please help me understnd.
  Thank you.</p>