|
11 | 11 | * All rights reserved. |
12 | 12 | * Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved. |
13 | 13 | * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved. |
14 | | - * Copyright (c) 2014 Research Organization for Information Science |
15 | | - * and Technology (RIST). All rights reserved. |
| 14 | + * Copyright (c) 2014-2019 Research Organization for Information Science |
| 15 | + * and Technology (RIST). All rights reserved. |
16 | 16 | * $COPYRIGHT$ |
17 | 17 | * |
18 | 18 | * Additional copyrights may follow |
|
161 | 161 |
|
162 | 162 | /* |
163 | 163 | * Define MACROS to take account of different size of logical from int |
| 164 | + * |
| 165 | + * There used to be an in-place option for the below conversions of |
| 166 | + * logical arrays. So if mpi_cart_create(..., periods, ...) took an |
| 167 | + * input array of Fortran logicals, it would walk the array converting |
| 168 | + * the elements to C-logical values, then at the end it would restore |
| 169 | + * the values back to Fortran logicals. |
| 170 | + * |
| 171 | + * The problem with that is periods is an INPUT argument and some |
| 172 | + * Fortran compilers even put it in read-only memory because of that. |
| 173 | + * So writing to it wasn't generally okay, even though we were restoring it |
| 174 | + * before returning. |
| 175 | + * |
| 176 | + * The in-place option is hence only valid if no conversion is ever needed |
| 177 | + * (e.g. Fortran logical and C int have the same size *and** Fortran logical |
| 178 | + * .TRUE. value is 1 in C. |
164 | 179 | */ |
165 | 180 |
|
166 | | -#if OMPI_SIZEOF_FORTRAN_LOGICAL == SIZEOF_INT |
| 181 | +#if (OMPI_SIZEOF_FORTRAN_LOGICAL == SIZEOF_INT) && (OMPI_FORTRAN_VALUE_TRUE == 1) |
167 | 182 | # define OMPI_LOGICAL_NAME_DECL(in) /* Not needed for int==logical */ |
168 | 183 | # define OMPI_LOGICAL_NAME_CONVERT(in) in /* Not needed for int==logical */ |
169 | 184 | # define OMPI_LOGICAL_SINGLE_NAME_CONVERT(in) in /* Not needed for int==logical */ |
|
172 | 187 | # define OMPI_ARRAY_LOGICAL_2_INT_ALLOC(in,n) /* Not needed for int==logical */ |
173 | 188 | # define OMPI_ARRAY_LOGICAL_2_INT_CLEANUP(in) /* Not needed for int==logical */ |
174 | 189 |
|
175 | | -# if OMPI_FORTRAN_VALUE_TRUE == 1 |
176 | | -# define OMPI_FORTRAN_MUST_CONVERT_LOGICAL_2_INT 0 |
177 | | -# define OMPI_LOGICAL_2_INT(a) a |
178 | | -# define OMPI_INT_2_LOGICAL(a) a |
179 | | -# define OMPI_ARRAY_LOGICAL_2_INT(in, n) |
180 | | -# define OMPI_ARRAY_INT_2_LOGICAL(in, n) |
181 | | -# define OMPI_SINGLE_INT_2_LOGICAL(a) /* Single-OUT variable -- Not needed for int==logical, true=1 */ |
182 | | -# else |
183 | | -# define OMPI_FORTRAN_MUST_CONVERT_LOGICAL_2_INT 1 |
184 | | -# define OMPI_LOGICAL_2_INT(a) ((a)==0? 0 : 1) |
185 | | -# define OMPI_INT_2_LOGICAL(a) ((a)==0? 0 : OMPI_FORTRAN_VALUE_TRUE) |
186 | | -# define OMPI_SINGLE_INT_2_LOGICAL(a) *a=OMPI_INT_2_LOGICAL(OMPI_LOGICAL_NAME_CONVERT(*a)) |
187 | | -# define OMPI_ARRAY_LOGICAL_2_INT(in, n) do { \ |
188 | | - int converted_n = (int)(n); \ |
189 | | - OMPI_ARRAY_LOGICAL_2_INT_ALLOC(in, converted_n + 1); \ |
190 | | - while (--converted_n >= 0) { \ |
191 | | - OMPI_LOGICAL_ARRAY_NAME_CONVERT(in)[converted_n]=OMPI_LOGICAL_2_INT(in[converted_n]); \ |
192 | | - } \ |
193 | | - } while (0) |
194 | | -# define OMPI_ARRAY_INT_2_LOGICAL(in, n) do { \ |
195 | | - int converted_n = (int)(n); \ |
196 | | - while (--converted_n >= 0) { \ |
197 | | - in[converted_n]=OMPI_INT_2_LOGICAL(OMPI_LOGICAL_ARRAY_NAME_CONVERT(in)[converted_n]); \ |
198 | | - } \ |
199 | | - OMPI_ARRAY_LOGICAL_2_INT_CLEANUP(in); \ |
200 | | - } while (0) |
201 | | - |
202 | | -# endif |
| 190 | +# define OMPI_FORTRAN_MUST_CONVERT_LOGICAL_2_INT 0 |
| 191 | +# define OMPI_LOGICAL_2_INT(a) a |
| 192 | +# define OMPI_INT_2_LOGICAL(a) a |
| 193 | +# define OMPI_ARRAY_LOGICAL_2_INT(in, n) |
| 194 | +# define OMPI_ARRAY_INT_2_LOGICAL(in, n) |
| 195 | +# define OMPI_SINGLE_INT_2_LOGICAL(a) /* Single-OUT variable -- Not needed for int==logical, true=1 */ |
203 | 196 | #else |
204 | 197 | /* |
205 | | - * For anything other than Fortran-logical == C-int, we have to convert |
| 198 | + * For anything other than Fortran-logical == C-int or some .TRUE. is not 1 in C, we have to convert |
206 | 199 | */ |
207 | 200 | # define OMPI_FORTRAN_MUST_CONVERT_LOGICAL_2_INT 1 |
208 | 201 | # define OMPI_LOGICAL_NAME_DECL(in) int c_##in |
|
238 | 231 | } \ |
239 | 232 | OMPI_ARRAY_LOGICAL_2_INT_CLEANUP(in); \ |
240 | 233 | } while (0) |
241 | | -#endif /* OMPI_SIZEOF_FORTRAN_LOGICAL */ |
| 234 | +#endif /* OMPI_SIZEOF_FORTRAN_LOGICAL && OMPI_FORTRAN_VALUE_TRUE */ |
242 | 235 |
|
243 | 236 |
|
244 | 237 | #endif /* OMPI_FORTRAN_BASE_FINT_2_INT_H */ |
0 commit comments