Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

symbol name in the .lib file

Han_H_
Beginner
732 Views

Hi,

I have found that when linking a fortran library in C/C++, the subroutine name has changed to ALL uppercase when compiled by Intel Fortran Compiler.

For example, the subroutine in fortran

 subroutine setulb(n, m, x, l, u, nbd, f, g, factr, pgtol, wa, iwa,
     +                 task, iprint, csave, lsave, isave, dsave)

has changed to SETULB when called in C/C++. 

However, when compiled the fortran code by gfortran, it is setulb_ and the name can be handled by the instructions, such as -fno-underscore, fsource-case-lower.

I would like to know, if there are equivalent instructions in ifort to change the name in the exported lib file, so I can use the same calling for them.

0 Kudos
2 Replies
IanH
Honored Contributor III
732 Views

Fortran 2003 added C interoperability features to the language to solve this sort of problem.  Those features are widely supported amongst current Fortran compilers.  You should use those features, rather than relying on compiler specific behaviour - it will make your current and future life much easier.

In Fortran, write a thin wrapper for your procedure that has the BIND(C) attribute and that takes appropriate interoperable arguments.

0 Kudos
Steven_L_Intel1
Employee
732 Views

Intel Fortran does have equivalent options, but I strongly recommend that you take Ian's advice and use the C interoperability features to account for name case and decoration. You could simply add BIND(C) after the close parentheses on the subroutine and this would cause the external name to be lowercased and not have a trailing underscore. I will warn you, though, that use of the interoperability features places some restrictions on what kinds of dummy arguments you can have. In particular, CHARACTER with length other than 1 is not allowed. (You pass strings as an array of single characters.)

Once you do this, you will be independent of implementation specifics for name decoration and case.

0 Kudos
Reply