1------------------------------------------------------------------------------
2--                                                                          --
3--                         GNAT COMPILER COMPONENTS                         --
4--                                                                          --
5--                   I N T E R F A C E S . F O R T R A N                    --
6--                                                                          --
7--                                 S p e c                                  --
8--                                                                          --
9-- This specification is derived from the Ada Reference Manual for use with --
10-- GNAT.  In accordance with the copyright of that document, you can freely --
11-- copy and modify this specification,  provided that if you redistribute a --
12-- modified version,  any changes that you have made are clearly indicated. --
13--                                                                          --
14------------------------------------------------------------------------------
15
16with Ada.Numerics.Generic_Complex_Types;
17pragma Elaborate_All (Ada.Numerics.Generic_Complex_Types);
18
19package Interfaces.Fortran is
20   pragma Pure;
21
22   type Fortran_Integer  is new Integer;
23   type Real             is new Float;
24   type Double_Precision is new Long_Float;
25
26   type Logical is new Boolean;
27   for Logical'Size use Integer'Size;
28   pragma Convention (Fortran, Logical);
29   --  As required by Fortran standard, logical allocates same space as
30   --  an integer. The convention is important, since in Fortran, Booleans
31   --  are implemented with zero/non-zero semantics for False/True, and the
32   --  pragma Convention (Fortran) activates the special handling required
33   --  in this case.
34
35   package Single_Precision_Complex_Types is
36      new Ada.Numerics.Generic_Complex_Types (Real);
37
38   package Double_Precision_Complex_Types is
39      new Ada.Numerics.Generic_Complex_Types (Double_Precision);
40
41   type Complex is new Single_Precision_Complex_Types.Complex;
42
43   type Double_Complex is new Double_Precision_Complex_Types.Complex;
44
45   subtype Imaginary is Single_Precision_Complex_Types.Imaginary;
46   i : Imaginary renames Single_Precision_Complex_Types.i;
47   j : Imaginary renames Single_Precision_Complex_Types.j;
48
49   type Character_Set is new Character;
50
51   type Fortran_Character is array (Positive range <>) of Character_Set;
52
53   --  Additional declarations as permitted by Ada 2012, p.608, paragraph 21.
54   --  Interoperability with Fortran 77's vendor extension using star
55   --  notation and Fortran 90's intrinsic types with kind=n parameter.
56   --  The following assumes that `n' matches the byte size, which
57   --  most Fortran compiler, including GCC's follow.
58
59   type Integer_Star_1  is new Integer_8;
60   type Integer_Kind_1  is new Integer_8;
61   type Integer_Star_2  is new Integer_16;
62   type Integer_Kind_2  is new Integer_16;
63   type Integer_Star_4  is new Integer_32;
64   type Integer_Kind_4  is new Integer_32;
65   type Integer_Star_8  is new Integer_64;
66   type Integer_Kind_8  is new Integer_64;
67
68   type Logical_Star_1  is new Boolean;
69   type Logical_Star_2  is new Boolean;
70   type Logical_Star_4  is new Boolean;
71   type Logical_Star_8  is new Boolean;
72   type Logical_Kind_1  is new Boolean;
73   type Logical_Kind_2  is new Boolean;
74   type Logical_Kind_4  is new Boolean;
75   type Logical_Kind_8  is new Boolean;
76   for Logical_Star_1'Size use Integer_8'Size;
77   for Logical_Star_2'Size use Integer_16'Size;
78   for Logical_Star_4'Size use Integer_32'Size;
79   for Logical_Star_8'Size use Integer_64'Size;
80   for Logical_Kind_1'Size use Integer_8'Size;
81   for Logical_Kind_2'Size use Integer_16'Size;
82   for Logical_Kind_4'Size use Integer_32'Size;
83   for Logical_Kind_8'Size use Integer_64'Size;
84   pragma Convention (Fortran, Logical_Star_1);
85   pragma Convention (Fortran, Logical_Star_2);
86   pragma Convention (Fortran, Logical_Star_4);
87   pragma Convention (Fortran, Logical_Star_8);
88   pragma Convention (Fortran, Logical_Kind_1);
89   pragma Convention (Fortran, Logical_Kind_2);
90   pragma Convention (Fortran, Logical_Kind_4);
91   pragma Convention (Fortran, Logical_Kind_8);
92
93   type Real_Star_4  is new Float;
94   type Real_Kind_4  is new Float;
95   type Real_Star_8  is new Long_Float;
96   type Real_Kind_8  is new Long_Float;
97
98   --  In the kind syntax, n is the same as the associated real kind.
99   --  In the star syntax, n is twice as large (real+imaginary size)
100   type Complex_Star_8  is new Complex;
101   type Complex_Kind_4  is new Complex;
102   type Complex_Star_16 is new Double_Complex;
103   type Complex_Kind_8  is new Double_Complex;
104
105   type Character_Kind_n is new Fortran_Character;
106
107   function To_Fortran (Item : Character)     return Character_Set;
108   function To_Ada     (Item : Character_Set) return Character;
109
110   function To_Fortran (Item : String)            return Fortran_Character;
111   function To_Ada     (Item : Fortran_Character) return String;
112
113   procedure To_Fortran
114     (Item   : String;
115      Target : out Fortran_Character;
116      Last   : out Natural);
117
118   procedure To_Ada
119     (Item   : Fortran_Character;
120      Target : out String;
121      Last   : out Natural);
122
123end Interfaces.Fortran;
124