title: MPI_Gather does not seem to work
body: <p>I needed to use the MPI_Gather function in my Matrix Multiplication program but am facing trouble with it for the last couple of days.</p>
  
  <p>Hence I wrote a simple MPI program using the gather function alone and have been trying to get it to run... For this I referred to the book 'Introduction to Parallel Programming by Peter Pacheco'.   </p>
  
  <p>The program directly exits, giving me absolutely no results or errors... I have not been able to figure out the mistake till now.</p>
  
  <pre><code>   /******************NOTE**********************
  
        The program simply uses the MPI_Gather() function. 
        The program is exiting directly.
        I have written it for only TWO processes.
        (-np 2)
  
     ******************************************/
  
      #include&lt;stdio.h&gt;
      #include"mpi.h"
  
      int main()
      {
       int i,j,proc,rank;
       double d[4];
       double local_a[2];
  
  
       MPI_Init(NULL,NULL);
       MPI_Comm_size(MPI_COMM_WORLD, &amp;proc);
       MPI_Comm_rank(MPI_COMM_WORLD, &amp;rank);
  
       if(rank==0)
       { 
  
         local_a[0]=1.0;
         local_a[1]=2.0;
       }
  
       else
       {
         local_a[0]=3.0;
         local_a[1]=4.0;
       }
  
       int local=2;
  
       if(rank==0)
       {   
  
         MPI_Gather(local_a,local,MPI_DOUBLE,d,local,MPI_DOUBLE,0,MPI_COMM_WORLD);
       //MPI_Gather(&amp;local_a,local,MPI_DOUBLE,&amp;d,local,MPI_DOUBLE,0,MPI_COMM_WORLD);
       //also tried the above line just to be certain.
  
  
         printf("\n");
         for(j=0;j&lt;4;j++)
           printf("\t%f",d[j]);
       }
       else
       {
         MPI_Gather(local_a,local,MPI_DOUBLE,d,local,MPI_DOUBLE,0,MPI_COMM_WORLD);
       //MPI_Gather(&amp;local_a,local,MPI_DOUBLE,&amp;d,local,MPI_DOUBLE,0,MPI_COMM_WORLD); 
       }
  
       MPI_Finalize();
  
       return 0;
  
      }
  </code></pre>
  
  <p>Can anyone please help me out.</p>
  
  <p>Thank You.</p>
  
  <p>Anagha Madhusudanan</p>