title: Problems debugging MPI program on a cluster
body: <p>I have an MPI program that runs on a cluster of machines. However, the program does not run to completion and I am unable to identify the reason. The main function consists of two main clauses (an if clause and an else clause):</p>
  
  <pre><code>#define SERVER 0
  
  if(my_rank == SERVER)
  {
     //do something
  }
  else
  {
     //do something else
  }
  </code></pre>
  
  <p>The problem seems to be in the "do something else" part and I would like to debug it with gdb. When I run the executable with gdb, I'm only able to step into the if clause because it seems MPI automatically assigns a rank of 0 to the main process (the one that launches the program). I looked into environment variables but I haven't found a flag that to pre-determine the rank of the main process. How can I debug the else clause?</p>