[Trilinos-Users] Fortran name mangling

Rouson, Damian rouson at sandia.gov
Wed Dec 15 14:36:12 MST 2010

I see Scot covered part of what I just wrote.  I would also add that the latest version of nearly every Fortran compiler provides the mentioned ISO_C_BINDING module (including the Intel, Portland Group, Gnu, NAG, Cray, and IBM compilers), so if you don't have access to it and updating your compiler version is an option, you can almost definitely get it.


On 12/15/10 5:15 AM, "Baker, Christopher G." <bakercg at ornl.gov> wrote:

The problem is that the symbol name is being mangled by the C++ compiler. A solution is to define it in an extern block:
$ cat test.cpp
#define Trilinos_Interface trilinos_interface_
extern "C" {
  void Trilinos_Interface() { }
$ icpc -c test.cpp
$ nm test.o | grep trilinos
0000000000000000 T trilinos_interface_

However, I would recommend, if possible, following Scot's advice for standards-compliant and portable solutions to this problem (I'm not sure if you were on the receiving list for this):

On 12/14/10 10:39 AM, "M. Scot Breitenfeld" <brtnfld at uiuc.edu<mailto:brtnfld at uiuc.edu>> wrote:

You can use the BIND statement to avoid the need to guess the naming

    subroutine Trilinos_Interface(...) BIND(c,name='Trilinos_Interface')
end interface

This assumes you have a Fortran 2003 compiler. If this is true then also
make use of the ISO_C_BINDING module as
a portable (and easy way) to interface with C(++).



On 12/14/10 1:34 PM, "Alireza Nejadmalayeri" <Alireza.Nejadmalayeri at Colorado.EDU<mailto:Alireza.Nejadmalayeri at Colorado.EDU>> wrote:

Thanks, Chris. Here is what   "nm Fortran_calls__Trilinos_CC_Interface.o | grep -i trilinos_interface"  returns:
     U trilinos_interface_

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.

Thank you,

Trilinos-Users mailing list
Trilinos-Users at software.sandia.gov

-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://software.sandia.gov/pipermail/trilinos-users/attachments/20101215/143e8de6/attachment.html 

More information about the Trilinos-Users mailing list