cmake/Modules/FindMPI/test_mpi.c

39 lines
920 B
C
Raw Normal View History

2018-01-26 17:06:56 +01:00
#include <mpi.h>
#ifdef __cplusplus
2018-08-09 18:06:22 +02:00
# include <cstdio>
2018-01-26 17:06:56 +01:00
#else
2018-08-09 18:06:22 +02:00
# include <stdio.h>
2018-01-26 17:06:56 +01:00
#endif
#if defined(MPI_VERSION) && defined(MPI_SUBVERSION)
2022-03-29 21:10:50 +02:00
static const char mpiver_str[] = { 'I', 'N',
2021-11-20 13:41:27 +01:00
'F', 'O',
':', 'M',
'P', 'I',
'-', 'V',
'E', 'R',
'[', ('0' + MPI_VERSION),
'.', ('0' + MPI_SUBVERSION),
']', '\0' };
2018-01-26 17:06:56 +01:00
#endif
int main(int argc, char* argv[])
{
#if defined(MPI_VERSION) && defined(MPI_SUBVERSION)
2018-08-09 18:06:22 +02:00
# ifdef __cplusplus
2018-01-26 17:06:56 +01:00
std::puts(mpiver_str);
2018-08-09 18:06:22 +02:00
# else
2018-01-26 17:06:56 +01:00
puts(mpiver_str);
2018-08-09 18:06:22 +02:00
# endif
2018-01-26 17:06:56 +01:00
#endif
#ifdef TEST_MPI_MPICXX
MPI::MPI_Init(&argc, &argv);
MPI::MPI_Finalize();
#else
MPI_Init(&argc, &argv);
MPI_Finalize();
#endif
2019-11-11 23:01:05 +01:00
return 0;
2018-01-26 17:06:56 +01:00
}