To assist you in writing mixed-language programs, XL Fortran follows a consistent set of rules when translating the name of a global entity into an external name that the linker can resolve:
Because names that begin with an underscore are reserved for the names of library routines, do not use an underscore as the first character of a Fortran external name.
To avoid conflicts between Fortran and non-Fortran function names, you can compile the Fortran program with the -qextname option. This option adds an underscore to the end of the Fortran names. Then use an underscore as the last character of any non-Fortran procedures that you want to call from Fortran.
You can use the -U option or the @PROCESS MIXED directive if you want the names to use both uppercase and lowercase:
@process mixed external C_Func ! With MIXED, we can call C_Func, not just c_func. integer aBc, ABC ! With MIXED, these are different variables. common /xYz/ aBc ! The same applies to the common block names. common /XYZ/ ABC ! xYz and XYZ are external names that are ! visible during linking. end
If you are porting your application from another system, and your application does encounter naming conflicts like these, you may need to use the -qextname Option. Or you can use the -brename linker option to rename the symbol if there are not too many names to change:
xlf90 -brename:old_name,new_name interlanguage_calls.f