From 920ca1b077d737990ce609381c26acdd28e5ecc3 Mon Sep 17 00:00:00 2001
From: Pietro Incardona <i-bird@localhost.localdomain>
Date: Thu, 11 Aug 2016 02:29:06 +0200
Subject: [PATCH] Fixing MPI installation

---
 install        | 15 ++-------------
 script/set_mpi | 17 ++++++++---------
 2 files changed, 10 insertions(+), 22 deletions(-)

diff --git a/install b/install
index 2e03cbfe..fe9aff2c 100755
--- a/install
+++ b/install
@@ -201,9 +201,6 @@ if [ -d "$i_dir/EIGEN" ]; then
     configure_options=" $configure_options --with-eigen=$i_dir/EIGEN "
     lin_alg_inc="$lin_alg_inc -I$i_dir/EIGEN"
 fi
-if [ -d "$i_dir/MPI" ]; then
-    configure_options="$configure_options CXX=mpic++ "
-fi
 if [ -d "$i_dir/METIS" ]; then
     configure_options=" $configure_options --with-metis=$i_dir/METIS "
 fi
@@ -226,14 +223,6 @@ if [ x"$platform" = x"linux" ]; then
 	lin_alg_lib="$lin_alg_lib -lrt"
 fi
 
-### MPI
-
-if [ x"$MPI_valid" == x"yes" ]; then
-	configure_options="$configure_options CXX=mpic++ "
-else
-	./script/install_MPI.sh $i_dir $ncore
-fi
-
 ### MPI compilers must be in your PATH folder
 
 set_mpi $i_dir
@@ -281,7 +270,7 @@ else
             fi
             ./script/install_MPI.sh $i_dir $ncore
             MPI_installed=1
-            export PATH="$PATH:$i_dir/MPI/bin"
+            export PATH="$i_dir/MPI/bin:$PATH"
             configure_options="$configure_options CXX=mpic++ "
         elif [ $conf_err -eq 201  ]; then
             echo "Metis not found try to install"
@@ -387,7 +376,7 @@ echo ""
 
 if [ -d "$i_dir/MPI" ]; then
   installation_report="$installation_report \033[92;1mMPI\033[0m Installed: \033[1m $i_dir/MPI \033[0m\n"
-  bash_path="$bash_path:$i_dir/MPI/bin"
+  bash_path="$i_dir/MPI/bin:$bash_path"
   bash_library="$bash_library:$i_dir/MPI/lib"
 elif [ $MPI_System_prv -eq 1 ]; then
   installation_report="$installation_report \033[92;1mMPI\033[0m Installed: \033[1m System installation \033[0m\n"
diff --git a/script/set_mpi b/script/set_mpi
index c0cd4d0b..0bc7d554 100755
--- a/script/set_mpi
+++ b/script/set_mpi
@@ -2,15 +2,14 @@
 
 function set_mpi()
 {
-  command -v mpirun >/dev/null 2>&1
-  if [ $? -ne 0 ]; then
-    
-    ### Check for mpi installation
-
-    if [ -d "$1/MPI"  ]; then
-      echo "Setting MPI compilers to: $PATH:$1/MPI/bin"
-      export PATH="$PATH:$1/MPI/bin"
-    fi    
+  if [ x"$MPI_valid" == x"yes" ]; then
+        configure_options="$configure_options CXX=mpic++ "
+  else
+        ./script/install_MPI.sh $i_dir $ncore
+        MPI_installed=1
+        export PATH="$i_dir/MPI/bin:$PATH"
+        configure_options="$configure_options CXX=mpic++ "
   fi
+
 }
 
-- 
GitLab