1dnl  This file is part of MED.
2dnl
3dnl  COPYRIGHT (C) 1999 - 2019  EDF R&D, CEA/DEN
4dnl  MED is free software: you can redistribute it and/or modify
5dnl  it under the terms of the GNU Lesser General Public License as published by
6dnl  the Free Software Foundation, either version 3 of the License, or
7dnl  (at your option) any later version.
8dnl
9dnl  MED is distributed in the hope that it will be useful,
10dnl  but WITHOUT ANY WARRANTY; without even the implied warranty of
11dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12dnl  GNU Lesser General Public License for more details.
13dnl
14dnl  You should have received a copy of the GNU Lesser General Public License
15dnl  along with MED.  If not, see <http://www.gnu.org/licenses/>.
16dnl
17
18dnl Ceci ne fonctionne pas car necessite le checkprogcc !
19dnl AC_CHECK_DECL([H5_HAVE_PARALLEL],
20dnl  [
21dnl  ],
22dnl  [
23dnl  ],
24dnl  [[#include <H5pubconf.h>]]
25dnl   ],[])
26dnl )
27
28dnl Ceci ne fonctionne pas car necessite le checkprogcc !
29dnl AC_EGREP_CPP ([MED_CATCH_H5_HAVE_PARALLEL],
30dnl [AC_LANG_PUSH([C])
31dnl  AC_LANG_CONFTEST([AC_LANG_SOURCE([[
32dnl \#ifdef H5_HAVE_PARALLEL
33dnl \#warning "MED_CATCH_H5_HAVE_PARALLEL"
34dnl \#else
35dnl \#error "I'M SO SORRY"
36dnl \#endif
37dnl ]]))]
38dnl  AC_LANG_POP
39dnl ],
40dnl [mpi_wanted_test="yes"],
41dnl [mpi_wanted_test="no"])
42
43# This function use H5pubconf.h to detect serial/parallel version of hdf found in ${hdf5include}.
44# No compiling is used within the test
45AC_DEFUN([_MED_BEFORE_CC_MPI], [
46AC_REQUIRE([AC_PROG_SED])
47
48if test "x`sed -n '/^#define *H5_HAVE_PARALLEL *1\{0,1\}/{s/.*/MED_CATCH_H5_HAVE_PARALLEL/p;}' ${hdf5include}/H5pubconf.h`" = "xMED_CATCH_H5_HAVE_PARALLEL"
49then
50 mpi_wanted_test="yes"
51else
52 mpi_wanted_test="no"
53fi
54])
55
56# If hdf5 is parallel we have to find mpicc frontend
57AC_DEFUN([_MED_CALLING_CC_MPI], [
58AC_REQUIRE([_MED_BEFORE_CC_MPI])
59
60AX_PROG_CC_MPI(test "x$mpi_wanted_test" = "xyes",[],[
61  if test x"$mpi_wanted_test" = xyes; then
62    AC_MSG_FAILURE([MPI CC compiler requested, but couldn't use it.])
63  fi
64])
65])
66
67# This macro test if hdf5 is a parallel version, then
68# call for mpi C/F compiler frontend detection, set WITHPMED conditionnal, substitute BUILD_WITH_PMED with yes or no and add a MED_HAVE_MPI define in med_config.h
69AC_DEFUN([MED_ENABLE_PMED],dnl
70[
71AC_REQUIRE([_MED_CALLING_CC_MPI])
72#We must check if the user want the Fortran interface
73#before testing a mpi fortran frontend
74#On devrait pouvoir le désactiver ici car il a été
75#requis ds le check f90
76AC_REQUIRE([_MED_DEFINE_F77_ENABLE])
77
78#The parallel fortran test must have a f90 compiler if fortran interface is activated
79MED_CHECK_F90
80
81if test "x$mpi_wanted_test" = "xyes"
82then
83 AM_CONDITIONAL([WITHPMED],[ true ])
84
85#Mécanisme pour exporter le #define MED_HAVE_MPI
86#dans med.h.in et non dans med_config.h.in
87 MED_DEFINE_MED_HAVE_MPI="#define MED_HAVE_MPI"
88 BUILD_WITH_PMED="yes"
89else
90 BUILD_WITH_PMED="no"
91 AC_MSG_NOTICE([HDF version is not a parallel one.])
92 AM_CONDITIONAL([WITHPMED],[ false ])
93fi
94 AC_SUBST(MED_DEFINE_MED_HAVE_MPI)
95 AC_SUBST(BUILD_WITH_PMED)
96])
97