fix hardcoded settings, add support for picking up dependencies provided via EasyBuild
author: Kenneth Hoste (kenneth.hoste@ugent.be)
diff -ru OpenFOAM-2.3.1.orig/etc/bashrc OpenFOAM-2.3.1/etc/bashrc
--- OpenFOAM-2.3.1.orig/etc/bashrc	2014-12-04 18:52:43.000000000 +0100
+++ OpenFOAM-2.3.1/etc/bashrc	2015-03-17 11:10:58.638236425 +0100
@@ -63,7 +63,7 @@
 
 #- Compiler:
 #    WM_COMPILER = Gcc | Gcc45 | Gcc46 | Gcc47 | Clang | Icc (Intel icc)
-export WM_COMPILER=Gcc
+: ${WM_COMPILER:=Gcc}; export WM_COMPILER
 unset WM_COMPILER_ARCH WM_COMPILER_LIB_ARCH
 
 #- Architecture:
@@ -81,7 +81,7 @@
 #- MPI implementation:
 #    WM_MPLIB = SYSTEMOPENMPI | OPENMPI | MPICH | MPICH-GM | HPMPI
 #               | GAMMA | MPI | QSMPI | SGIMPI
-export WM_MPLIB=SYSTEMOPENMPI
+: ${WM_MPLIB:=SYSTEMOPENMPI}; export WM_MPLIB
 
 #- Operating System:
 #    WM_OSTYPE = POSIX | ???
@@ -115,7 +115,7 @@
 
 # Location of third-party software
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-export WM_THIRD_PARTY_DIR=$WM_PROJECT_INST_DIR/ThirdParty-$WM_PROJECT_VERSION
+: ${WM_THIRD_PARTY_DIR:=$WM_PROJECT_INST_DIR/ThirdParty-$WM_PROJECT_VERSION}; export WM_THIRD_PARTY_DIR
 
 # Location of site-specific templates etc
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff -ru OpenFOAM-2.3.1.orig/etc/config/scotch.sh OpenFOAM-2.3.1/etc/config/scotch.sh
--- OpenFOAM-2.3.1.orig/etc/config/scotch.sh	2014-12-04 18:52:43.000000000 +0100
+++ OpenFOAM-2.3.1/etc/config/scotch.sh	2015-03-17 11:10:09.815948216 +0100
@@ -33,7 +33,11 @@
 #     during the wmake process
 #------------------------------------------------------------------------------
 
-export SCOTCH_VERSION=scotch_6.0.0
-export SCOTCH_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$SCOTCH_VERSION
+if [ -n "${SCOTCH_ROOT}" ] ; then
+	export SCOTCH_ARCH_PATH="${SCOTCH_ROOT}"
+else
+	export SCOTCH_VERSION=scotch_6.0.0
+	export SCOTCH_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$SCOTCH_VERSION
+fi
 
 # -----------------------------------------------------------------------------
diff -ru OpenFOAM-2.3.1.orig/etc/config/settings.csh OpenFOAM-2.3.1/etc/config/settings.csh
--- OpenFOAM-2.3.1.orig/etc/config/settings.csh	2014-12-04 18:52:43.000000000 +0100
+++ OpenFOAM-2.3.1/etc/config/settings.csh	2015-03-17 11:10:09.815948216 +0100
@@ -336,7 +336,7 @@
 # Communications library
 # ~~~~~~~~~~~~~~~~~~~~~~
 
-unsetenv MPI_ARCH_PATH MPI_HOME FOAM_MPI_LIBBIN
+#unsetenv MPI_ARCH_PATH MPI_HOME FOAM_MPI_LIBBIN
 
 switch ("$WM_MPLIB")
 case SYSTEMOPENMPI:
diff -ru OpenFOAM-2.3.1.orig/etc/config/settings.sh OpenFOAM-2.3.1/etc/config/settings.sh
--- OpenFOAM-2.3.1.orig/etc/config/settings.sh	2014-12-04 18:52:43.000000000 +0100
+++ OpenFOAM-2.3.1/etc/config/settings.sh	2015-03-17 11:10:09.815948216 +0100
@@ -356,7 +356,7 @@
 # Communications library
 # ~~~~~~~~~~~~~~~~~~~~~~
 
-unset MPI_ARCH_PATH MPI_HOME FOAM_MPI_LIBBIN
+#unset MPI_ARCH_PATH MPI_HOME FOAM_MPI_LIBBIN
 
 case "$WM_MPLIB" in
 SYSTEMOPENMPI)
@@ -524,6 +524,11 @@
     _foamAddPath    $MPI_ARCH_PATH/bin64
     _foamAddLib     $MPI_ARCH_PATH/lib64
     ;;
+
+EASYBUILDMPI)
+    export FOAM_MPI=mpi
+    ;;
+
 *)
     export FOAM_MPI=dummy
     ;;
diff -ru OpenFOAM-2.3.1.orig/src/parallel/decompose/ptscotchDecomp/Make/options OpenFOAM-2.3.1/src/parallel/decompose/ptscotchDecomp/Make/options
--- OpenFOAM-2.3.1.orig/src/parallel/decompose/ptscotchDecomp/Make/options	2014-12-04 18:52:43.000000000 +0100
+++ OpenFOAM-2.3.1/src/parallel/decompose/ptscotchDecomp/Make/options	2015-03-17 11:10:09.815948216 +0100
@@ -3,10 +3,8 @@
 
 EXE_INC = \
     $(PFLAGS) $(PINC) \
-    -I$(SCOTCH_ROOT)/include \
     -I$(SCOTCH_ARCH_PATH)/include/$(FOAM_MPI) \
-    -I/usr/include/scotch \
     -I../decompositionMethods/lnInclude
 
 LIB_LIBS = \
-    -L$(SCOTCH_ROOT)/lib -L$(FOAM_EXT_LIBBIN)/$(FOAM_MPI) -lptscotch -lptscotcherrexit ${LINK_FLAGS} -lrt
+    -L$(SCOTCH_ARCH_PATH)/lib -L$(FOAM_EXT_LIBBIN)/$(FOAM_MPI) -lptscotch -lptscotcherrexit ${LINK_FLAGS} -lrt
diff -ru OpenFOAM-2.3.1.orig/src/parallel/decompose/ptscotchDecomp/ptscotchDecomp.C OpenFOAM-2.3.1/src/parallel/decompose/ptscotchDecomp/ptscotchDecomp.C
--- OpenFOAM-2.3.1.orig/src/parallel/decompose/ptscotchDecomp/ptscotchDecomp.C	2014-12-04 18:52:43.000000000 +0100
+++ OpenFOAM-2.3.1/src/parallel/decompose/ptscotchDecomp/ptscotchDecomp.C	2015-03-17 11:10:09.815948216 +0100
@@ -112,6 +112,8 @@
 
 \*---------------------------------------------------------------------------*/
 
+#include "mpi.h"
+
 #include "ptscotchDecomp.H"
 #include "addToRunTimeSelectionTable.H"
 #include "Time.H"
@@ -121,8 +123,8 @@
 
 extern "C"
 {
-#include <stdio.h>
 #include "mpi.h"
+#include <stdio.h>
 #include "ptscotch.h"
 }
 
diff -ru OpenFOAM-2.3.1.orig/src/parallel/decompose/scotchDecomp/Make/options OpenFOAM-2.3.1/src/parallel/decompose/scotchDecomp/Make/options
--- OpenFOAM-2.3.1.orig/src/parallel/decompose/scotchDecomp/Make/options	2014-12-04 18:52:43.000000000 +0100
+++ OpenFOAM-2.3.1/src/parallel/decompose/scotchDecomp/Make/options	2015-03-17 11:10:09.815948216 +0100
@@ -7,10 +7,8 @@
 
 EXE_INC = \
     $(PFLAGS) $(PINC) \
-    -I$(SCOTCH_ROOT)/include \
     -I$(SCOTCH_ARCH_PATH)/include \
-    -I/usr/include/scotch \
     -I../decompositionMethods/lnInclude
 
 LIB_LIBS = \
-    -L$(SCOTCH_ROOT)/lib -L$(FOAM_EXT_LIBBIN) -lscotch -lscotcherrexit -lrt
+    -L$(SCOTCH_ARCH_PATH)/lib -L$(FOAM_EXT_LIBBIN) -lscotch -lscotcherrexit -lrt
diff -ru OpenFOAM-2.3.1.orig/wmake/rules/linux64Gcc/c OpenFOAM-2.3.1/wmake/rules/linux64Gcc/c
--- OpenFOAM-2.3.1.orig/wmake/rules/linux64Gcc/c	2014-12-04 18:52:43.000000000 +0100
+++ OpenFOAM-2.3.1/wmake/rules/linux64Gcc/c	2015-03-17 11:10:09.815948216 +0100
@@ -2,7 +2,7 @@
 
 cWARN        = -Wall
 
-cc          = gcc -m64
+cc          = $(MPICC)
 
 include $(RULES)/c$(WM_COMPILE_OPTION)
 
diff -ru OpenFOAM-2.3.1.orig/wmake/rules/linux64Gcc/c++ OpenFOAM-2.3.1/wmake/rules/linux64Gcc/c++
--- OpenFOAM-2.3.1.orig/wmake/rules/linux64Gcc/c++	2014-12-04 18:52:43.000000000 +0100
+++ OpenFOAM-2.3.1/wmake/rules/linux64Gcc/c++	2015-03-17 11:10:09.815948216 +0100
@@ -2,7 +2,7 @@
 
 c++WARN     = -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor
 
-CC          = g++ -m64
+CC          = $(MPICXX)
 
 include $(RULES)/c++$(WM_COMPILE_OPTION)
 
diff -ru OpenFOAM-2.3.1.orig/wmake/rules/linux64Gcc/cOpt OpenFOAM-2.3.1/wmake/rules/linux64Gcc/cOpt
--- OpenFOAM-2.3.1.orig/wmake/rules/linux64Gcc/cOpt	2014-12-04 18:52:43.000000000 +0100
+++ OpenFOAM-2.3.1/wmake/rules/linux64Gcc/cOpt	2015-03-17 11:10:09.815948216 +0100
@@ -1,3 +1,3 @@
 cDBUG       =
-cOPT        = -O3
+cOPT        = $(CFLAGS)
 # -fprefetch-loop-arrays
diff -ru OpenFOAM-2.3.1.orig/wmake/rules/linux64Gcc/c++Opt OpenFOAM-2.3.1/wmake/rules/linux64Gcc/c++Opt
--- OpenFOAM-2.3.1.orig/wmake/rules/linux64Gcc/c++Opt	2014-12-04 18:52:43.000000000 +0100
+++ OpenFOAM-2.3.1/wmake/rules/linux64Gcc/c++Opt	2015-03-17 11:10:09.815948216 +0100
@@ -1,3 +1,3 @@
 c++DBUG     =
-c++OPT      = -O3
+c++OPT      = $(CXXFLAGS)
 # -fprefetch-loop-arrays
diff -ru OpenFOAM-2.3.1.orig/wmake/rules/linux64Icc/c OpenFOAM-2.3.1/wmake/rules/linux64Icc/c
--- OpenFOAM-2.3.1.orig/wmake/rules/linux64Icc/c	2014-12-04 18:52:43.000000000 +0100
+++ OpenFOAM-2.3.1/wmake/rules/linux64Icc/c	2015-03-17 11:10:09.815948216 +0100
@@ -2,7 +2,7 @@
 
 cWARN        =
 
-cc          = icc
+cc          = $(MPICC)
 
 include $(RULES)/c$(WM_COMPILE_OPTION)
 
diff -ru OpenFOAM-2.3.1.orig/wmake/rules/linux64Icc/c++ OpenFOAM-2.3.1/wmake/rules/linux64Icc/c++
--- OpenFOAM-2.3.1.orig/wmake/rules/linux64Icc/c++	2014-12-04 18:52:43.000000000 +0100
+++ OpenFOAM-2.3.1/wmake/rules/linux64Icc/c++	2015-03-17 11:10:09.815948216 +0100
@@ -2,7 +2,7 @@
 
 c++WARN     = -wd327,525,654,819,1125,1476,1505,1572
 
-CC          = icpc -std=c++0x
+CC          = $(MPICXX)
 
 include $(RULES)/c++$(WM_COMPILE_OPTION)
 
diff -ru OpenFOAM-2.3.1.orig/wmake/rules/linux64Icc/cOpt OpenFOAM-2.3.1/wmake/rules/linux64Icc/cOpt
--- OpenFOAM-2.3.1.orig/wmake/rules/linux64Icc/cOpt	2014-12-04 18:52:43.000000000 +0100
+++ OpenFOAM-2.3.1/wmake/rules/linux64Icc/cOpt	2015-03-17 11:10:09.815948216 +0100
@@ -1,2 +1,2 @@
 cDBUG       =
-cOPT        = -O3 -no-prec-div
+cOPT        = $(CFLAGS)
diff -ru OpenFOAM-2.3.1.orig/wmake/rules/linux64Icc/c++Opt OpenFOAM-2.3.1/wmake/rules/linux64Icc/c++Opt
--- OpenFOAM-2.3.1.orig/wmake/rules/linux64Icc/c++Opt	2014-12-04 18:52:43.000000000 +0100
+++ OpenFOAM-2.3.1/wmake/rules/linux64Icc/c++Opt	2015-03-17 11:10:09.815948216 +0100
@@ -1,2 +1,2 @@
 c++DBUG     =
-c++OPT      = -xHost -O2 -no-prec-div
+c++OPT      = $(CXXFLAGS)
