From 5b8a375bd998eaebcb68991b02fa0fecea7f38b7 Mon Sep 17 00:00:00 2001
From: Markus Blatt <markus@dr-blatt.de>
Date: Mon, 28 Apr 2014 17:42:37 +0200
Subject: [PATCH] [bugfix] Fix macros for the case that HAVE_METIS is not
 defined.

For HAVE_METIS we do not use the ENABLE trick. It is therefore either defined or
not. Therfore using "#if HAVE_METIS" is a bug. This patch fixes this.
---
 dune/istl/repartition.hh | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/dune/istl/repartition.hh b/dune/istl/repartition.hh
index a4e23b4d..2ec86bf0 100644
--- a/dune/istl/repartition.hh
+++ b/dune/istl/repartition.hh
@@ -10,7 +10,7 @@
 #if HAVE_PARMETIS
 #include <parmetis.h>
 #endif
-#if defined(METISNAMEL) && HAVE_METIS
+#if defined(METISNAMEL) && defined(HAVE_METIS)
 // METISNAMEL is defined when scotch is used and according to christian
 // we have to include the metis header in this case.
 #include <metis.h>
@@ -757,12 +757,18 @@ namespace Dune
                           Dune::OwnerOverlapCopyCommunication<T1,T2>*& outcomm,
                           RedistributeInterface& redistInf,
                           bool verbose=false);
-#if HAVE_PARMETIS && (!defined(METISNAMEL) || HAVE_METIS)
-  extern "C" {
-    // backwards compatibility to parmetis < 4.0.0
+#if HAVE_PARMETIS
 #if PARMETIS_MAJOR_VERSION > 3
     typedef idx_t idxtype;
+#elif defined(METISNAMEL)
+    typedef int idxtype;
+#else
+    typedef std::size_t idxtype;
 #endif
+#if !defined(METISNAMEL) || !defined(HAVE_METIS)
+  extern "C"
+  {
+    // backwards compatibility to parmetis < 4.0.0
     void METIS_PartGraphKway(int *nvtxs, idxtype *xadj, idxtype *adjncy, idxtype *vwgt,
                              idxtype *adjwgt, int *wgtflag, int *numflag, int *nparts,
                              int *options, int *edgecut, idxtype *part);
@@ -771,8 +777,7 @@ namespace Dune
                                   idxtype *adjwgt, int *wgtflag, int *numflag, int *nparts,
                                   int *options, int *edgecut, idxtype *part);
   }
-#else
-  typedef std::size_t idxtype;
+#endif
 #endif
 
   template<class S, class T>
@@ -835,7 +840,7 @@ namespace Dune
                <<" to "<<nparts<<" parts"<<std::endl;
     Timer time;
     int rank = oocomm.communicator().rank();
-#if !HAVE_PARMETIS || (defined(METISNAMEL) && !HAVE_METIS)
+#if !HAVE_PARMETIS || (defined(METISNAMEL) && !defined(HAVE_METIS))
     int* part = new int[1];
     part[0]=0;
 #else
@@ -1276,7 +1281,7 @@ namespace Dune
     // Global communications are necessary
     // The parmetis global identifiers for the owner vertices.
     ParmetisDuneIndexMap indexMap(graph,oocomm);
-#if HAVE_PARMETIS && (!defined(METISNAMEL) || HAVE_METIS)
+#if HAVE_PARMETIS && (!defined(METISNAMEL) || defined(HAVE_METIS))
     idxtype *part = new idxtype[indexMap.numOfOwnVtx()];
 #else
     std::size_t *part = new std::size_t[indexMap.numOfOwnVtx()];
@@ -1284,7 +1289,7 @@ namespace Dune
     for(std::size_t i=0; i < indexMap.numOfOwnVtx(); ++i)
       part[i]=mype;
 
-#if !HAVE_PARMETIS || (defined(METISNAMEL) && !HAVE_METIS)
+#if !HAVE_PARMETIS || (defined(METISNAMEL) && !defined(HAVE_METIS))
     if(oocomm.communicator().rank()==0 && nparts>1)
       std::cerr<<"ParMETIS not activated. Will repartition to 1 domain instead of requested "
                <<nparts<<" domains."<<std::endl;
-- 
GitLab