title: MUMPS - The MPI_Comm_f2c() function was called before MPI_INIT was invoked
body: <p>I need to use MUMPS in my project. I wanted to test the installation with the simple example of solving equations (below). The problem is, that this code works correctly in my personal PC, but it gives me this error every time I try to run it in my work computer:</p>
  
  <pre><code>*** The MPI_Comm_f2c() function was called before MPI_INIT was invoked.
  *** This is disallowed by the MPI standard.
  *** Your MPI job will now abort.
  [espreso-ws:3263] Local abort before MPI_INIT completed successfully; not able to aggregate error messages, and not able to guarantee that all other processes were killed!
  </code></pre>
  
  <p>I've tried to look for possible solutions, but I've found only these questions:</p>
  
  <p><a href="https://stackoverflow.com/questions/10772300/error-the-mpi-send-function-was-called-before-mpi-init-was-invoked">error: The MPI_Send() function was called before MPI_INIT was invoked</a></p>
  
  <p><a href="http://www.open-mpi.org/community/lists/users/2012/05/19262.php" rel="nofollow noreferrer">http://www.open-mpi.org/community/lists/users/2012/05/19262.php</a></p>
  
  <p>None of them provides any solution.</p>
  
  <p>So now, I'm incredibly confused about this and I don't really know, what should I try to do. There IS <code>MPI_Init()</code> invoked before <code>MPI_Comm_f2c()</code> of course.</p>
  
  <p>Do you know, how to solve this problem?</p>
  
  <hr>
  
  <h3>mumps_solve.c</h3>
  
  <pre><code>/*
   *  file c_example.c
   *  This file is part of MUMPS 4.10.0
   *  To run: aprun -n 2 ./dsimpletest &lt; input_simpletest_real
   */
  /* Example program using the C interface to the
   * double real arithmetic version of MUMPS, dmumps_c.
   * We solve the system A x = RHS
   */
  #include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  #include &lt;mpi.h&gt;
  #include &lt;dmumps_c.h&gt;
  #define JOB_INIT -1
  #define JOB_END -2
  #define USE_COMM_WORLD -987654
  
  int main(int argc, char ** argv)
  {
    DMUMPS_STRUC_C id;
    int n = 2;
    int nz = 4;
    int irn[] = {1,1,2,2};
    int jcn[] = {1,2,1,2};
    double a[4];
    double rhs[2];
  
    int myid, ierr;
    ierr = MPI_Init(&amp;argc, &amp;argv);
    ierr = MPI_Comm_rank(MPI_COMM_WORLD, &amp;myid);
  
    /* Define A and rhs */
    rhs[0]=5.0;rhs[1]=2.0;
    a[0]=3.0;a[1]=2.0;a[2]=1.0;a[3]=4.0;
  
    /* Initialize a MUMPS instance. Use MPI_COMM_WORLD */
    id.job=JOB_INIT;id.par=1; id.sym=0;id.comm_fortran=USE_COMM_WORLD;
  
    dmumps_c(&amp;id); // here the program crashes
  
    /* Define the problem on the host */
    if (myid == 0) {
      id.n = n; id.nz =nz; id.irn=irn; id.jcn=jcn;
      id.a = a; id.rhs = rhs;
    }
  #define ICNTL(I) icntl[(I)-1] /* macro s.t. indices match documentation */
  /* No outputs */
    id.ICNTL(1)=-1; id.ICNTL(2)=-1; id.ICNTL(3)=-1; id.ICNTL(4)=0;
  /* Call the MUMPS package. */
    id.job=6;
    dmumps_c(&amp;id);
    id.job=JOB_END; dmumps_c(&amp;id); /* Terminate instance */
    if (myid == 0) {
      printf("Solution is : (%8.2f  %8.2f)\n", rhs[0],rhs[1]);
    }
    ierr = MPI_Finalize();
    return 0;
  }
  </code></pre>
  
  <hr>
  
  <h3>Makefile</h3>
  
  <pre><code>.DEFAULT_GOAL=all
  
  BINARIES=mumps_solve
  
  .PHONY=all
  all: mumps_solve
  
  mumps_solve: mumps_solve.o
          mpicc mumps_solve.o -o mumps_solve -ldmumps
  
  mumps_solve.o: mumps_solve.c
          mpicc -c mumps_solve.c -o mumps_solve.o
  
  .PHONY=clean
  clean:
          rm -f ${BINARIES} *.o
  </code></pre>