|
| 1 | +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ |
| 2 | +/* |
| 3 | + * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana |
| 4 | + * University Research and Technology |
| 5 | + * Corporation. All rights reserved. |
| 6 | + * Copyright (c) 2004-2020 The University of Tennessee and The University |
| 7 | + * of Tennessee Research Foundation. All rights |
| 8 | + * reserved. |
| 9 | + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, |
| 10 | + * University of Stuttgart. All rights reserved. |
| 11 | + * Copyright (c) 2004-2005 The Regents of the University of California. |
| 12 | + * All rights reserved. |
| 13 | + * Copyright (c) 2015 Research Organization for Information Science |
| 14 | + * and Technology (RIST). All rights reserved. |
| 15 | + * Copyright (c) 2018-2025 Triad National Security, LLC. All rights |
| 16 | + * reserved. |
| 17 | + * $COPYRIGHT$ |
| 18 | + * |
| 19 | + * Additional copyrights may follow |
| 20 | + * |
| 21 | + * $HEADER$ |
| 22 | + */ |
| 23 | + |
| 24 | +#include "ompi_config.h" |
| 25 | + |
| 26 | +#include "ompi/mpi/c/bindings.h" |
| 27 | +#include "ompi/runtime/params.h" |
| 28 | +#include "ompi/communicator/communicator.h" |
| 29 | +#include "ompi/errhandler/errhandler.h" |
| 30 | +#include "ompi/info/info.h" |
| 31 | + |
| 32 | +PROTOTYPE ERROR_CLASS abi_get_fortran_info(INFO_OUT info) |
| 33 | +{ |
| 34 | + char tmp[16]; |
| 35 | + ompi_info_t *newinfo = NULL; |
| 36 | + const char true_str[]="true"; |
| 37 | + const char false_str[]="false"; |
| 38 | + const char *cptr; |
| 39 | + int ret = MPI_SUCCESS; |
| 40 | + |
| 41 | + if (MPI_PARAM_CHECK) { |
| 42 | + if (NULL == info) { |
| 43 | + return OMPI_ERRHANDLER_NOHANDLE_INVOKE(MPI_ERR_INFO, |
| 44 | + FUNC_NAME); |
| 45 | + } |
| 46 | + } |
| 47 | + |
| 48 | +#if OMPI_BUILD_FORTRAN_BINDINGS |
| 49 | + |
| 50 | + *info = ompi_info_allocate (); |
| 51 | + if (NULL == (*info)) { |
| 52 | + return OMPI_ERRHANDLER_NOHANDLE_INVOKE(MPI_ERR_NO_MEM, |
| 53 | + FUNC_NAME); |
| 54 | + } |
| 55 | + |
| 56 | + |
| 57 | +#if OMPI_SIZEOF_FORTRAN_LOGICAL |
| 58 | + snprintf(tmp, 16, "%d", OMPI_SIZEOF_FORTRAN_LOGICAL); |
| 59 | + ret = opal_info_set(&newinfo->super, "mpi_logical_size", tmp); |
| 60 | + if (OPAL_SUCCESS != ret) { |
| 61 | + goto err_cleanup; |
| 62 | + } |
| 63 | +#endif |
| 64 | + |
| 65 | +#if OMPI_SIZEOF_FORTRAN_INTEGER |
| 66 | + snprintf(tmp, 16, "%d", OMPI_SIZEOF_FORTRAN_INTEGER); |
| 67 | + ret = opal_info_set(&newinfo->super, "mpi_integer_size", tmp); |
| 68 | + if (OPAL_SUCCESS != ret) { |
| 69 | + goto err_cleanup; |
| 70 | + } |
| 71 | +#endif |
| 72 | + |
| 73 | +#if OMPI_SIZEOF_FORTRAN_REAL |
| 74 | + snprintf(tmp, 16, "%d", OMPI_SIZEOF_FORTRAN_REAL); |
| 75 | + ret = opal_info_set(&newinfo->super, "mpi_real_size", tmp); |
| 76 | + if (OPAL_SUCCESS != ret) { |
| 77 | + goto err_cleanup; |
| 78 | + } |
| 79 | +#endif |
| 80 | + |
| 81 | +#if OMPI_SIZEOF_FORTRAN_DOUBLE_PRECISION |
| 82 | + snprintf(tmp, 16, "%d", OMPI_SIZEOF_FORTRAN_DOUBLE_PRECISION); |
| 83 | + ret = opal_info_set(&newinfo->super, "mpi_double_precision_size", tmp); |
| 84 | + if (OPAL_SUCCESS != ret) { |
| 85 | + goto err_cleanup; |
| 86 | + } |
| 87 | +#endif |
| 88 | + |
| 89 | +#if OMPI_SIZEOF_FORTRAN_LOGICAL1 |
| 90 | + cptr = true_str; |
| 91 | +#else |
| 92 | + cptr = false_str; |
| 93 | +#endif |
| 94 | + ret = opal_info_set(&newinfo->super, "mpi_logical1_supported", cptr); |
| 95 | + if (OPAL_SUCCESS != ret) { |
| 96 | + goto err_cleanup; |
| 97 | + } |
| 98 | + |
| 99 | +#if OMPI_SIZEOF_FORTRAN_LOGICAL2 |
| 100 | + cptr = true_str; |
| 101 | +#else |
| 102 | + cptr = false_str; |
| 103 | +#endif |
| 104 | + ret = opal_info_set(&newinfo->super, "mpi_logical2_supported", cptr); |
| 105 | + if (OPAL_SUCCESS != ret) { |
| 106 | + goto err_cleanup; |
| 107 | + } |
| 108 | + |
| 109 | +#if OMPI_SIZEOF_FORTRAN_LOGICAL4 |
| 110 | + cptr = true_str; |
| 111 | +#else |
| 112 | + cptr = false_str; |
| 113 | +#endif |
| 114 | + ret = opal_info_set(&newinfo->super, "mpi_logical4_supported", cptr); |
| 115 | + if (OPAL_SUCCESS != ret) { |
| 116 | + goto err_cleanup; |
| 117 | + } |
| 118 | + |
| 119 | +#if OMPI_SIZEOF_FORTRAN_LOGICAL8 |
| 120 | + cptr = true_str; |
| 121 | +#else |
| 122 | + cptr = false_str; |
| 123 | +#endif |
| 124 | + ret = opal_info_set(&newinfo->super, "mpi_logical8_supported", cptr); |
| 125 | + if (OPAL_SUCCESS != ret) { |
| 126 | + goto err_cleanup; |
| 127 | + } |
| 128 | + |
| 129 | +#if OMPI_SIZEOF_FORTRAN_LOGICAL16 |
| 130 | + cptr = true_str; |
| 131 | +#else |
| 132 | + cptr = false_str; |
| 133 | +#endif |
| 134 | + ret = opal_info_set(&newinfo->super, "mpi_logical16_supported", cptr); |
| 135 | + if (OPAL_SUCCESS != ret) { |
| 136 | + goto err_cleanup; |
| 137 | + } |
| 138 | + |
| 139 | +#if OMPI_SIZEOF_FORTRAN_INTEGER1 |
| 140 | + cptr = true_str; |
| 141 | +#else |
| 142 | + cptr = false_str; |
| 143 | +#endif |
| 144 | + ret = opal_info_set(&newinfo->super, "mpi_integer1_supported", cptr); |
| 145 | + if (OPAL_SUCCESS != ret) { |
| 146 | + goto err_cleanup; |
| 147 | + } |
| 148 | + |
| 149 | +#if OMPI_SIZEOF_FORTRAN_INTEGER2 |
| 150 | + cptr = true_str; |
| 151 | +#else |
| 152 | + cptr = false_str; |
| 153 | +#endif |
| 154 | + ret = opal_info_set(&newinfo->super, "mpi_integer2_supported", cptr); |
| 155 | + if (OPAL_SUCCESS != ret) { |
| 156 | + goto err_cleanup; |
| 157 | + } |
| 158 | + |
| 159 | +#if OMPI_SIZEOF_FORTRAN_INTEGER4 |
| 160 | + cptr = true_str; |
| 161 | +#else |
| 162 | + cptr = false_str; |
| 163 | +#endif |
| 164 | + ret = opal_info_set(&newinfo->super, "mpi_integer4_supported", cptr); |
| 165 | + if (OPAL_SUCCESS != ret) { |
| 166 | + goto err_cleanup; |
| 167 | + } |
| 168 | + |
| 169 | +#if OMPI_SIZEOF_FORTRAN_INTEGER8 |
| 170 | + cptr = true_str; |
| 171 | +#else |
| 172 | + cptr = false_str; |
| 173 | +#endif |
| 174 | + ret = opal_info_set(&newinfo->super, "mpi_integer8_supported", cptr); |
| 175 | + if (OPAL_SUCCESS != ret) { |
| 176 | + goto err_cleanup; |
| 177 | + } |
| 178 | + |
| 179 | +#if OMPI_SIZEOF_FORTRAN_INTEGER16 |
| 180 | + cptr = true_str; |
| 181 | +#else |
| 182 | + cptr = false_str; |
| 183 | +#endif |
| 184 | + ret = opal_info_set(&newinfo->super, "mpi_integer16_supported", cptr); |
| 185 | + if (OPAL_SUCCESS != ret) { |
| 186 | + goto err_cleanup; |
| 187 | + } |
| 188 | + |
| 189 | +#if OMPI_SIZEOF_FORTRAN_REAL4 |
| 190 | + cptr = true_str; |
| 191 | +#else |
| 192 | + cptr = false_str; |
| 193 | +#endif |
| 194 | + ret = opal_info_set(&newinfo->super, "mpi_real2_supported", cptr); |
| 195 | + if (OPAL_SUCCESS != ret) { |
| 196 | + goto err_cleanup; |
| 197 | + } |
| 198 | + |
| 199 | +#if OMPI_SIZEOF_FORTRAN_REAL4 |
| 200 | + cptr = true_str; |
| 201 | +#else |
| 202 | + cptr = false_str; |
| 203 | +#endif |
| 204 | + ret = opal_info_set(&newinfo->super, "mpi_real4_supported", cptr); |
| 205 | + if (OPAL_SUCCESS != ret) { |
| 206 | + goto err_cleanup; |
| 207 | + } |
| 208 | + |
| 209 | +#if OMPI_SIZEOF_FORTRAN_REAL8 |
| 210 | + cptr = true_str; |
| 211 | +#else |
| 212 | + cptr = false_str; |
| 213 | +#endif |
| 214 | + ret = opal_info_set(&newinfo->super, "mpi_real8_supported", cptr); |
| 215 | + if (OPAL_SUCCESS != ret) { |
| 216 | + goto err_cleanup; |
| 217 | + } |
| 218 | + |
| 219 | +#if OMPI_SIZEOF_FORTRAN_REAL16 |
| 220 | + cptr = true_str; |
| 221 | +#else |
| 222 | + cptr = false_str; |
| 223 | +#endif |
| 224 | + ret = opal_info_set(&newinfo->super, "mpi_real16_supported", cptr); |
| 225 | + if (OPAL_SUCCESS != ret) { |
| 226 | + goto err_cleanup; |
| 227 | + } |
| 228 | + |
| 229 | +#if OMPI_SIZEOF_FORTRAN_COMPLEX4 |
| 230 | + cptr = true_str; |
| 231 | +#else |
| 232 | + cptr = false_str; |
| 233 | +#endif |
| 234 | + ret = opal_info_set(&newinfo->super, "mpi_complex4_supported", cptr); |
| 235 | + if (OPAL_SUCCESS != ret) { |
| 236 | + goto err_cleanup; |
| 237 | + } |
| 238 | + |
| 239 | +#if OMPI_SIZEOF_FORTRAN_COMPLEX8 |
| 240 | + cptr = true_str; |
| 241 | +#else |
| 242 | + cptr = false_str; |
| 243 | +#endif |
| 244 | + ret = opal_info_set(&newinfo->super, "mpi_complex8_supported", cptr); |
| 245 | + if (OPAL_SUCCESS != ret) { |
| 246 | + goto err_cleanup; |
| 247 | + } |
| 248 | + |
| 249 | +#if OMPI_SIZEOF_FORTRAN_COMPLEX16 |
| 250 | + cptr = true_str; |
| 251 | +#else |
| 252 | + cptr = false_str; |
| 253 | +#endif |
| 254 | + ret = opal_info_set(&newinfo->super, "mpi_complex16_supported", cptr); |
| 255 | + if (OPAL_SUCCESS != ret) { |
| 256 | + goto err_cleanup; |
| 257 | + } |
| 258 | + |
| 259 | +#if OMPI_SIZEOF_FORTRAN_COMPLEX32 |
| 260 | + cptr = true_str; |
| 261 | +#else |
| 262 | + cptr = false_str; |
| 263 | +#endif |
| 264 | + ret = opal_info_set(&newinfo->super, "mpi_complex32_supported", cptr); |
| 265 | + if (OPAL_SUCCESS != ret) { |
| 266 | + goto err_cleanup; |
| 267 | + } |
| 268 | + |
| 269 | +#if OMPI_SIZEOF_FORTRAN_DOUBLE_COMPLEX |
| 270 | + cptr = true_str; |
| 271 | +#else |
| 272 | + cptr = false_str; |
| 273 | +#endif |
| 274 | + ret = opal_info_set(&newinfo->super, "mpi_double_complex_supported", cptr); |
| 275 | + if (OPAL_SUCCESS != ret) { |
| 276 | + goto err_cleanup; |
| 277 | + } |
| 278 | + |
| 279 | + *info = newinfo; |
| 280 | + |
| 281 | +#else |
| 282 | + |
| 283 | + *info = MPI_INFO_NULL; |
| 284 | + |
| 285 | +#endif /* OMPI_BUILD_FORTRAN_BINDINGS */ |
| 286 | + |
| 287 | + return ret; |
| 288 | + |
| 289 | +err_cleanup: |
| 290 | + ompi_info_free(&newinfo); |
| 291 | + return ret; |
| 292 | + |
| 293 | + return MPI_SUCCESS; |
| 294 | +} |
0 commit comments