petsc-3.3-p7 2013-05-11

Documentation: Installation

Quick Instructions:

Invoke the following commands from the top level PETSc directory:
Check here for MS Windows Installation

Encounter problems?


Example Usages:

PETSC_DIR and PETSC_ARCH are a couple of variables that control the configuration and build process of PETSc. These variables can be set as envirnment variables or specified on the command line [to both configure and make]

PETSC_DIR: this variable should point to the location of the PETSc installation that is used. Multiple PETSc versions can coexist on the same file-system. By changing PETSC_DIR value, one can switch between these installed versions of PETSc.

PETSC_ARCH: this variable gives a name to a configuration/build. Configure uses this value to stores the generated config makefiles in ${PETSC_DIR}/${PETSC_ARCH}/conf. And make uses this value to determine this location of these makefiles [which intern help in locating the correct include and library files].

Thus one can install multiple variants of PETSc libraries - by providing different PETSC_ARCH values to each configure build. Then one can switch between using these variants of libraries [from make] by switching the PETSC_ARCH value used.

If configure doesn't find a PETSC_ARCH value [either in env variable or command line option], it automatically generates a default value and uses it. Also - if make doesn't find a PETSC_ARCH env variable - it defaults to the value used by last successful invocation of previous configure.

Return to Installation Instructions


Specify compilers and compiler options used to build PETSc [and perhaps external packages]

Return to Installation Instructions

External Packages:

PETSc provides interfaces to various external packages. Blas/Lapack is a required package, MPI is not required if running sequentially. One can optionally use external solvers like Hypre, MUMPS, etc. from within PETSc aplications.

PETSc configure has the ability to download and install these external packages. Alternatively if these packages are already installed, then configure can detect and use them.

The following modes can be used to install/use external packages with configure.

Notes: Additional options: Return to Installation Instructions


These packages provide some basic numeric kernels used by PETSc.

Notes: Return to Installation Instructions


This software provides the parallel functionality for PETSc.

Using MPI Compilers:

Installing without MPI:

Installing with Open MPI with shared MPI libraries:

OpenMPI defaults to building shared libraries for MPI. However, the binaries generated by MPI wrappers mpicc/mpif77 etc require LD_LIBRARY_PATH to be set to the location of these libraries.

Due to this OpenMPI restriction one has to set LD_LIBRARY_PATH correctly [per OpenMPI installation instructions], before running PETSc configure. If you do not set this environmental variables you will get messages when running ./configure such as

            UNABLE to EXECUTE BINARIES for config/
            Cannot run executables created with C. If this machine uses a batch system
            to submit jobs you will need to configure using/ with the additional option --with-batch.
            Otherwise there is problem with the compilers. Can you compile and run code with your C/C++ (and maybe Fortran) compilers?

or when running a code compiled with OpenMPI

-bash-3.3$ ./conftest
./conftest: error while loading shared libraries: cannot open shared object file: No such file or directory


Return to Installation Instructions

Microsoft Windows Installation With MS/Intel/Compaq Compilers:

Microsoft Windows OS does not provide the same unix shell enviornment as the other OSes. Also the default MS/Intel/Compaq compilers behave differently than other unix compilers. So to install PETSc on Microsoft Windows - one has to install cygwin [for the unix enviornment] and use win32fe [part of PETSc sources,to interface to MS/Intel/Compaq compilers].

Install Cygwin: Please download and install cygwin package from Make sure the following cygwin components are installed.

Remove Cygwin link.exe: Cygwin link.exe can conflict with Intel ifort and Comapq F90 compilers. If you are using these compilers - please do [from cygwin/bash shell]:

Setup cygwin bash shell with Working Compilers: We require the compilers to be setup properly in a cygwin bash command shell, so that "cl foo.c" or "ifort foo.f" works from this shell. For example - if using VS2005 C and Intel 10 Fortran one can do:

Example Configure usage with Windows Compilers:

Use configure with VC2005 C and Intel Fortran 10 [With MPICH2 installed].

If fortran usage is not required, use:

Using Compaq F90:

Using Microsoft C/C++ 6.0 & Compaq Fortran 6.0 with MPICH2 configure command to use:

Note: MPICH2 mpif.h needs a fix for it to work with Compaq F90 [specifically remove line with MPI_DISPLACEMENT_CURRENT - which uses 'integer*8' - which is unsupported by Compaq F90]

ExternalPackages: The --download-package option does not work with many external packages on Microsoft Windows.

Project Files: We cannot provide Microsoft Visual Studio project files for users as they are specific to the configure options, location of external packages, compiler versions etc. used for any given build of PETSc, so they are potentially different for each build of PETSc. So if you need a project file for use with PETSc - please do the following.

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.

Using Cygwin gcc/g++/gfortran: One can install and use PETSc with gcc/gfortran compilers from cygwin. In this case follow the regular Unix instructions.

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 cygwin make and other UNIX tools. For additional info, run ${PETSC_DIR}/bin/win32/win32fe without any options.

Return to Installation Instructions

Installing PETSc in /usr/local or /opt where sudo or root previledges are required:

If one wants to install PETSc [with sources] in a common system location like /usr/local or /opt, then we suggest creating a dir for PETSc in the required location with user privileges, and then do the PETSc install [as a regular/non-root user]. i.e.

Installing with --prefix:

One can also use the GNU --prefix install mode.

After the install is done, one has to switch to using PETSC_DIR=/opt/petsc/petsc-3.3-p0. If you've installed PETSc with the --prefix option then you DO NOT use a PETSC_ARCH variable. You should install different configurations using different --prefix names.

Using DESTDIR with prefix install:

One can also use the GNU DESTDIR with a prefix install. This mode is generally used by binary packagers.

The following is an example of creating 2 binary packages for PETSc - one with MPICH - the other with OpenMPI

Note: The --prefix build process internally uses a PETSC_ARCH value [either specified by user or automatically created by configure], and the buildfiles are stored in petsc-source-tree/PETSC_ARCH location. But after 'make install' step - PETSC_ARCH has no significance. One can reuse the same PETSC_ARCH for multiple builds - provided the previous buildfiles are removed before starting the next build. Similarly one can reuse DESTDIR for multiple installs provided the installfiles from the previous builddir are removed

Return to Installation Instructions

Installing on machine requiring cross compiler or a job scheduler, such as IBM SP or IBM Blue Gene:

If one has to use a cross compiler - or go through the job scheduler to use MPI on a given machine - use the configure option --with-batch as follows:

Return to Installation Instructions

Installing with TAU Instrumentation package:

TAU package and the prerequisite PDT packages need to be installed separately [perhaps with MPI]. Now use as compiler to PETSc configure.

Return to Installation Instructions

Installing PETSc to use NVidia GPUs (aka CUDA)

Cuda build of PETSc curently works on Apple OSX, Linux [Ubuntu 10.04], Microsoft Windows [Server 2003].

Return to Installation Instructions

Installing PETSc to use PThreads

Return to Installation Instructions