On 6 May 2011 16:27, Tim Prince <tcpri...@live.com> wrote:
> If you want to use the MPI Fortran library, don't convert your Fortran to C.
>  It's difficult to understand why you would consider f2c a "simplest way,"
> but at least it should allow you to use ordinary C MPI function calls.

Sorry, maybe I wasn't clear. Just to clarify, all of *my* code is
written in C++ (because I don't actually know Fortran), but I want to
use some function from PARPACK which is written in Fortran. I think I
originally used f2c because it was a massive pain linking to a Fortran
library. I suppose I could give it another go, but I don't think it
affects the problem of mixing APIs (since the f2c version still uses
the Fortran API).

> The MPI Fortran library must be built against the same Fortran run-time
> libraries which you use for your own Fortran code.  The header files for the
> Fortran MPI calls probably don't work in C.  It would be a big struggle to
> get them to work with f2c, since f2c doesn't have much ability to deal with
> headers other than its own.

Yeah I've had to manually recreate C versions of the Fortran headers
(mpif.h), which is a pain and the main reason I want to try a
different method.

> There's no reason you can't make both C and Fortran MPI calls in the same
> application.  If you mean mixing a send from one language with a receive in
> another, I think most would avoid that.

I'm fairly sure that there wouldn't ever be a send in one language and
a receive in another, but I would be doing independent sends/receives
with different languages (one after another), something like this:

MPI_Init(argc, argv); // C.
call mpi_send(..., MPI_DOUBLE_PRECISION, ...); // Fortan.
// ...
MPI_AllGatherV(..., MPI_DOUBLE, ...); // C, but completely separate
from previous communications.
MPI_Finalize(); // C.

> Whether someone uses OpenMP has little to do with choice of MPI
> implementation.  Some of us still may be cursing the choice of OpenMPI for
> the name of an MPI implementation.

Oops, that was a typo - I meant OpenMPI! I'm not actually using OpenMP at all.

Thanks for the help!

Tim

Reply via email to