Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 9/08/2022
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

Use Standard Fortran Interoperability Syntax for Existing Fortran Extensions

Before the introduction of the Standard Fortran interoperability features, extensions provided by Intel® Fortran were used to facilitate programming using code written in Fortran and C. The Fortran 2003 standard defined new language features for C interoperability; in many cases, these features can be used instead of existing Intel® Fortran extensions. The following table lists the legacy Intel® Fortran extensions and shows their Standard Fortran equivalents.

NOTE:

Existing code using legacy extensions will continue to work; however, if you are writing new code, you should use the standard syntax.

Legacy Extension

Standard Fortran Interoperability Equivalent

ATTRIBUTES ALIAS

Use BIND(C,NAME=<alias-name>).

The BIND(C) syntax also implies ATTRIBUTES DECORATE; the compiler applies whatever name decoration (leading or trailing underscores) that C would use for the name. If the NAME= keyword is omitted, Intel® Fortran will use the Fortran name converted to lowercase on all platforms.

If the procedure has no arguments, you must indicate that with () when adding BIND.

All arguments to a routine specified as interoperable (with BIND(C)) must themselves be interoperable.

You can also specify BIND(C) on module variables and COMMON blocks.

ATTRIBUTES C

Use BIND(C) (see ALIAS above), which has a similar effect to ATTRIBUTES C except that it does not change the argument passing mechanism to be by-value. Use the Fortran standard VALUE attribute if you need to pass by value.

BIND(C) specifies that small records are passed and returned as function value results in the same way that C would. The results may be different from the Intel® Fortran default. Like ATTRIBUTES C, BIND(C) lowercases the external name and adds any necessary name decoration.

ATTRIBUTES DECORATE

Typically used with ATTRIBUTES ALIAS. See ATTRIBUTES ALIAS above.

ATTRIBUTES DEFAULT

Not needed when using BIND(C); the compiler always uses the semantics of the C compiler regardless of the setting of command-line options such as iface.

ATTRIBUTES EXTERN

Use BIND(C) with a module variable.

ATTRIBUTES REFERENCE

Not needed when using BIND(C).

Typically used with character arguments, or to override the implicit pass-by-value of ATTRIBUTES C.

ATTRIBUTES STDCALL

No equivalent.

The use of STDCALL with BIND(C) is supported in Intel® Fortran and, for Windows* on IA-32 architecture only, it changes the external procedure name and stack conventions. For more information, see ATTRIBUTES C and STDCALL.

ATTRIBUTES VALUE

Use the Fortran-standard VALUE attribute.

VALUE has an additional effect when used with a Fortran procedure. The dummy argument is received by value, then copied to a temporary variable that can be modified within the procedure. Once the procedure exits, the temporary value is discarded.

ATTRIBUTES VARYING

No equivalent.

%LOC function

Use the C_LOC function from intrinsic module ISO_C_BINDING, which may be an appropriate substitute for variables. C_FUNLOC is the corresponding function for procedures.

%VAL function

Declare the argument with the VALUE attribute.

%REF function

No equivalent; %REF function is the default when BIND(C) is used.