@@ -8,8 +8,7 @@ Date: 2023-12-29
8
8
9
9
The proposal is to allow a complex pointer to be associated to a real
10
10
array, and similarly to allow a real pointer to be associated to a
11
- complex scalar or array. Going further, this could be extended to
12
- argument association between entities of type real and complex.
11
+ complex scalar or array.
13
12
14
13
2. Motivation
15
14
@@ -88,9 +87,9 @@ used, with additional rules and restrictions:
88
87
- `c` can also be a complex scalar pointer, in the case where r is a
89
88
rank-1 array of size 2
90
89
- the size of the first dimension of `r` shall be even
91
- - `c%re` refers to the same storage than `r(1::2)` (rank-1), or
90
+ - `c%re` refers to the same storage as `r(1::2)` (rank-1), or
92
91
`r(1::2,:)` (rank-2), etc...
93
- - `c%im` refers to the same storage than `r(2::2)` (rank-1), or
92
+ - `c%im` refers to the same storage as `r(2::2)` (rank-1), or
94
93
`r(2::2,:)` (rank-2), etc...
95
94
96
95
`r => c`
@@ -106,8 +105,7 @@ used, with additional rules and restrictions:
106
105
3.2 Alternative syntaxes
107
106
108
107
If one wants to make the association between two different types more
109
- explicit, also catching possible mistakes at compile time, a new
110
- syntax may be introduced:
108
+ explicit and more type-safe, a new syntax may be introduced:
111
109
112
110
Alternative syntax 1:
113
111
```
@@ -127,24 +125,14 @@ c => complex :: r
127
125
r => real :: c
128
126
```
129
127
130
- 4. Argument association
128
+ Something generic (that is, not `complex_pointer()` or `real_pointer()`)
129
+ may be desirable in case other inter-type pointer association would be
130
+ allowed in future versions of the standard.
131
131
132
- For full consistency, argument association between the real and
133
- complex types of the same kind could (or should?) be allowed, without
134
- having to use intermediate pointers. For, if pointer association
135
- is possible and allowed, the argument association is also possible
136
- with the exact same rules and restrictions (contiguity, etc...).
137
132
138
- Should the argument association be allowed, then the default pointer
139
- association syntax should be kept, without considering the alternative
140
- syntaxes. The main added value of the alternative syntaxes is to allow
141
- an additional check at compile time (that the association between two
142
- different type is really intentional): not only this is not critical,
143
- but this check cannot be performed with the argument association.
133
+ 4. Issues / Objections / Limitations
144
134
145
- 5. Objections
146
-
147
- 5.1. Memory layout
135
+ 4.1. Memory layout
148
136
149
137
This proposal would constraint the memory layout of the complex type
150
138
beyond what the current standard does. However, the required layout
@@ -166,10 +154,28 @@ such a layout is possible at all). In this layout, a complex array is
166
154
stored with all the real parts first, then all the imaginary parts.
167
155
In this case, `c%re` would refer to the same storage as `r(1:n/2)`.
168
156
169
- 6. References
157
+ 4.2. Argument association
158
+
159
+ Allowing a real actual argument to be associated to a complex dummy
160
+ argument -and vice-versa- has also been considered, but it would raise
161
+ backward compatibility issues. So this part has been dropped.
162
+
163
+ 4.3. Alignment
164
+
165
+ Considering for instance a default real type stored on 4 bytes, the
166
+ default complex type is stored on 8 bytes. Compilers may prefer/want to
167
+ align complex arrays on 16 bytes boundaries, which cannot be guaranteed
168
+ if a complex pointer is associated to an arbitrary real array
169
+ (e.g. `c => r(2:)`). If this is a problem, the pointer association may be
170
+ allowed only in the other way (real pointer associated to a complex array).
171
+
172
+
173
+ 5. References
170
174
171
175
Fortran Discourse Forum:
172
176
https://fortran-lang.discourse.group/t/complex-type-storage-again/7020
177
+ https://fortran-lang.discourse.group/t/implicit-real-complex-conversion-in-fortran/7381
173
178
174
179
Fortran Proposal Github:
175
180
https://github.com/j3-fortran/fortran_proposals/issues/323
181
+ https://github.com/j3-fortran/fortran_proposals/pull/325
0 commit comments