24.05.2014 Views

XL Fortran Enterprise Edition for AIX : User's Guide - IBM

XL Fortran Enterprise Edition for AIX : User's Guide - IBM

XL Fortran Enterprise Edition for AIX : User's Guide - IBM

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Interlanguage Calls<br />

This section gives details about per<strong>for</strong>ming interlanguage calls from your <strong>Fortran</strong><br />

program: that is, calling routines that were written in a language other than<br />

<strong>Fortran</strong>. It assumes that you are familiar with the syntax of all applicable<br />

languages.<br />

Conventions <strong>for</strong> <strong>XL</strong> <strong>Fortran</strong> External Names<br />

To assist you in writing mixed-language programs, <strong>XL</strong> <strong>Fortran</strong> follows a consistent<br />

set of rules when translating the name of a global entity into an external name that<br />

the linker can resolve:<br />

v<br />

v<br />

v<br />

v<br />

Both the underscore (_) and the dollar sign ($) are valid characters anywhere in<br />

names.<br />

Because names that begin with an underscore are reserved <strong>for</strong> the names of<br />

library routines, do not use an underscore as the first character of a <strong>Fortran</strong><br />

external name.<br />

To avoid conflicts between <strong>Fortran</strong> and non-<strong>Fortran</strong> function names, you can<br />

compile the <strong>Fortran</strong> program with the -qextname option. This option adds an<br />

underscore to the end of the <strong>Fortran</strong> names. Then use an underscore as the last<br />

character of any non-<strong>Fortran</strong> procedures that you want to call from <strong>Fortran</strong>.<br />

Names can be up to 250 characters long.<br />

Program and symbolic names are interpreted as all lowercase by default. If you<br />

are writing new non-<strong>Fortran</strong> code, use all-lowercase procedure names to<br />

simplify calling the procedures from <strong>Fortran</strong>.<br />

You can use the -U option or the @PROCESS MIXED directive if you want the<br />

names to use both uppercase and lowercase:<br />

@process mixed<br />

external C_Func<br />

integer aBc, ABC<br />

common /xYz/ aBc<br />

common /XYZ/ ABC<br />

end<br />

! With MIXED, we can call C_Func, not just c_func.<br />

! With MIXED, these are different variables.<br />

! The same applies to the common block names.<br />

! xYz and XYZ are external names that are<br />

! visible during linking.<br />

Names <strong>for</strong> module procedures are <strong>for</strong>med by concatenating __ (two<br />

underscores), the module name, _IMOD_ (<strong>for</strong> intrinsc modules) or _NMOD_ (<strong>for</strong><br />

non-intrinsic modules), and the name of the module procedure. For example,<br />

module procedure MYPROC in module MYMOD has the external name<br />

__mymod_NMOD_myproc.<br />

© Copyright <strong>IBM</strong> Corp. 1990, 2004 345

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!