From 21d244f46ebc2facdfc44374abd0aea25e0cfdb0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Steffen=20M=C3=BCthing?= <muething@dune-project.org>
Date: Thu, 22 Aug 2013 17:51:55 +0200
Subject: [PATCH] Add support for MPICH 3.x

MPICH has stepped up its versioning scheme, jumping from MPICH2 1.x
to MPICH 3.x, but has stayed compatible to the older MPICH2 versions.
Unfortunately, the macro MPICH2_VERSION used by mpi_config.m4 to detect
the package has been renamed to MPICH_VERSION.

This patch fixes the problem by adding a separate test for MPICH_VERSION
ana making sure that the macro starts with the letter "3".
---
 m4/mpi-config.m4 | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/m4/mpi-config.m4 b/m4/mpi-config.m4
index 644f4d5d5..b5c5891eb 100644
--- a/m4/mpi-config.m4
+++ b/m4/mpi-config.m4
@@ -5,6 +5,12 @@ mpi_trybuild () {
   return 0
 }
 
+mpi_trybuild_run () {
+  mpi_trybuild "-o conftest ${1}" || return 1
+  ./conftest 2>&1 || return 1
+  return 0
+}
+
 mpi_preprocess () {
   $MPICC -E -c ${1} 2> /dev/null
 }
@@ -177,7 +183,29 @@ _EOF
 
     AC_MSG_RESULT([yes])
     rm -f conftest*
-    return 0    
+    return 0
+  fi
+
+  rm -f conftest*
+  AC_MSG_RESULT([no])
+  return 1
+}
+
+test_mpich3 () {
+  AC_MSG_CHECKING([for mpich 3.x])
+  cat >conftest.c <<_EOF
+#include <mpi.h>
+#include <stdio.h>
+int main() { printf ("%s\n", MPICH_VERSION); return 0; }
+_EOF
+
+  if (mpi_trybuild_run "conftest.c" | grep -q "^3\.") ; then
+    dune_MPI_VERSION="MPICH2"
+    mpi_getmpich2flags
+
+    AC_MSG_RESULT([yes])
+    rm -f conftest*
+    return 0
   fi
 
   rm -f conftest*
@@ -316,6 +344,7 @@ get_mpiparameters() {
   test_mvapich && return
   test_mvapich2 && return
   test_mpich2 && return
+  test_mpich3 && return
   test_ibmmpi && return
   test_intelmpi && return
    
-- 
GitLab