Skip to content

Commit 8495212

Browse files
committed
squashme: temporary commit
Signed-off-by: Howard Pritchard <[email protected]>
1 parent b0e08ca commit 8495212

File tree

2 files changed

+119
-2
lines changed

2 files changed

+119
-2
lines changed

ompi/mpi/c/bindings.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "ompi_config.h"
2626
#include "mpi.h"
2727
#include "ompi/datatype/ompi_datatype.h"
28+
#include "ompi/datatype/ompi_datatype_internal.h"
2829
#include "ompi/info/info.h"
2930

3031
BEGIN_C_DECLS
@@ -123,6 +124,7 @@ int ompi_isendrecv(const void * sendbuf, size_t sendcount, MPI_Datatype sendtype
123124
void * recvbuf, size_t recvcount, MPI_Datatype recvtype, int source, int recvtag, MPI_Comm comm, MPI_Request * request);
124125
int ompi_abi_get_fortran_info(ompi_info_t **info);
125126
int ompi_abi_set_fortran_info(ompi_info_t *info);
127+
int ompi_abi_get_fortran_booleans(int logical_size, void *logical_true, void *logical_false, int *is_set);
126128

127129
END_C_DECLS
128130

ompi/mpi/c/ompi_abi_fortran.c

Lines changed: 117 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,8 @@ int ompi_abi_set_fortran_info(ompi_info_t *info)
321321
* no to any of this setting fortran info stuff.
322322
*/
323323
#if OMPI_BUILD_FORTRAN_BINDINGS
324-
return MPI_ERR_ABI;
325-
#endif
324+
ret = MPI_ERR_ABI;
325+
#else
326326

327327
/*
328328
* dup user supplied fortran info. For now just to
@@ -336,6 +336,121 @@ int ompi_abi_set_fortran_info(ompi_info_t *info)
336336
if (MPI_SUCCESS == ret) {
337337
ompi_mpi_instance_append_finalize (ompi_abi_fortran_finalize);
338338
}
339+
#endif
339340
return ret;
340341

341342
}
343+
344+
int ompi_abi_get_fortran_booleans(int logical_size, void *logical_true, void *logical_false, int *is_set)
345+
{
346+
#if OMPI_HAVE_FORTRAN_LOGICAL
347+
bool unavailable = false;
348+
bool use_int8_t = false, use_int16_t = false, use_int32_t = false, use_int64_t = false;
349+
switch (logical_size) {
350+
case OMPI_SIZEOF_FORTRAN_LOGICAL1:
351+
switch (OMPI_DATATYPE_MPI_LOGICAL1) {
352+
case OMPI_DATATYPE_MPI_INT8_T:
353+
use_int8_t = true;
354+
break;
355+
case OMPI_DATATYPE_MPI_INT16_T:
356+
use_int16_t = true;
357+
break;
358+
case OMPI_DATATYPE_MPI_INT32_T:
359+
use_int32_t = true;
360+
break;
361+
case OMPI_DATATYPE_MPI_INT64_T:
362+
use_int64_t = true;
363+
break;
364+
default:
365+
unavailable = true;
366+
break;
367+
}
368+
case OMPI_SIZEOF_FORTRAN_LOGICAL2:
369+
switch (OMPI_DATATYPE_MPI_LOGICAL2) {
370+
case OMPI_DATATYPE_MPI_INT8_T:
371+
use_int8_t = true;
372+
break;
373+
case OMPI_DATATYPE_MPI_INT16_T:
374+
use_int16_t = true;
375+
break;
376+
case OMPI_DATATYPE_MPI_INT32_T:
377+
use_int32_t = true;
378+
break;
379+
case OMPI_DATATYPE_MPI_INT64_T:
380+
use_int64_t = true;
381+
break;
382+
default:
383+
unavailable = true;
384+
break;
385+
}
386+
case OMPI_SIZEOF_FORTRAN_LOGICAL4:
387+
switch (OMPI_DATATYPE_MPI_LOGICAL4) {
388+
case OMPI_DATATYPE_MPI_INT8_T:
389+
use_int8_t = true;
390+
break;
391+
case OMPI_DATATYPE_MPI_INT16_T:
392+
use_int16_t = true;
393+
break;
394+
case OMPI_DATATYPE_MPI_INT32_T:
395+
use_int32_t = true;
396+
break;
397+
case OMPI_DATATYPE_MPI_INT64_T:
398+
use_int64_t = true;
399+
break;
400+
default:
401+
unavailable = true;
402+
break;
403+
}
404+
case OMPI_SIZEOF_FORTRAN_LOGICAL8:
405+
switch (OMPI_DATATYPE_MPI_LOGICAL8) {
406+
case OMPI_DATATYPE_MPI_INT8_T:
407+
use_int8_t = true;
408+
break;
409+
case OMPI_DATATYPE_MPI_INT16_T:
410+
use_int16_t = true;
411+
break;
412+
case OMPI_DATATYPE_MPI_INT32_T:
413+
use_int32_t = true;
414+
break;
415+
case OMPI_DATATYPE_MPI_INT64_T:
416+
use_int64_t = true;
417+
break;
418+
default:
419+
unavailable = true;
420+
break;
421+
}
422+
default:
423+
unavailable = true;
424+
}
425+
426+
if (true == unavailable) {
427+
*is_set = 0;
428+
} else {
429+
*is_set = 1;
430+
if (true == use_int8_t) {
431+
int8_t *true_ptr = (int8_t *)logical_true;
432+
int8_t *false_ptr = (int8_t *)logical_false;
433+
*true_ptr = (int8_t)OMPI_FORTRAN_VALUE_TRUE;
434+
*false_ptr = (int8_t)OMPI_FORTRAN_VALUE_FALSE;
435+
} else if (true == use_int16_t) {
436+
int16_t *true_ptr = (int16_t *)logical_true;
437+
int16_t *false_ptr = (int16_t *)logical_false;
438+
*true_ptr = (int16_t)OMPI_FORTRAN_VALUE_TRUE;
439+
*false_ptr = (int16_t)OMPI_FORTRAN_VALUE_FALSE;
440+
} else if (true == use_int32_t) {
441+
int32_t *true_ptr = (int32_t *)logical_true;
442+
int32_t *false_ptr = (int32_t *)logical_false;
443+
*true_ptr = (int32_t)OMPI_FORTRAN_VALUE_TRUE;
444+
*false_ptr = (int32_t)OMPI_FORTRAN_VALUE_FALSE;
445+
} else if (true == use_int64_t) {
446+
int64_t *true_ptr = (int64_t *)logical_true;
447+
int64_t *false_ptr = (int64_t *)logical_false;
448+
*true_ptr = (int64_t)OMPI_FORTRAN_VALUE_TRUE;
449+
*false_ptr = (int64_t)OMPI_FORTRAN_VALUE_FALSE;
450+
}
451+
}
452+
#else
453+
*is_set = 0;
454+
#endif /* OMPI_HAVE_FORTRAN_LOGICAL */
455+
return MPI_SUCCESS;
456+
}

0 commit comments

Comments
 (0)