[Trilinos-Users] Fortran name mangling
rouson at sandia.gov
Wed Dec 15 14:32:02 MST 2010
If you're running nm on a library file and trying to decipher a name mangling scheme, then the resulting code will be compiler-specific and therefore non-portable. If you're using a recent version of ifort, a preferred approach is to link using Fortran interface bodies that bind to C function prototypes in a way that is standards-conforming and therefore not compiler-specific.
An even better way is to work with the ForTrilinos developers on writing fully object-oriented Fortran 2003 interfaces to the packages of interest to you. The released version of ForTrilinos wraps numerous Epetra classes. We are working on Amesos wrappers and have Tpetra and Stratimikos high on our priority list. If these overlap with your interests, we're in luck. If not, there's a lot we can offer in terms of a wrapping strategy that resolves several important issues that arise in accessing Trilinos from Fortran and we can assist with the wrapper construction process.
Please feel free to write fortrilinos-developers at software.sandia.gov for more information.
On 12/14/10 10:34 AM, "Alireza Nejadmalayeri" <Alireza.Nejadmalayeri at colorado.edu> wrote:
Thanks, Chris. Here is what "nm Fortran_calls__Trilinos_CC_Interface.o | grep -i trilinos_interface" returns:
And nm libmyappLib.a | grep -i trilinos_interface :
0000000000000050 T _Z19trilinos_interface_PiS_
0000000000000018 r _Z19trilinos_interface_PiS_$$LSDA
Could you please advise on these.
----- Original Message -----
From: "Baker, Christopher G." <bakercg at ornl.gov <mailto:bakercg at ornl.gov> >
To: "Alireza Nejadmalayeri" <Alireza.Nejadmalayeri at colorado.edu <mailto:Alireza.Nejadmalayeri at colorado.edu> >; <trilinos-users at software.sandia.gov <mailto:trilinos-users at software.sandia.gov> >
Sent: Tuesday, December 14, 2010 2:54 AM
Subject: Re: [Trilinos-Users] Fortran name mangling
Try looking at libmyappLib.a so see what the symbol is called:
nm libmyappLib.a | grep -i trilinos_interface
Also, it won't hurt to verify what the Fortran compiler is doing:
mpif90 $(FORT_FLAGS) $(INCLUDE_DIRS) $(DEFINES) -c Fortran_calls_Trilinos_CC_Interface.f90
nm Fortran_calls_Trilinos_CC_Interface.o | grep -i trilinos_interface
On 12/13/10 11:02 PM, "Alireza Nejadmalayeri" <Alireza.Nejadmalayeri at colorado.edu<mailto:Alireza.Nejadmalayeri at colorado.edu <mailto:Alireza.Nejadmalayeri at colorado.edu> >> wrote:
I have been trying to compile a simple mixed Fortran/CC code using makefile build system, but it is not going so well.
I would appreciate any advice on how to debug this problem:
1) I have just 2 source files: Fortran_calls__Trilinos_CC_Interface.f90 & Trilinos_Interface.cpp
2) Trilinos_Interface.cpp contains a function, void Trilinos_Interface(...) , which is communicating with Trilinos
3) Inside Fortran_calls__Trilinos_CC_Interface.f90, Trilinos_Interface(...) is called
4) Inside Trilinos_Interface.cpp, I have defined:
#define Trilinos_Interface trilinos_interface_
5) And the build part of the makefile:
mpif90 $(FORT_FLAGS) $(LINK_FLAGS) $(INCLUDE_DIRS) $(DEFINES) $(LIBRARY_DIRS) libmyappLib.a $(LIBRARIES) Fortran_calls__Trilinos_CC_Interface.f90 -o MyApp.exe
$(Trilinos_AR) cr libmyappLib.a Trilinos_Interface.o
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_DIRS) $(DEFINES) Trilinos_Interface.cpp
The reason I use mpif90 is that $FORT is mpif77, though I think there is no difference here.
But I am getting this:
/tmp/iforteBcFzw.o: In function `fortran_calls_c':
/usr/rmt_share/scratch95/a/alireza/The_Trilions_Project/Trilinos_Users/TrilinosUsers__EpetraOperatorAztecOO__FcallsCC2/Fortran_calls__Trilinos_CC_Interface.f90:270: undefined reference to `trilinos_interface_'
make: *** [MyApp.exe] Error 1
Besides, I notice "lower under" mangling while configuring:
FORTRAN_MANGLING: Bingo! LOWER UNDER is the correct fortran name mangling!
-- Fortran name mangling: LOWER UNDER
-- Detecting Fortran/C Interface
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Trilinos-Users