patch to avoid hardcoding of settings, so defaults can be set on the outside by defining environment variables
author: Kenneth Hoste (Ghent University)
diff -ru OpenFOAM-2.0.1.ORIG/etc/bashrc OpenFOAM-2.0.1/etc/bashrc
--- OpenFOAM-2.0.1.ORIG/etc/bashrc	2011-08-03 11:42:18.000000000 +0200
+++ OpenFOAM-2.0.1/etc/bashrc	2014-07-01 10:58:53.980635981 +0200
@@ -63,7 +63,7 @@
 
 #- Compiler:
 #    WM_COMPILER = Gcc | Gcc43 | Gcc44 | Gcc45 | Gcc46 | 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
-export WM_MPLIB=OPENMPI
+: ${WM_MPLIB:=OPENMPI}; 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.0.1.ORIG/etc/config/scotch.sh OpenFOAM-2.0.1/etc/config/scotch.sh
--- OpenFOAM-2.0.1.ORIG/etc/config/scotch.sh	2011-08-03 11:42:18.000000000 +0200
+++ OpenFOAM-2.0.1/etc/config/scotch.sh	2014-07-08 00:06:23.422603272 +0200
@@ -33,7 +33,11 @@
 #     during the wmake process
 #------------------------------------------------------------------------------
 
-export SCOTCH_VERSION=scotch_5.1.11
-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_5.1.11
+	export SCOTCH_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$SCOTCH_VERSION
+fi
 
 # -----------------------------------------------------------------------------
diff -ru OpenFOAM-2.0.1.ORIG/etc/config/settings.csh OpenFOAM-2.0.1/etc/config/settings.csh
--- OpenFOAM-2.0.1.ORIG/etc/config/settings.csh	2011-08-03 11:42:18.000000000 +0200
+++ OpenFOAM-2.0.1/etc/config/settings.csh	2014-07-01 10:58:53.982635976 +0200
@@ -366,7 +366,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 OPENMPI:
diff -ru OpenFOAM-2.0.1.ORIG/etc/config/settings.sh OpenFOAM-2.0.1/etc/config/settings.sh
--- OpenFOAM-2.0.1.ORIG/etc/config/settings.sh	2011-08-03 11:42:18.000000000 +0200
+++ OpenFOAM-2.0.1/etc/config/settings.sh	2014-07-03 20:38:00.140345132 +0200
@@ -386,7 +386,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
 OPENMPI)
@@ -502,6 +502,10 @@
     _foamAddLib     $MPI_ARCH_PATH/lib
     ;;
 
+EASYBUILDMPI)
+    export FOAM_MPI=mpi
+    ;;
+
 *)
     export FOAM_MPI=dummy
     ;;
diff -ru OpenFOAM-2.0.1.ORIG/src/OSspecific/POSIX/fileMonitor.C OpenFOAM-2.0.1/src/OSspecific/POSIX/fileMonitor.C
--- OpenFOAM-2.0.1.ORIG/src/OSspecific/POSIX/fileMonitor.C	2011-08-03 11:42:18.000000000 +0200
+++ OpenFOAM-2.0.1/src/OSspecific/POSIX/fileMonitor.C	2014-07-01 11:47:12.008248918 +0200
@@ -32,6 +32,7 @@
 #include "regIOobject.H"     // for fileModificationSkew symbol
 
 #ifdef FOAM_USE_INOTIFY
+#   include <unistd.h>
 #   include <sys/inotify.h>
 #   include <sys/ioctl.h>
 #   include <errno.h>
diff -ru OpenFOAM-2.0.1.ORIG/src/Pstream/dummy/UIPread.C OpenFOAM-2.0.1/src/Pstream/dummy/UIPread.C
--- OpenFOAM-2.0.1.ORIG/src/Pstream/dummy/UIPread.C	2011-08-03 11:42:18.000000000 +0200
+++ OpenFOAM-2.0.1/src/Pstream/dummy/UIPread.C	2014-07-03 19:04:04.937308304 +0200
@@ -67,6 +67,34 @@
 }
 
 
+// Add missing constructor
+// (This code is taken from OpenFOAM 2.1.1)
+Foam::UIPstream::UIPstream
+(
+    const int fromProcNo,
+    PstreamBuffers& buffers
+)
+:
+    UPstream(buffers.commsType_),
+    Istream(buffers.format_, buffers.version_),
+    fromProcNo_(fromProcNo),
+    externalBuf_(buffers.recvBuf_[fromProcNo]),
+    externalBufPosition_(buffers.recvBufPos_[fromProcNo]),
+    tag_(buffers.tag_),
+    clearAtEnd_(true),
+    messageSize_(0)
+{
+    notImplemented
+    (
+        "UIPstream::UIPstream\n"
+        "(\n"
+            "const int,\n"
+            "PstreamBuffers&\n"
+        ")"
+    );
+}
+
+
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
 Foam::label Foam::UIPstream::read
diff -ru OpenFOAM-2.0.1.ORIG/src/finiteVolume/fields/fvPatchFields/constraint/wedge/wedgeFvPatchScalarField.C OpenFOAM-2.0.1/src/finiteVolume/fields/fvPatchFields/constraint/wedge/wedgeFvPatchScalarField.C
--- OpenFOAM-2.0.1.ORIG/src/finiteVolume/fields/fvPatchFields/constraint/wedge/wedgeFvPatchScalarField.C	2011-08-03 11:42:18.000000000 +0200
+++ OpenFOAM-2.0.1/src/finiteVolume/fields/fvPatchFields/constraint/wedge/wedgeFvPatchScalarField.C	2014-07-10 16:00:51.894987531 +0200
@@ -48,7 +48,7 @@
         updateCoeffs();
     }
 
-    operator==(patchInternalField());
+    this->operator==(patchInternalField());
 }
 
 
diff -ru OpenFOAM-2.0.1.ORIG/src/parallel/decompose/ptscotchDecomp/Make/options OpenFOAM-2.0.1/src/parallel/decompose/ptscotchDecomp/Make/options
--- OpenFOAM-2.0.1.ORIG/src/parallel/decompose/ptscotchDecomp/Make/options	2011-08-03 11:42:19.000000000 +0200
+++ OpenFOAM-2.0.1/src/parallel/decompose/ptscotchDecomp/Make/options	2014-07-08 09:13:19.985079768 +0200
@@ -4,8 +4,7 @@
 EXE_INC = \
     $(PFLAGS) $(PINC) \
     -I$(SCOTCH_ARCH_PATH)/include/$(FOAM_MPI) \
-    -I/usr/include/scotch \
     -I../decompositionMethods/lnInclude
 
 LIB_LIBS = \
-    -L$(FOAM_EXT_LIBBIN)/$(FOAM_MPI) -lptscotch -lptscotcherrexit -lrt
+    -L$(SCOTCH_ARCH_PATH)/lib -L$(FOAM_EXT_LIBBIN)/$(FOAM_MPI) -lptscotch -lptscotcherrexit -lrt
diff -ru OpenFOAM-2.0.1.ORIG/src/parallel/decompose/ptscotchDecomp/ptscotchDecomp.C OpenFOAM-2.0.1/src/parallel/decompose/ptscotchDecomp/ptscotchDecomp.C
--- OpenFOAM-2.0.1.ORIG/src/parallel/decompose/ptscotchDecomp/ptscotchDecomp.C	2011-08-03 11:42:19.000000000 +0200
+++ OpenFOAM-2.0.1/src/parallel/decompose/ptscotchDecomp/ptscotchDecomp.C	2014-07-01 10:58:54.067635849 +0200
@@ -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.0.1.ORIG/src/parallel/decompose/scotchDecomp/Make/options OpenFOAM-2.0.1/src/parallel/decompose/scotchDecomp/Make/options
--- OpenFOAM-2.0.1.ORIG/src/parallel/decompose/scotchDecomp/Make/options	2011-08-03 11:42:19.000000000 +0200
+++ OpenFOAM-2.0.1/src/parallel/decompose/scotchDecomp/Make/options	2014-07-03 20:34:48.490670831 +0200
@@ -8,8 +8,7 @@
 EXE_INC = \
     $(PFLAGS) $(PINC) \
     -I$(SCOTCH_ARCH_PATH)/include \
-    -I/usr/include/scotch \
     -I../decompositionMethods/lnInclude
 
 LIB_LIBS = \
-    -L$(FOAM_EXT_LIBBIN) -lscotch -lscotcherrexit -lrt
+    -I$(SCOTCH_ARCH_PATH)/lib -L$(FOAM_EXT_LIBBIN) -lscotch -lscotcherrexit -lrt
diff -ru OpenFOAM-2.0.1.ORIG/wmake/rules/linux64Gcc/c OpenFOAM-2.0.1/wmake/rules/linux64Gcc/c
--- OpenFOAM-2.0.1.ORIG/wmake/rules/linux64Gcc/c	2011-08-03 11:42:23.000000000 +0200
+++ OpenFOAM-2.0.1/wmake/rules/linux64Gcc/c	2014-07-01 10:58:54.068635847 +0200
@@ -2,7 +2,7 @@
 
 cWARN        = -Wall
 
-cc          = gcc -m64
+cc          = $(MPICC)
 
 include $(RULES)/c$(WM_COMPILE_OPTION)
 
diff -ru OpenFOAM-2.0.1.ORIG/wmake/rules/linux64Gcc/c++ OpenFOAM-2.0.1/wmake/rules/linux64Gcc/c++
--- OpenFOAM-2.0.1.ORIG/wmake/rules/linux64Gcc/c++	2011-08-03 11:42:23.000000000 +0200
+++ OpenFOAM-2.0.1/wmake/rules/linux64Gcc/c++	2014-07-01 10:58:54.070635843 +0200
@@ -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.0.1.ORIG/wmake/rules/linux64Gcc/c++Opt OpenFOAM-2.0.1/wmake/rules/linux64Gcc/c++Opt
--- OpenFOAM-2.0.1.ORIG/wmake/rules/linux64Gcc/c++Opt	2011-08-03 11:42:23.000000000 +0200
+++ OpenFOAM-2.0.1/wmake/rules/linux64Gcc/c++Opt	2014-07-01 10:58:54.071635842 +0200
@@ -1,3 +1,3 @@
 #c++DBUG     = -O0 -DFULLDEBUG -g
 c++DBUG     =
-c++OPT      = -O3
+c++OPT      = $(CXXFLAGS)
diff -ru OpenFOAM-2.0.1.ORIG/wmake/rules/linux64Gcc/cOpt OpenFOAM-2.0.1/wmake/rules/linux64Gcc/cOpt
--- OpenFOAM-2.0.1.ORIG/wmake/rules/linux64Gcc/cOpt	2011-08-03 11:42:23.000000000 +0200
+++ OpenFOAM-2.0.1/wmake/rules/linux64Gcc/cOpt	2014-07-01 10:58:54.073635840 +0200
@@ -1,2 +1,2 @@
 cDBUG       =
-cOPT        = -O3
+cOPT        = $(CFLAGS)
diff -ru OpenFOAM-2.0.1.ORIG/wmake/rules/linux64Icc/c OpenFOAM-2.0.1/wmake/rules/linux64Icc/c
--- OpenFOAM-2.0.1.ORIG/wmake/rules/linux64Icc/c	2011-08-03 11:42:23.000000000 +0200
+++ OpenFOAM-2.0.1/wmake/rules/linux64Icc/c	2014-07-01 10:58:54.074635838 +0200
@@ -2,7 +2,7 @@
 
 cWARN        =
 
-cc          = icc
+cc          = $(MPICC)
 
 include $(RULES)/c$(WM_COMPILE_OPTION)
 
diff -ru OpenFOAM-2.0.1.ORIG/wmake/rules/linux64Icc/c++ OpenFOAM-2.0.1/wmake/rules/linux64Icc/c++
--- OpenFOAM-2.0.1.ORIG/wmake/rules/linux64Icc/c++	2011-08-03 11:42:23.000000000 +0200
+++ OpenFOAM-2.0.1/wmake/rules/linux64Icc/c++	2014-07-01 10:58:54.076635834 +0200
@@ -2,7 +2,7 @@
 
 c++WARN     = -wd327,654,819,1125,1476,1505,1572
 
-CC          = icpc -std=c++0x
+CC          = $(MPICXX)
 
 include $(RULES)/c++$(WM_COMPILE_OPTION)
 
diff -ru OpenFOAM-2.0.1.ORIG/wmake/rules/linux64Icc/c++Opt OpenFOAM-2.0.1/wmake/rules/linux64Icc/c++Opt
--- OpenFOAM-2.0.1.ORIG/wmake/rules/linux64Icc/c++Opt	2011-08-03 11:42:23.000000000 +0200
+++ OpenFOAM-2.0.1/wmake/rules/linux64Icc/c++Opt	2014-07-01 10:58:54.077635833 +0200
@@ -1,3 +1,3 @@
 c++DBUG     =
 #c++OPT      = -xSSE3 -O3 -no-prec-div
-c++OPT      = -xSSE3 -O1 -no-prec-div
+c++OPT      = $(CXXFLAGS)
diff -ru OpenFOAM-2.0.1.ORIG/wmake/rules/linux64Icc/cOpt OpenFOAM-2.0.1/wmake/rules/linux64Icc/cOpt
--- OpenFOAM-2.0.1.ORIG/wmake/rules/linux64Icc/cOpt	2011-08-03 11:42:23.000000000 +0200
+++ OpenFOAM-2.0.1/wmake/rules/linux64Icc/cOpt	2014-07-01 10:58:54.078635832 +0200
@@ -1,2 +1,2 @@
 cDBUG       =
-cOPT        = -O3 -no-prec-div
+cOPT        = $(CFLAGS)
