Skip to content

Commit f4f467d

Browse files
committed
fp-interop: Add initial draft of C floating-point interop
1 parent 608c3c2 commit f4f467d

File tree

1 file changed

+170
-0
lines changed

1 file changed

+170
-0
lines changed

proposals/fp_interop/25-xxx.txt

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
To: J3 J3/##-###
2+
From: Patrick Fasano
3+
Subject: Requirements and specifications for interoperability with C
4+
interchange and extended types
5+
Date: 2025-Oct-XX
6+
7+
Reference:
8+
9+
1 Background
10+
============
11+
12+
bg01. The ISO C23 specification (ISO/IEC 9899:2024) added support for
13+
interchange and extended floating-point types. The current Fortran
14+
202Y work list WG5/N2249 includes adding interoperability with
15+
these types as accepted work item US05. At meeting #230 in June
16+
2023, J3 accepted paper 23-176 as background/use-case for
17+
additional interchange types.
18+
19+
bg03. This paper contains formal requirements and specifications for
20+
Fortran 202Y proposal US05, "Add extended floating-point types
21+
defined in ISO C23 to ISO_C_BINDING".
22+
23+
2 Requirements
24+
==============
25+
26+
rq01. The ISO_C_BINDING module should provide integer named constants
27+
for KIND parameters corresponding to the C interchange floating
28+
types '_Float16', '_Float32', '_Float64', and '_Float128'.
29+
30+
rq03. If the companion processor defines '__STDC_IEC_60559_BFP__' and
31+
'__STDC_IEC_60559_TYPES__', then the KIND parameters corresponding
32+
to '_Float32' and '_Float64' should equal those corresponding to
33+
'float' and 'double', respectively.
34+
35+
rq05. The ISO_C_BINDING module should provide integer named constants
36+
for KIND parameters corresponding to the C interchange complex
37+
types '_Float16_Complex', '_Float32_Complex', '_Float64_Complex',
38+
and '_Float128_Complex'. The values of the named constants should
39+
equal those of the respective constants for the interchange
40+
floating types.
41+
42+
rq07. [optional] The ISO_C_BINDING module should provide integer named
43+
constants for KIND parameters corresponding to the C extended
44+
floating types '_Float32x', '_Float64x', and '_Float128x'.
45+
46+
rq09. [optional] The ISO_C_BINDING module should provide integer named
47+
constants for KIND parameters corresponding to the C extended
48+
complex types '_Float32x_Complex', '_Float64x_Complex', and
49+
'_Float128x_Complex'. The values of the named constants should
50+
match those of the respective constants for the extended floating
51+
types.
52+
53+
rq11. [optional] The ISO_C_BINDING module should provide integer named
54+
constants for KIND parameters corresponding to the C interchange
55+
decimal floating types '_Decimal32', '_Decimal64', and
56+
'_Decimal128'.
57+
58+
rq13. [optional] The ISO_C_BINDING module should provide integer named
59+
constants for KIND parameters corresponding to the C extended
60+
decimal floating types '_Decimal64x', and '_Decimal128x'.
61+
62+
rq15. [optional] The ISO_C_BINDING module may provide additional integer
63+
named constants for KIND parameters corresponding to C interchange
64+
floating types of the form '_FloatN', '_FloatNx', and
65+
'_FloatN_Complex' if the companion processor defines them.
66+
67+
rq17. [optional] The ISO_C_BINDING module may provide additional integer
68+
named constants for KIND parameters corresponding to C interchange
69+
decimal floating types of the form '_DecimalN' if the companion
70+
processor defines them.
71+
72+
3 Specifications
73+
================
74+
75+
sp01. For all integer named constants to be added to the ISO_C_BINDING
76+
module, the value shall be a valid real kind type parameter or
77+
shall be -1 if the companion processor defines the corresponding C
78+
type and there is no interoperating Fortran processor kind, or -2
79+
if the companion processor does not define the corresponding C
80+
type.
81+
82+
sp02. To the ISO_C_BINDING module, add the following integer named
83+
constants for real KIND parameters:
84+
85+
+----------------+--------------------+
86+
| Named constant | C interchange type |
87+
+----------------+--------------------+
88+
| C_FLOAT16 | _Float16 |
89+
| C_FLOAT32 | _Float32 |
90+
| C_FLOAT64 | _Float64 |
91+
| C_FLOAT128 | _Float128 |
92+
+----------------+--------------------+
93+
94+
If the companion processor defines '__STDC_IEC_60559_BFP__' and
95+
'__STDC_IEC_60559_TYPES__', then the constants 'C_FLOAT32' and
96+
'C_FLOAT64' should have the same values as 'C_FLOAT' and
97+
'C_DOUBLE' (C2023 H.2.4.2).
98+
99+
sp05. To the ISO_C_BINDING module, add the following integer named
100+
constants for real KIND parameters:
101+
102+
+--------------------+--------------------+
103+
| Named constant | C interchange type |
104+
+--------------------+--------------------+
105+
| C_FLOAT16_COMPLEX | _Float16_Complex |
106+
| C_FLOAT32_COMPLEX | _Float32_Complex |
107+
| C_FLOAT64_COMPLEX | _Float64_Complex |
108+
| C_FLOAT128_COMPLEX | _Float128_Complex |
109+
+--------------------+--------------------+
110+
111+
The values of each of these named constants shall be the same as
112+
the respective constants defined in sp01.
113+
114+
sp07. [if rq07] To the ISO_C_BINDING module, add the following integer
115+
named constants for real KIND parameters:
116+
117+
+----------------+-----------------+
118+
| Named constant | C extended type |
119+
+----------------+-----------------+
120+
| C_FLOAT32X | _Float32x |
121+
| C_FLOAT64X | _Float64x |
122+
| C_FLOAT128X | _Float128x |
123+
+----------------+-----------------+
124+
125+
sp09. [if rq09] To the ISO_C_BINDING module, add the following integer
126+
named constants for real KIND parameters:
127+
128+
+---------------------+--------------------+
129+
| Named constant | C extended type |
130+
+---------------------+--------------------+
131+
| C_FLOAT32X_COMPLEX | _Float32x_Complex |
132+
| C_FLOAT64X_COMPLEX | _Float64x_Complex |
133+
| C_FLOAT128X_COMPLEX | _Float128x_Complex |
134+
+---------------------+--------------------+
135+
136+
sp11. [if rq11] To the ISO_C_BINDING module, add the following integer
137+
named constants for real KIND parameters:
138+
139+
+----------------+--------------------+
140+
| Named constant | C interchange type |
141+
+----------------+--------------------+
142+
| C_DECIMAL32 | _Decimal32 |
143+
| C_DECIMAL64 | _Decimal64 |
144+
| C_DECIMAL128 | _Decimal128 |
145+
+----------------+--------------------+
146+
147+
sp13. [if rq13] To the ISO_C_BINDING module, add the following integer
148+
named constants for real KIND parameters:
149+
150+
+----------------+--------------------+
151+
| Named constant | C interchange type |
152+
+----------------+--------------------+
153+
| C_DECIMAL64X | _Decimal64x |
154+
| C_DECIMAL128X | _Decimal128x |
155+
+----------------+--------------------+
156+
157+
sp15. [if rq15] If the companion processor defines additional types of
158+
the form '_FloatN', the processor may add integer named constants
159+
of the form 'C_FLOATN'. If the companion processor defines
160+
additional types of the form '_FloatNx', the processor may add
161+
integer named constants of the form 'C_FLOATNX'. If the companion
162+
processor defines additional types of the form '_FloatN_Complex',
163+
the processor may add integer named constants of the form
164+
'C_FLOATN_COMPLEX'.
165+
166+
sp17. [if rq17] If the companion processor defines additional types of
167+
the form '_DecimalN', the processor may add integer named
168+
constants of the form 'C_DECIMALN'.
169+
170+
=== END ===

0 commit comments

Comments
 (0)