Building PETSc

PISM is built on top of PETSc, which is actively developed and an up-to-date PETSc distribution may not be available in package repositories. Download the PETSc source by grabbing the current gzipped tarball at:

(Use version 3.5 or newer; see Required tools and libraries for details.) The “lite” form of the tarball is fine if you are willing to depend on an Internet connection for accessing PETSc documentation.

You should configure and build PETSc as described on the PETSc installation page, but it might be best to read the following comments on the PETSc configure and build process first:

  1. Untar in your preferred location and enter the new PETSc directory. Note PETSc should not be configured using root privileges. When you run the configure script the following options are recommended; note PISM uses shared libraries by default:

    export PETSC_DIR=$PWD
    export PETSC_ARCH=opt
    ./config/ --with-shared-libraries \
                          --with-debugging=0 \

    You need to define the environment variables PETSC_DIR and PETSC_ARCH 1 – one way is shown here – before running the configuration script. Turning off the inclusion of debugging code and symbols can give a significant speed improvement, but some kinds of development will benefit from setting --with-debugging=1. Using shared libraries may be unwise on certain clusters; check with your system administrator. PISM does not use PETSc’s Fortran API, so the Fortran compiler is disabled by --with-fc=0.

  2. It is sometimes convenient to have PETSc grab a local copy of BLAS and LAPACK rather than using the system-wide version. So one may add “--download-f2cblaslapack=1” to the other configure options.

  3. If there is an existing MPI installation, we recommend using MPI’s compiler wrappers to specify an MPI library when installing PETSc, for example:

    CC=mpicc CXX=mpicxx ./config/ --with-shared-libraries \
                                              --with-debugging=0 \

    If you get messages suggesting that PETSc cannot configure using your existing MPI, you might want to try adding the --download-mpich=1 (or --download-openmpi=1) option to PETSc’s configure command.

  4. Configuration of PETSc for a batch system requires special procedures described at the PETSc documentation site. One starts with a configure option --with-batch=1. See the “Installing on machine requiring cross compiler or a job scheduler” section of the PETSc installation page.

  5. Configuring PETSc may take a moment even when everything goes smoothly. A value for the environment variable PETSC_ARCH will be reported at the end of the configure process; take note of this value. One may always reconfigure with additional PETSC_ARCH as needed.

  6. After finishes, you will need to run make all test in the PETSc directory and watch the result.



The PETSC_ARCH variable is just a string you can use to choose different PETSc configurations and does not have any other significance.

Previous Up Next