02.07.2014 Views

Intel(R) Fortran Compiler for Linux* Systems User's Guide Volume I ...

Intel(R) Fortran Compiler for Linux* Systems User's Guide Volume I ...

Intel(R) Fortran Compiler for Linux* Systems User's Guide Volume I ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Intel</strong>® <strong>Fortran</strong> <strong>Compiler</strong> <strong>for</strong> <strong>Linux*</strong> <strong>Systems</strong> <strong>User's</strong> <strong>Guide</strong>, <strong>Volume</strong> I: Building<br />

Applications<br />

After establishing a consistent interface between mixed-language procedures,<br />

you then need to reconcile any differences in the treatment of individual data<br />

types (strings, arrays, and so on). This is discussed in Exchanging and<br />

Accessing Data in Mixed-Language Programming.<br />

Note<br />

This section uses the term "routine" in a generic way, to refer to functions,<br />

subroutines, and procedures from different languages.<br />

Adjusting Calling Conventions in Mixed-Language Programming<br />

Adjusting Calling Conventions in<br />

Mixed-Language Programming<br />

Overview<br />

The calling convention determines how a program makes a call to a routine, how<br />

the arguments are passed, and how the routines are named. See Adjusting<br />

Naming Conventions in Mixed-Language Programming.<br />

In a single-language program, calling conventions are nearly always correct,<br />

because there is one default <strong>for</strong> all routines and because header files or <strong>Fortran</strong><br />

module files with interface blocks en<strong>for</strong>ce consistency between the caller and the<br />

called routine.<br />

In a mixed-language program, different languages cannot share the same header<br />

files. If, as a result, you link <strong>Fortran</strong> and C routines that use different calling<br />

conventions, the error is not apparent until the bad call is made at run time.<br />

During execution, the bad call causes indeterminate results and/or a fatal error,<br />

often somewhere in the program that has no apparent relation to the actual<br />

cause: memory/stack corruption due to calling errors. There<strong>for</strong>e, you should<br />

check carefully the calling conventions <strong>for</strong> each mixed-language call.<br />

The discussion of calling conventions between languages applies only to external<br />

procedures. You cannot call internal procedures from outside the program unit<br />

that contains them.<br />

A calling convention affects programming in four ways:<br />

1. The caller routine uses a calling convention to determine the order in which to<br />

pass arguments to another routine; the called routine uses a calling convention to<br />

determine the order in which to receive the arguments passed to it. In <strong>Fortran</strong>, you<br />

181

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

Saved successfully!

Ooh no, something went wrong!