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


-- 
Jeff Squyres
jsquy...@cisco.com
For corporate legal information go to: 
http://www.cisco.com/web/about/doing_business/legal/cri/

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

Reply via email to