title: MPI: Program hanged at scanf
body: <p>I have written a simple MPI program. I am not doing any processing in the program. It just has the MPI skeleton and lines to read a variable. However, the program gets hanged while running. It prints a few newlines and then hangs forever. </p>
  
  <pre><code>int main(int argc, char* argv[]) {
      int my_rank; /* rank of process */
      int p; /* number of processes */
      int tag = 0; /* tag for messages */
      long N;
      MPI_Status status; /* return status for receive */
  
      /* start up MPI */
      MPI_Init(&amp;argc, &amp;argv);
  
      /* find out process rank */
      MPI_Comm_rank(MPI_COMM_WORLD, &amp;my_rank);
  
      /* find out number of processes */
      MPI_Comm_size(MPI_COMM_WORLD, &amp;p);
  
  
      printf("\nEnter the number of random points to generate: ");
      scanf("%ld", &amp;N);
  
      if (my_rank == 0) {
  
      }
  
      /* shut down MPI */
      MPI_Finalize();
  
      return 0;
  }
  </code></pre>