
The facilities relevant to interfacing with the Fortran language are the
package Interfaces.Fortran and support for the Import, Export and
Convention pragmas with convention_identifier Fortran.

The package Interfaces.Fortran defines Ada types whose representations
are identical to the default representations of the Fortran intrinsic
types Integer, Real, Double Precision, Complex, Logical, and Character
in a supported Fortran implementation. These Ada types can therefore be
used to pass objects between Ada and Fortran programs.
Static Semantics

The library package Interfaces.Fortran has the following declaration:

with Ada.Numerics.Generic_Complex_Types;  See section G.1.1 Complex Types.
pragma Elaborate_All(Ada.Numerics.Generic_Complex_Types);
package Interfaces.Fortran is
pragma Pure(Fortran);

type Fortran_Integer is range implementationdefined;

type Real is digits implementationdefined;
type Double_Precision is digits implementationdefined;

type Logical is new Boolean;

package Single_Precision_Complex_Types is
new Ada.Numerics.Generic_Complex_Types (Real);

type Complex is new Single_Precision_Complex_Types.Complex;

subtype Imaginary is Single_Precision_Complex_Types.Imaginary;
i : Imaginary renames Single_Precision_Complex_Types.i;
j : Imaginary renames Single_Precision_Complex_Types.j;

type Character_Set is implementationdefined character type;

type Fortran_Character is
array (Positive range <>) of Character_Set;
pragma Pack (Fortran_Character);

function To_Fortran (Item : in Character) return Character_Set;
function To_Ada (Item : in Character_Set) return Character;

function To_Fortran (Item : in String) return Fortran_Character;
function To_Ada (Item : in Fortran_Character) return String;

procedure To_Fortran (Item : in String;
Target : out Fortran_Character;
Last : out Natural);

procedure To_Ada (Item : in Fortran_Character;
Target : out String;
Last : out Natural);

end Interfaces.Fortran;

The types Fortran_Integer, Real, Double_Precision, Logical, Complex, and
Fortran_Character are Fortrancompatible.

The To_Fortran and To_Ada functions map between the Ada type Character
and the Fortran type Character_Set, and also between the Ada type String
and the Fortran type Fortran_Character. The To_Fortran and To_Ada
procedures have analogous effects to the string conversion subprograms
found in Interfaces.COBOL.
Implementation Requirements

An implementation shall support pragma Convention with a Fortran
convention_identifier for a Fortraneligible type, See section B.1 Interfacing Pragmas.
Implementation Permissions

An implementation may add additional declarations to the Fortran
interface packages. For example, the Fortran interface package for an
implementation of Fortran 77 (ANSI X3.91978) that defines types like
Integer*n, Real*n, Logical*n, and Complex*n may contain the declarations
of types named Integer_Star_n, Real_Star_n, Logical_Star_n, and
Complex_Star_n. (This convention should not apply to Character*n, for
which the Ada analog is the constrained array subtype Fortran_Character
(1..n).) Similarly, the Fortran interface package for an implementation
of Fortran 90 that provides multiple kinds of intrinsic types, e.g.
Integer (Kind=n), Real (Kind=n), Logical (Kind=n), Complex (Kind=n), and
Character (Kind=n), may contain the declarations of types with the
recommended names Integer_Kind_n, Real_Kind_n, Logical_Kind_n,
Complex_Kind_n, and Character_Kind_n.
Implementation Advice

An Ada implementation should support the following interface
correspondences between Ada and Fortran:

An Ada procedure corresponds to a Fortran subroutine.

An Ada function corresponds to a Fortran function.

An Ada parameter of an elementary, array, or record type T is passed as
a T(F) argument to a Fortran procedure, where T(F) is the Fortran type
corresponding to the Ada type T, and where the INTENT attribute of the
corresponding dummy argument matches the Ada formal parameter mode; the
Fortran implementation's parameter passing conventions are used. For
elementary types, a local copy is used if necessary to ensure bycopy
semantics.

An Ada parameter of an accesstosubprogram type is passed as a
reference to a Fortran procedure whose interface corresponds to the
designated subprogram's specification.