[Trilinos-Users] Fortran name mangling

M. Scot Breitenfeld brtnfld at uiuc.edu
Tue Dec 14 08:39:06 MST 2010


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

interface
    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(++).

Scot



On 12/13/2010 10:02 PM, Alireza Nejadmalayeri wrote:
> Hello,
>  
> 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:
>  
> MyApp.exe: libmyappLib.a
>  mpif90 $(FORT_FLAGS) $(LINK_FLAGS) $(INCLUDE_DIRS) $(DEFINES)
> $(LIBRARY_DIRS) libmyappLib.a $(LIBRARIES)
> Fortran_calls__Trilinos_CC_Interface.f90 -o MyApp.exe
>  
> libmyappLib.a: Trilinos_Interface.o
>  $(Trilinos_AR) cr libmyappLib.a Trilinos_Interface.o
>  
> 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.
>  
> 6)
> 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
>  
> 7)
> 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
>  
> Thank you,
> alireza
>  
>
>
> _______________________________________________
> Trilinos-Users mailing list
> Trilinos-Users at software.sandia.gov
> http://software.sandia.gov/mailman/listinfo/trilinos-users




More information about the Trilinos-Users mailing list