[Mpi3-tools] Fortran Wrappers in Fortran?

Marc-Andre Hermanns m.a.hermanns at grs-sim.de
Tue Jun 4 12:25:22 CDT 2013

Hi Rolf,

comments inline.

>> with the Fortran wrappers discussion taking off tomorrow, I wanted to
>> explicitly ask about something that has spooked around in my head for
>> some time, and I am unsure whether this is viable or not.
>> It does not solve the name mangling is general, but maybe it is an
>> easy approach in some cases, such as simple preinstrumented libraries.
>> The new Fortran interface comes only with Fortran 2008+ compilers,
>> because older compilers don't know all the new magic that is necessary
>> to make it work, right? This would mean that the compiler also has the
>> C interface capabilities of Fortran 2003.
> The new mpi_f08 module does not require Fortran 2008 + TS 29113.
> Preliminary implementations (with MPI_SUBARRAYS_SUPPORTED=.FALSE.)
> are possible with Fortran 2003. Same is valid for the new
> requirements on the mpi module (e.g., compile time arument checking).

Fortran 2003 would be sufficient for my idea, so that should be ok.

>> Performance tools like Scalasca or Score-P, usually call
>> straight-forward C routines in the wrappers to generate the
>> measurement
>> data and maybe do some simple computations in between. Usually, they
>> just pass the initial parameters through.
>> As most of our wrapper code is generated anyway. Would it be a viable
>> approach to
>> 1) generate a C interface definition for the parts of the measurement
>> system in question to call the measurement routines from Fortran, and
>> 2) generate Fortran wrappers that directly call the measurement system
>> through the generated interface and then call the Fortran version of
>> "PMPI_Func"?
>> Would the Fortran compiler then take care of all the name mangling
>> issues in this case?
>> Using Fortran wrappers calling the Fortran PMPI routines would also
>> make handle conversion (to call the C MPI wrapper) unnecessary and
>> could save overhead.
> I'm not sure whether I understood your approach.
> For me, it looks like that you want to go a similar way as Bill Long
> who has Fortran-written wrappers that directly call the
> MPI C routines. For this, he defined a module with the Interfaces
> of the MPI C routines in Fortran 2003 syntax with BIND(C).
It is similar, but not quite the same.

I also propose to have pure Fortran wrappers, but instead of calling the 
MPI C routines, I would call the Fortran PMPI functions. I would define 
a BIND(C) interface for my measurement system and call those routines in 
the wrapper.

 > He tries to get his Fortran MPI wrappers fully portable,
 > though the tools intercept only at the C Interface.

My proposal would make tools intercept on both the C and the Fortran 
interface. As a the majority of the wrappers is generated, I think this 
could still be maintainable.

> See also the Details in c20.comments.txt attached to a previous mail.

I'll check for that (I may have to search the online archive, though).


Marc-Andre Hermanns
German Research School for
Simulation Sciences GmbH
c/o Laboratory for Parallel Programming
52062 Aachen | Germany

Tel +49 241 80 99753
Fax +49 241 80 6 99753
Web www.grs-sim.de

Members: Forschungszentrum Jülich GmbH | RWTH Aachen University
Registered in the commercial register of the local court of
Düren (Amtsgericht Düren) under registration number HRB 5268
Registered office: Jülich
Executive board: Prof. Marek Behr, Ph.D | Prof. Dr. Sebastian M. Schmidt

More information about the mpiwg-tools mailing list