# Download:

curl http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-3.5.4.tar.gz -o petsc-3.5.4.tar.gz

# Unpack:

tar xvzf petsc-3.5.4.tar.gz

cd petsc-3.5.4

------------------------------------------------------------------------------------------
# Note
Currently python 3.X is not supported. In case of problems, try to invoke "configure" as 
"python2.7 ./configure ..."
------------------------------------------------------------------------------------------



# Debug version

./configure \
--prefix=/opt/petsc/petsc-3.5.4-int32-deb \
--download-fblaslapack=1 \
--with-debugging=1 \
--COPTFLAGS="-g -O0" \
--FOPTFLAGS="-g -O0" \
--CXXOPTFLAGS="-g -O0" \
--with-large-file-io=1 \
--with-cc=mpicc \
--with-cxx=mpicxx \
--with-fc=mpif90 \
--with-shared-libraries=0 \
--download-metis=1 \
--download-parmetis=1 \
--download-scalapack=1 \
--download-mumps=1 \
--download-superlu_dist=1


make all

sudo make install

------------------------------------------------------------------------------------------

# Optimized version

./configure \
--prefix=/opt/petsc/petsc-3.5.4-int32-opt \
--with-blas-lapack-lib="-Wl,-framework,Accelerate" \
--with-debugging=0 \
--COPTFLAGS="-O3" \
--FOPTFLAGS="-O3" \
--CXXOPTFLAGS="-O3" \
--with-large-file-io=1 \
--with-cc=mpicc \
--with-cxx=mpicxx \
--with-fc=mpif90 \
--with-shared-libraries=0 \
--download-metis=1 \
--download-parmetis=1 \
--download-scalapack=1 \
--download-mumps=1 \
--download-superlu_dist=1


make all

sudo make install

------------------------------------------------------------------------------------------

# Set paths in .bash_profile

export PETSC_DEB=/opt/petsc/petsc-3.5.4-int32-deb
export PETSC_OPT=/opt/petsc/petsc-3.5.4-int32-opt

NOTES:

[1] DEBUG & OPTIMIZED

No more PETSC_DIR and no more switching between the debug and optimized versions with .bash_profile is necessary.
Makefile is now supporting building both versions simultaneously.
type 'make mode=deb all' (or simply 'make all', mode=deb is the default) to build everything in debug mode
type 'make mode=opt all' to build everything in optimized mode

[2] SVN

Also it's not necessary to do svn updates explicitly.
type 'make update' to update to latest version, and to write a new Version.h file.

[3] VIEW ENVIRONMENT
type 'make mode=deb print' or 'make mode=opt print' to view your environmental variables.

[4] TESTS

Tests are also separated. In the tests directory:
type 'make mode=deb check' to perform tests in debug mode.
type 'make mode=opt check' or (or simply 'make check', mode=opt is the default) to perform tests in optimized mode.

Take care that mode=deb is the default for LaMEM, and mode=opt is the default for tests.

------------------------------------------------------------------------------------------
