Index: /issm/trunk-jpl/externalpackages/dakota/install-discover.sh
===================================================================
--- /issm/trunk-jpl/externalpackages/dakota/install-discover.sh	(revision 12308)
+++ /issm/trunk-jpl/externalpackages/dakota/install-discover.sh	(revision 12308)
@@ -0,0 +1,103 @@
+#!/bin/bash
+
+echo "Currently, this script must be pasted line by line into the terminal"
+
+#Get number of cpus
+NUMCPUS=$1;
+
+#Some cleanup
+rm -rf Dakota
+rm -rf src 
+rm -rf install 
+mkdir src install 
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/Dakota_4_3.src.tar.gz' 'Dakota_4_3.src.tar.gz'
+
+#Untar 
+tar -zxvf  Dakota_4_3.src.tar.gz
+
+#Move Dakota to src directory
+mv Dakota/* src
+rm -rf Dakota
+
+#Apply patches
+patch src/src/ParallelLibrary.C ./ParallelLibrary.C.patch
+patch src/src/ParallelLibrary.H ./ParallelLibrary.H.patch
+patch src/src/NIDRProblemDescDB.C ./NIDRProblemDescDB.C.patch
+patch src/src/NonDSampling.C ./NonDSampling.C.patch
+patch src/src/NonDLocalReliability.C ./NonDLocalReliability.C.patch
+patch src/src/NonDUnilevelRBDO.C ./NonDUnilevelRBDO.C.patch    #  source not even used?
+#patch -R src/packages/Pecos/src/LHSDriver.cpp ./LHSDriver.cpp.patch
+
+#Configure dakota
+cd src
+
+./configure \ 
+	--prefix="$ISSM_DIR/externalpackages/dakota/install/" \
+	--without-graphics  \
+	--with-pic \
+	--disable-mpi \
+	--with-blas="-L/usr/local/intel/mkl/10.1.2.024/lib/64/ -lmkl -lmkl_lapack -liomp5 -lpthread" \
+	--with-lapack="-L/usr/local/intel/mkl/10.1.2.024/lib/64/ -lmkl -lmkl_lapack -liomp5 -lpthread" 
+
+cd ..
+
+#Before compiling, if running on 64 bits, we need to active fPIC compilation. Some packages 
+#do not register -fPIC in Dakota, which is a problem. Edit the faulty Makefiles and add the -fPIC 
+#flag to the compilation.
+cat ./src/methods/NCSUOpt/Makefile | sed 's/FFLAGS = -g -O2/FFLAGS = -g -O2 -fPIC/g' >  temp
+mv temp ./src/methods/NCSUOpt/Makefile
+
+cat ./src/methods/acro/packages/pebbl/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
+mv temp ./src/methods/acro/packages/pebbl/src/Makefile
+
+cat ./src/methods/hopspack/src-nappspack/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
+mv temp ./src/methods/hopspack/src-nappspack/Makefile
+
+cat ./src/methods/hopspack/src-cddlib/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
+mv temp  ./src/methods/hopspack/src-cddlib/Makefile 
+
+cat ./src/methods/hopspack/src-shared/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
+mv temp  ./src/methods/hopspack/src-shared/Makefile 
+
+cat ./src/methods/hopspack/src-shared/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
+mv temp  ./src/methods/hopspack/src-shared/Makefile 
+
+cat ./src/methods/hopspack/src-conveyor/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2 -fPIC/g' > temp
+mv temp  ./src/methods/hopspack/src-conveyor/Makefile 
+
+cat ./src/methods/hopspack/src-appspack/Makefile | sed 's/CXXFLAGS = -g -O2/CXXFLAGS = -g -O2  -fPIC/g' > temp
+mv temp ./src/methods/hopspack/src-appspack/Makefile 
+
+cat ./src/methods/acro/packages/colin/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
+mv temp ./src/methods/acro/packages/colin/src/Makefile
+
+cat ./src/methods/acro/packages/coliny/src/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CXXFLAGS = -O2 -fpermissive -fPIC/g' > temp
+mv temp ./src/methods/acro/packages/coliny/src/Makefile
+
+cat ./src/methods/acro/packages/tpl/3po/Makefile | sed 's/CFLAGS = -O2/CFLAGS = -O2 -fPIC/g' > temp
+mv temp  ./src/methods/acro/packages/tpl/3po/Makefile 
+
+cat ./src/methods/acro/packages/tpl/3po/Makefile | sed 's/CXXFLAGS = -O2 -fpermissive/CFLAGS = -O2 -fpermissive -fPIC/g' > temp
+mv temp  ./src/methods/acro/packages/tpl/3po/Makefile 
+
+cat ./src/packages/ampl/Makefile | sed 's/CFLAGS = -g -O2/CFLAGS = -g -O2 -fPIC/g' > temp
+mv temp  ./src/packages/ampl/Makefile 
+
+#Compile and install dakota
+cd src 
+if [ -z $NUMCPUS ];
+then
+	make
+	make install
+else
+	make -j $NUMCPUS
+	make -j $NUMCPUS install
+fi
+cd ..
+
+#Weird behaviour of Dakota: libamplsolver.a and amplsolver.a are not the same thing!
+cd install/lib
+mv libamplsolver.a libamplsolver.a.bak
+ln -s ../../src/packages/ampl/amplsolver.a ./libamplsolver.a
Index: /issm/trunk-jpl/externalpackages/metis/configs/4.0/discover/Makefile.in.patch
===================================================================
--- /issm/trunk-jpl/externalpackages/metis/configs/4.0/discover/Makefile.in.patch	(revision 12308)
+++ /issm/trunk-jpl/externalpackages/metis/configs/4.0/discover/Makefile.in.patch	(revision 12308)
@@ -0,0 +1,10 @@
+3c3,5
+< CC = cc
+---
+> CC = icc
+> OBJ_EXT=o
+> LIB_EXT=a
+6c8
+< OPTFLAGS = -O2 
+---
+> OPTFLAGS = -DLINUX -fPIC
Index: /issm/trunk-jpl/externalpackages/metis/install-4.0-discover.sh
===================================================================
--- /issm/trunk-jpl/externalpackages/metis/install-4.0-discover.sh	(revision 12308)
+++ /issm/trunk-jpl/externalpackages/metis/install-4.0-discover.sh	(revision 12308)
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+#Some cleanup
+rm -rf install metis-4.0
+mkdir install
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/metis-4.0.tar.gz' 'metis-4.0.tar.gz'
+
+#Untar 
+tar -zxvf  metis-4.0.tar.gz
+
+#Move metis into install directory
+mv metis-4.0/* install
+rm -rf metis-4.0
+
+#Apply patches
+cd install 
+patch -p1 < ../metis-4.0.patch
+patch Makefile.in ../configs/4.0/discover/Makefile.in.patch
+
+#Compile
+make
Index: /issm/trunk-jpl/externalpackages/petsc/install-3.2-discover.sh
===================================================================
--- /issm/trunk-jpl/externalpackages/petsc/install-3.2-discover.sh	(revision 12308)
+++ /issm/trunk-jpl/externalpackages/petsc/install-3.2-discover.sh	(revision 12308)
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+#Some cleanup
+rm -rf install petsc-3.2-p3 src
+mkdir install src
+
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/petsc-3.2-p3.tar.gz' 'petsc-3.2-p3.tar.gz'
+
+#Untar and move petsc to install directory
+tar -zxvf  petsc-3.2-p3.tar.gz
+mv petsc-3.2-p3/* src/
+rm -rf petsc-3.2-p3
+
+#configure
+cd src
+./config/configure.py \
+	--prefix="$ISSM_DIR/externalpackages/petsc/install" \
+	--PETSC_DIR="$ISSM_DIR/externalpackages/petsc/src" \
+	--PETSC_ARCH="$ISSM_ARCH" \
+	--with-batch=1 \
+	--with-debugging=0 \
+	--with-shared-libraries=0 \
+	--known-mpi-shared-libraries=1 \
+	--with-mpi-dir=/usr/local/intel/mpi/3.2.2.006/lib64 \
+	--with-blas-lapack-dir=/usr/local/intel/mkl/10.1.2.024/lib/64/ \
+	--download-mumps=yes \
+	--download-scalapack=yes \
+	--download-blacs=yes \
+	--download-plapack=yes \
+	--download-parmetis=yes \
+	--with-pic=1
+
+echo "== Follow PETSc's instructions"
