<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><div dir="ltr">Florin,<div> As we discussed, it looks your aim is to provide MPI profiling (implemented in C) to Fortran+MPI code.</div><div> Try this: Implement your profiling layer in PMPI_Xxxx(), and call MPI_Xxxx() in it. You do not need to change cases or add trailing underscores. Then, insert your library after libmpifort.a, before libmpi.a in linking</div><div> </div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr">--Junchao Zhang</div></div></div>
<br><div class="gmail_quote">On Tue, Nov 18, 2014 at 9:47 AM, Isaila, Florin D. <span dir="ltr"><<a href="mailto:fisaila@mcs.anl.gov" target="_blank">fisaila@mcs.anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
it works what Rajeev suggests, defining the C function as mpi_init_ (one underscore for g77). In this case I would need a wrapper for and one for Fortran.<br>
<br>
However I understand from Section 14.2.1 of the MPI3 document (thanks Junchao for pointing to this) that I should be able to define just an MPI_Init wrapper in C and the call of MPI_Init(0, 0) from the Fortran implementation of mpi_init should be also redirected to my function.<br>
<br>
Pavan, I use MPICH-3.1.3. There is slight difference when I run the example you gave me, the libpmpi library does not appear:<br>
fisaila@howard:f77$ mpif77 -show fpi.f<br>
gfortran fpi.f -I/homes/fisaila/software/mpich/include -I/homes/fisaila/software/mpich/include -L/homes/fisaila/software/mpich/lib -lmpifort -Wl,-rpath -Wl,/homes/fisaila/software/mpich/lib -Wl,--enable-new-dtags -lmpi<br>
<br>
fisaila@howard:f77$ export PROFILE_PRELIB="-lfoo"<br>
<br>
fisaila@howard:f77$ mpif77 -show fpi.f<br>
gfortran fpi.f -I/homes/fisaila/software/mpich/include -I/homes/fisaila/software/mpich/include -L/homes/fisaila/software/mpich/lib -lmpifort -lfoo -Wl,-rpath -Wl,/homes/fisaila/software/mpich/lib -Wl,--enable-new-dtags -lmpi<br>
<br>
The mpi and mpifort have the following symbols:<br>
<br>
fisaila@howard:f77_program$ nm /homes/fisaila/software/mpich/lib/libmpi.a | grep MPI_Init<br>
000000000000146d W MPI_Init<br>
000000000000146d T PMPI_Init<br>
<br>
<br>
fisaila@howard:f77_program$ nm /homes/fisaila/software/mpich/lib/libmpifort.a | grep -i MPI_Init<br>
0000000000000000 W MPI_INIT<br>
0000000000000000 W PMPI_INIT<br>
U PMPI_Init<br>
0000000000000000 W mpi_init<br>
0000000000000000 W mpi_init_<br>
0000000000000000 W mpi_init__<br>
0000000000000000 W pmpi_init<br>
0000000000000000 T pmpi_init_<br>
0000000000000000 W pmpi_init__<br>
<br>
Thanks<br>
Florin<br>
<br>
<br>
________________________________________<br>
From: Rajeev Thakur [<a href="mailto:thakur@mcs.anl.gov">thakur@mcs.anl.gov</a>]<br>
Sent: Monday, November 17, 2014 3:39 PM<br>
To: <a href="mailto:discuss@mpich.org">discuss@mpich.org</a><br>
Cc: <a href="mailto:mpich-discuss@mcs.anl.gov">mpich-discuss@mcs.anl.gov</a><br>
Subject: Re: [mpich-discuss] f77 bindings and profiling<br>
<div class="HOEnZb"><div class="h5"><br>
You need to add the right number of underscores at the end of the C function depending on the Fortran compiler you are using. For gfortran I think it is two underscores. So define the C function as mpi_init__. If that doesn't work, use one underscore. MPICH detects all this automatically at configure time.<br>
<br>
Rajeev<br>
<br>
On Nov 17, 2014, at 3:28 PM, "Isaila, Florin D." <<a href="mailto:fisaila@mcs.anl.gov">fisaila@mcs.anl.gov</a>> wrote:<br>
<br>
> Hi ,<br>
><br>
> I am trying to use MPI profiling to make mpi_init from a F77 program call my MPI_Init (written in C), but I do not manage to achieve that. In this simple F77 program:<br>
> program main<br>
> include 'mpif.h'<br>
> integer error<br>
> call mpi_init(error)<br>
> call mpi_finalize(error)<br>
> end<br>
><br>
> I try to make the mpi_init call:<br>
> int MPI_Init (int *argc, char ***argv){ int ret;<br>
> printf("My function!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");<br>
> ret = PMPI_Init(argc, argv);<br>
> return ret;<br>
> }<br>
><br>
> My MPI_Init belongs to a library libtarget.a I created. I use -profile for compiling and I created the target.conf containing:<br>
> PROFILE_PRELIB="-L/homes/fisaila/benches/try/staticlib_mpif77 -ltarget"<br>
> in the right place.<br>
><br>
> The library appears in the command line before the mpich library:<br>
> mpif77 -show -g -profile=target init_finalize.f -o init_finalize<br>
> gfortran -g init_finalize.f -o init_finalize -I/homes/fisaila/software/mpich/include -L/homes/fisaila/software/mpich/lib -L/homes/fisaila/benches/try/staticlib_mpif77 -ltarget -Wl,-rpath -Wl,/homes/fisaila/software/mpich/lib -lmpich -lopa -lmpl -lrt -lpthread<br>
><br>
> However, the program never gets into my MPI_Init.<br>
><br>
> Any suggestion about what I am missing?<br>
><br>
> Thanks<br>
> Florin<br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
> _______________________________________________<br>
> discuss mailing list <a href="mailto:discuss@mpich.org">discuss@mpich.org</a><br>
> To manage subscription options or unsubscribe:<br>
> <a href="https://lists.mpich.org/mailman/listinfo/discuss" target="_blank">https://lists.mpich.org/mailman/listinfo/discuss</a><br>
<br>
_______________________________________________<br>
discuss mailing list <a href="mailto:discuss@mpich.org">discuss@mpich.org</a><br>
To manage subscription options or unsubscribe:<br>
<a href="https://lists.mpich.org/mailman/listinfo/discuss" target="_blank">https://lists.mpich.org/mailman/listinfo/discuss</a><br>
_______________________________________________<br>
discuss mailing list <a href="mailto:discuss@mpich.org">discuss@mpich.org</a><br>
To manage subscription options or unsubscribe:<br>
<a href="https://lists.mpich.org/mailman/listinfo/discuss" target="_blank">https://lists.mpich.org/mailman/listinfo/discuss</a><br>
</div></div></blockquote></div><br></div>