title: mpirun was unable to find the specified executable file
body: <p>I have problems compiling this code using OpenMPI.Since I am a bit new to the concepts of using OpenMPI, it would be great if someone of you could give me a hint to the mistake here.
  Compiling works just fine, but if I run the code I get this message:</p>
  
  <pre><code>mpirun was unable to find the specified executable file, and therefore
  did not launch the job.  This error was first reported for process
  rank 0; it may have occurred for other processes as well.
  
  NOTE: A common cause for this error is misspelling a mpirun command
        line parameter option (remember that mpirun interprets the first
        unrecognized command line token as the executable).  
  </code></pre>
  
  <p>I am compiling using: </p>
  
  <pre><code>mpic++ matmult.cpp -o matmult
  </code></pre>
  
  <p>and running it with: </p>
  
  <pre><code>mpirun -n 2 matmult
  </code></pre>
  
  <p>... and here is the used code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;mpi.h&gt;
  #define MASTER 0
  #define FROM_MASTER 1
  #define FROM_WORKER 2
  
  // ---------------------------------------------------------------------------
  // allocate space for empty matrix A[row][col]
  // access to matrix elements possible with:
  // - A[row][col]
  // - A[0][row*col]
  
  float **alloc_mat(int row, int col)
  {
      float **A1, *A2;
  
      A1 = (float **)calloc(row, sizeof(float *));        // pointer on rows
      A2 = (float *)calloc(row*col, sizeof(float));    // all matrix elements
      for (int i = 0; i &lt; row; i++)
          A1[i] = A2 + i*col;
  
      return A1;
  }
  
  // ---------------------------------------------------------------------------
  // random initialisation of matrix with values [0..9]
  
     void init_mat(float **A, int row, int col)
     {
         for (int i = 0; i &lt; row*col; i++)
              A[0][i] = (float)(rand() % 10);
     }
  
      // ---------------------------------------------------------------------------
      // DEBUG FUNCTION: printout of all matrix elements
  
     void print_mat(float **A, int row, int col, char *tag)
     {
      int i, j;
  
      printf("Matrix %s:\n", tag);
      for (i = 0; i &lt; row; i++)
      {
          for (j = 0; j &lt; col; j++) 
              printf("%6.1f   ", A[i][j]);
          printf("\n"); 
      }
  }
  
  // ---------------------------------------------------------------------------
  
  int main(int argc, char *argv[]) {   
      int numtasks;
      int taskid;
      int numworkers;
      int source;
      int dest;
      int mtype;
      int rows;
      int averow, extra, offset;
      double starttime, endtime;
      float **A, **B, **C;    // matrices
      int d1, d2, d3;         // dimensions of matrices
      int i, j, k, rc;            // loop variables
  
  
      MPI_Status status;
      MPI_Init(&amp;argc,&amp;argv);
      MPI_Comm_rank(MPI_COMM_WORLD,&amp;taskid);
      MPI_Comm_size(MPI_COMM_WORLD,&amp;numtasks);
  
      if (argc != 4) {
          printf ("Matrix multiplication: C = A x B\n");
          printf ("Usage: %s &lt;NumRowA&gt; &lt;NumColA&gt; &lt;NumColB&gt;\n", argv[0]); 
          return 0;
      }
  
      if (numtasks &lt; 2 ) {
      printf("Need at least two MPI tasks. Quitting...\n");
      MPI_Abort(MPI_COMM_WORLD,rc);
      exit(1);
      }
  
       /* read user input */
      d1 = atoi(argv[1]);     // rows of A and C  d1
      d2 = atoi(argv[2]);     // cols of A and rows of B  d2
      d3 = atoi(argv[3]);     // cols of B and C d3
  
      printf("Matrix sizes C[%d][%d] = A[%d][%d] x B[%d][%d]\n", d1, d3, d1, d2, d2, d3);
  
      /* prepare matrices */
      A = alloc_mat(d1, d2);
      init_mat(A, d1, d2); 
      B = alloc_mat(d2, d3);
      init_mat(B, d2, d3);
      C = alloc_mat(d1, d3);
  
  
       /* Code für den Manager */
      if (taskid == MASTER) {
          /*printf("matrix multiplikation withMPI\n");
          printf("initializing arrays ...\n");
              for (i=0; i&lt;d1; i++) 
                  for (j=0; j&lt;d2; j++) 
                  A[i][j]=i+j;
  
  
              for (i=0; i&lt;d2; i++) 
                  for (j=0; j&lt;d3; j++) 
                  B[i][j]=i*j;*/
  
  
  
               /* Matrizen versenden */
              averow = d1/numworkers;
              extra = d1%numworkers;
              offset = 0;
              mtype = FROM_MASTER;
  
              starttime=MPI_Wtime();
  
              for (dest=1;dest&lt;=numworkers;dest++) {
                  rows = (dest &lt;= extra) ? averow+1 :averow;
                  printf("Sending %drows to task %doffset=%d\n",rows,dest,offset);
                  MPI_Send(&amp;offset, 1, MPI_INT,dest,mtype, MPI_COMM_WORLD);
                  MPI_Send(&amp;rows, 1, MPI_INT,dest,mtype, MPI_COMM_WORLD);
                  MPI_Send(&amp;A[offset][0],rows*d2, MPI_DOUBLE,dest,mtype, MPI_COMM_WORLD);
                  MPI_Send(&amp;B, d2*d3, MPI_DOUBLE,dest,mtype, MPI_COMM_WORLD);
                  offset =offset+rows;
              }
  
               /* Ergebnisse empfangen */
               mtype = FROM_WORKER;
  
              for (i=1; i&lt;=numworkers; i++) {
                  source = i;
                  MPI_Recv(&amp;offset, 1, MPI_INT,source,mtype, MPI_COMM_WORLD, &amp;status);
                  MPI_Recv(&amp;rows, 1, MPI_INT,source,mtype, MPI_COMM_WORLD, &amp;status);
                  MPI_Recv(&amp;C[offset][0],rows*d3, 
                  MPI_DOUBLE,source,mtype,MPI_COMM_WORLD,&amp;status);
                  printf("Received results from task %d\n",source);
              }
  
              endtime=MPI_Wtime();
              printf("\nIt took %fseconds.\n",endtime-starttime);
       }       
  
      /* Code für die Arbeiter */
  
      if (taskid &gt; MASTER) {
          mtype = FROM_MASTER;
  
          MPI_Recv(&amp;offset, 1, MPI_INT, MASTER,mtype, MPI_COMM_WORLD, &amp;status);
          MPI_Recv(&amp;d1, 1, MPI_INT, MASTER,mtype, MPI_COMM_WORLD, &amp;status);
          MPI_Recv(&amp;A,rows*d2, MPI_DOUBLE, MASTER,mtype, MPI_COMM_WORLD, &amp;status);
          MPI_Recv(&amp;B, d2*d3, MPI_DOUBLE, MASTER,mtype, MPI_COMM_WORLD, &amp;status);
  
      /* print user instruction */
  
  
      // no initialisation of C, because it gets filled by matmult
  
      /* serial version of matmult */
          printf("Perform matrix multiplication...\n");
          for (i = 0; i &lt; d1; i++)
              for (j = 0; j &lt; d3; j++)
                  for (k = 0; k &lt; d2; k++)
                  C[i][j] += A[i][k] * B[k][j];
  
          mtype = FROM_WORKER;
          MPI_Send(&amp;offset, 1, MPI_INT, MASTER,mtype, MPI_COMM_WORLD);
          MPI_Send(&amp;d1, 1, MPI_INT, MASTER,mtype, MPI_COMM_WORLD);
          MPI_Send(&amp;C,rows*d3, MPI_DOUBLE, MASTER,mtype, MPI_COMM_WORLD);
  
      }
  
      MPI_Finalize();
  
  
      /* test output 
      print_mat(A, d1, d2, "A"); 
      print_mat(B, d2, d3, "B"); 
      print_mat(C, d1, d3, "C"); */
  
      printf ("\nDone.\n");
  
  
      //return 0;
  }
  </code></pre>
  
  <p><br>
  <strong>Results of running</strong> <code>mpirun matmult</code> <em>(default settings, single process)</em>:</p>
  
  <blockquote>
    <p>mpirun has exited due to process rank 0 with PID 77202 on node
    juliuss-mbp-3 exiting improperly. There are three reasons this could
    occur:  </p>
    
    <ol>
    <li><p>this process did not call "init" before exiting, but others in the
    job did. This can cause a job to hang indefinitely while it waits
    for all processes to call "init". By rule, if one process calls
    "init", then ALL processes must call "init" prior to termination.</p></li>
    <li><p>this process called "init", but exited without calling "finalize". By rule, all processes that call "init" MUST call
    "finalize" prior to exiting or it will be considered an "abnormal
    termination"</p></li>
    <li><p>this process called "MPI_Abort" or "orte_abort" and the mca parameter orte_create_session_dirs is set to false. In this case,
    the run-time cannot detect that the abort call was an abnormal
    termination. Hence, the only error message you will receive is this
    one. This may have caused other processes in the application to be
    terminated by signals sent by mpirun (as reported here). You can
    avoid this message by specifying -quiet on the mpirun command line.</p></li>
    </ol>
  </blockquote>