Docs:  Installation

  Quick instructions:

  Invoke the following commands from the toplevel PETSc directory [using bash shell] 
export PETSC_DIR=$PWD
./config/configure.py --with-cc=gcc --with-fc=g77 --download-f-blas-lapack=1 --download-mpich=1
make all test

  Detailed instructions:

Example Usages:

  • Examples are at config/*.py. We use some of these scripts locally for testing - for example config/linux-gnu-amd64.py
  • Using the bash shell, assuming BLAS, LAPACK, MPICH are not currently installed ./config/configure.py will download & install BLAS, LAPACK, MPICH if they are not already installed on the system) :
            export PETSC_DIR=/home/petsc/petsc-2.3.1-p0
            cd $PETSC_DIR
            ./config/configure.py --download-f-blas-lapack=1 --download-mpich=1
            make
            make test
  • Same as above - but build Complex version of PETSc:
            export PETSC_DIR=/home/petsc/petsc-2.3.1-p0
            cd $PETSC_DIR
            ./config/configure.py --download-f-blas-lapack=1 --download-mpich=1 --with-scalar-type=complex
            make
            make test
  • Using the bash shell, assuming BLAS, LAPACK, MPICH software are installed at the specified locations:
            export PETSC_DIR=/home/petsc/petsc-2.3.1-p0
            cd $PETSC_DIR
            ./config/configure.py --with-blas-lapack-dir=/usr/local/lib --with-mpi-dir=/usr/local/mpich
            make
            make test
  • Using tcsh shell, install PETSc with default BLAS and LAPACK and no MPI:
            setenv PETSC_DIR /home/petsc/petsc-2.3.1-p0
            cd $PETSC_DIR
            ./config/configure.py --with-mpi=0
            make
            make test
  • Install PETSc with default BLAS, LAPACK and MPI using the GNU compilers, build the optimized version of the libraries:
            ./config/configure.py --with-vendor-compilers=0
            make
            make test
  • Using csh shell, install PETSc on Linux with two different sets of compilers:
            setenv PETSC_ARCH linux-gnu
            ./config/configure.py --with-vendor-compilers=0 --with-mpi-dir=/usr/local/mpich-gnu
            make
            make test
            setenv PETSC_ARCH linux-gnu-intel
            ./config/configure.py --with-vendor-compilers=intel --with-gnu-compilers=0 --with-blas-lapack-dir=/usr/local/mkl --with-mpi-dir=/usr/local/mpich-intel
            make
            make test

Several variables control the configuration and build process of PETSc. They can either be given as arguments to make or be set as environment variables.

PETSC_DIR: - this environment/make variable should point to the location of the PETSc installation that is used. You can add export PETSC_DIR=value in your .profile or .sh file or setenv PETSC_DIR value in your .cshrc or .tcshrc file. Multiple PETSc versions can coexist on the same file-system. By changing PETSC_DIR one can switch between the versions

PETSC_ARCH: this environment/make variable is used to specify the configuration that should currently be used. It corresponds to the configuration files in bmake/${PETSC_ARCH}. Multiple variants of PETSc libraries can be installed - each variant corresponding to a different PETSC_ARCH. One can switch between using these variants - by changing the value of PETSC_ARCH. If PETSC_ARCH is not set, the configuration from the last time you ran ./config/configure.py will be used.

Return to Installation Instructions     


Cygwin  provides UNIX tools on Microsoft Windows. When installing Cygwin make sure you install the following additional packages

  • make
  • python

Cygwin also has GNU compilers ( gcc, g++, g77) which can be used  if Microsoft, Intel, or Borland Group compilers are not available

Note: Previously we recommanded doing 'rebaseall' to avoid python problems. However 'rebaseall' has its own problems - so if there any python issues, the current recommendation is to reinstall cygwin from scratch.

 Cygwin  http://www.cygwin.com

Return to Installation Instructions    


BLAS/LAPACK: these packages provide some basic numeric kernels used by PETSc.

  • If ./config/configure.py cannot locate BLAS and LAPACK you can use the options --with-blas-lapack-dir=directory or --with-blas-lib=library and --with-lapack-lib=library or --with-blas-lapack-lib=library to indicate the location of the libraries.
    • on Microsoft Windows and Linux, one can use Intel MKL
    • On AIX (IBM) ESSL, on OSF (Compaq/alpha) DXML, on Solaris Sunperf, on SGI libcomplib.sgimath.
    • On some Linux boxes, blas/lapack is installed [/usr/lib/liblapack.a /usr/lib/libblas.a ]
    • Alternatively download the source distribution fblaslapack or cblaslapack from PETSc downloadpage
  • Use the ./config/configure.py options --download-f-blas-lapack=yes, --download-f-blas-lapack=ifneeded, then PETSc will download and install a BLAS and LAPACK for you.
  • Use --download-c-blas-lapack (as opposed to --download-f-blas-lapack) only if there is no fortran compiler.
 Intel MKL  http://www.intel.com/software/products/mkl
 fblaslapack  ftp://ftp.mcs.anl.gov/pub/petsc/fblaslapack.tar.gz
 cblaslapack  ftp://ftp.mcs.anl.gov/pub/petsc/f2cblaslapack.tar.gz

Return to Installation Instructions    


MPI: This software provides the parallel functionality for PETSc.

  • If ./config/configure.py cannot locate MPI you can indicate its location with --with-mpi-dir=directory or --with-mpi-include=directory --with-mpi-lib=libraryname --with-mpirun=pathofmpirun
    • On parallel machines, Vendor provided MPI might already be installed.  IBM, SGI, Cray etc provide their own. 
    • If vendor provided MPI is not available, it can be installed from sources. We recommend MPICH
  • Use the ./config/configure.py option --download-mpich=yes then PETSc will download and install MPICH for you.
 MPI     http://www.mpi-forum.org
 MPICH  http://www.mcs.anl.gov/mpi/mpich
 LAM  http://www.lam-mpi.org
 MPICH-NT (Microsoft Windows)  http://www-unix.mcs.anl.gov/~ashton/mpich.nt
 MPI/Pro (Microsoft Windows)  http://www.mpi-softtech.com/products/mpi_pro
 HPVM (Microsoft Windows)  http://www-csag.ucsd.edu/projects/hpvm.html
 WMPI (Microsoft Windows)  http://www.criticalsoftware.com/hpc

Return to Installation Instructions    


I don't want to use MPI: You can build (sequential) PETSc without an MPI.

Run ./config/configure.py --with-mpi=0 ....

Return to Installation Instructions    


Additional Microsoft Windows Notes:

Configure: --download-package option does not work with many external packages [for eg: mpich]

Project Files: We provide templates for Microsoft Visual Studio project files at ${PETSC_DIR}/projects. These do not work by default. If you need to use project files:

  • try compiling the example from make file - for eg:
    cd src/ksp/ksp/examples/tutorials
    make ex2
  • if the above works - then make sure all the compiler/linker options used by make are also present in the project file.
  • if errors - redo the above step. [if all the options are correctly specified - then the example should compile from MSDev.

Debugger:  Running PETSc probrams with -start_in_debugger is not supported on this platform, so debuggers will need to be initiated manually. Make sure your environment is properly configured to use the appropriate debugger for your compiler. The debuggers can be initiated using Microsoft Visual Studio 6: msdev ex1.exe, Microsoft Visual Studio .NET: devenv ex1.exe, Intel Enhanced Debugger: edb ex1.exe, or GNU Debugger gdb ex1.exe.

PETSc Win32 front end - win32fe:  This tool is used as a wrapper to Microsoft/ Borland/ Intel compilers and associated tools - to enable building PETSc libraries using make and other UNIX tools. For additional info, run ${PETSC_DIR}/bin/win32/win32fe without any options.

Return to Installation Instructions       


Installing on IBM SP:

To run any code compiled with MPI on IBM SP - one has to go through the job scheduler.  Running configure on such job-scheduler only machines requires the additional option '--with-batch=1'. Alternatively check/run  config/aix5.1.0.0.py for all configure options required on the SP.

Installing on IBM Blue Gene:

IBM Blue Gene [as of now] requires modified compiler script wrappers to compile PETSc-2.3.1. Please download ftp://ftp.mcs.anl.gov/pub/petsc/tmp/petsc-bgl-tools.tar.gz and follow instructions provided in the README file.

Installing with TAU Instrumentation package:

TAU package and the prerequisite PDT packages need to be installed separately. PETSc provides a wrapper compiler for TAU. This needs to be invoked with the correct information for the installed TAU and PDT packages. For eg:

 ./config/configure.py --with-mpi-dir=/home/petsc/soft/linux-rh73/mpich-1.2.4 --with-fc=0 --with-cxx=0 -PETSC_ARCH=linux-tau -with-cpp=cpp --with-cc="`pwd`/bin/taucc.py -cc=gcc -pdt_parse=/homes/petsc/soft/linux-rh73/pdtoolkit-2.2b1/linux/bin/cxxparse -tau_lib_dir=/homes/petsc/soft/linux-rh73/tau-2.11.18/i386_linux/lib"

Installing TOPS components:

To install TOPS components one has to download and install CCA Tools.  [linux only]

  • Get the CCA Tools package from http://www.cca-forum.org/download/cca-tools/cca-tools-0.5.9.tar.gz
  • Configure cca-tools using '-with-mpi' option [prerequisites might be Java SDK, c++, mpich1]
  • Configure PETSc with C++, babel, ccafe options. Check config/asterix-tops.py for an example.
  • Build PETSc libraries & TOPS components with 'make all'
  • To test  do: 'cd src/tops; make examples'

Installing the Python Bindings:

Currently, the automatic Python installtion works only for the developer release. The first step to installing the Python bindings is to add the following 3 options to your configuration:
    ./config/configure --with-shared --with-dynamic --with-python
which will download the source for the bindings into src/python and make sure that PETSc can build dynamic libraries for the Python modules. If you have the relase version, this download can be done manually using:
    mkdir src/python
    cd src/python
    wget ftp://ftp.mcs.anl.gov/pub/petsc/PETScPython.tar.gz .
    tar xvzf PETScPython.tar.gz
After building PETSc, we can build the bindings using:
    make python
which will create python modules stored in lib/PETSC_ARCH/PETSc.

Return to Installation Instructions