Thank you all for your answers.

I stayed with the C version, with the FORTRAN symbols added as it worked with the tests I was willing to start. Nevertheless, in order to keep a more proper/portable solution, is it possible to use the same tools as in ompi/mpi/fortran/mpif-h/init_f.c in order to generate the mangled symbols (i.e. using #pragma weak or OMPI_GENERATE_F77_BINDINGS ) ?

Thank you.

Clément FOYER


On 12/12/2016 04:21 PM, Jeff Squyres (jsquyres) wrote:
If your Fortran compiler is new enough (and it *probably* is...?), you can use 
the BIND(C) notation to ease C / Fortran interoperability issues.


On Dec 12, 2016, at 5:37 AM, Gilles Gouaillardet 
<gilles.gouaillar...@gmail.com> wrote:

Clement,

Ideally, your LD_PRELOAD'able library should be written in Fortran so you do 
not even run into this kind of issues (name mangling + parameter types)

If you really want to write it in C, you have to do it all manually

SUBROUTINE MPI_INIT(ierror)
INTEGER IERROR

can become

void mpi_init_(MPI_Fint * ierror)

Note mangling is compiler dependent.
For most compilers, this is the function name with all lower cases, followed by 
one or two underscores.

You will also have to convert all parameters
INTEGER comm
will be replaced (modulo the typos) with
MPI_Comm c_comm;
MPI_Fint *comm;
c_comm = MPI_Comm_f2c(*comm);

And so on, that is why Fortran wrapper is preferred,
plus there might be over caveats with Fortean 2008

Cheers,

Gilles

On Monday, December 12, 2016, Clement FOYER <clement.fo...@gmail.com> wrote:
Hello everyone,

I have been trying to redirect MPI_Init and MPI_Finalize calls from a FORTRAN application 
(the CG benchmark from NAS Parallel Benchmarks). It appears that in the fortran 
application the MPI_Init function signature is "mpi_init_", whereas in my 
shared object it is MPI_Init. How is the f-to-c binding done in Open-MPI? How can I 
change the Makefile.am (or add a configure.m4) in order to check the way this name 
mapping is done by the compiler, and how to add the proper symbols so that my shared 
object could be used also with FORTRAN programs ?

Thank you in advance,

Clément FOYER

_______________________________________________
devel mailing list
devel@lists.open-mpi.org
https://rfd.newmexicoconsortium.org/mailman/listinfo/devel
_______________________________________________
devel mailing list
devel@lists.open-mpi.org
https://rfd.newmexicoconsortium.org/mailman/listinfo/devel


_______________________________________________
devel mailing list
devel@lists.open-mpi.org
https://rfd.newmexicoconsortium.org/mailman/listinfo/devel

Reply via email to