title: Parallelizing a function in openMpi?
body: <p>I have an algorithm parallelized in main() using C with openMPI; it works perfect but now I want to move the code over to an external function.</p>
  
  <pre><code>void my_parallel_function(int v[], int size, int rank)
  {
     if(rank==0)
     {
       MPI_Send(&amp;v[0], 5, MPI_INT, 1, 1, MPI_COMM_WORLD);
     }
     else
     {
       MPI_Recv(&amp;v[0], 5, MPI_INT, MPI_ANY_SOURCE, 1, MPI_COMM_WORLD,&amp;status);
       printf("value of item 1: %d", v[0]);
     }
  }
  
  int main(int argc, char *argv[])
  {        
      int rank, size;
  
      MPI_Init(&amp;argc, &amp;argv);
      MPI_Comm_size(MPI_COMM_WORLD, &amp;size);
      MPI_Comm_rank(MPI_COMM_WORLD, &amp;rank);
      MPI_Status status;
  
      int vect[100];
  
      if (rank==0)
      {
        my_parallel_function(vect, size, rank);
      }
  
      MPI_Finalize();
      return 0;
  }
  </code></pre>
  
  <p>The above code is only intended to illustrate what I would like to do.  I can run my code from the console but then there is no response, it just hangs.</p>
  
  <p>Any ideas? Thanks a lot!</p>