PETSc Users Manual


The manual is currently being migrated here. If you are a user, see the current manual here. If you are a PETSc contributor, please help with the migration!


THIS SECTION IS IN NEED OF EXPERT COPYEDITING! This documentation is being moved from the old, LaTeX-based manual to a web-friendlier format using Sphinx. The content below was mostly automatically converted from LaTeX source, and almost certainly includes multiple formatting errors, missing images, etc. If you are a developer/contributor/expert and would like to claim this section to clean it up (and if so inspired, improve and/or streamline it), please make an initial MR to remove this banner and replace it with a note identifying it as being edited by you. Then, edit using Sphinx tools and when ready, submit your changes. Note that developer information on Sphinx lives here: Sphinx Documentation.

Mathematics and Computer Science Division

Prepared by
S. Balay1, S. Abhyankar2, M. Adams3, J. Brown1, P. Brune1, K. Buschelman1, L. Dalcin4, A. Dener1, V. Eijkhout6, W. Gropp1, D. Karpeyev1, D. Kaushik1, M. Knepley1, D. May7, L. Curfman McInnes1, R. Mills1, T. Munson1, K. Rupp1, P. Sanan8, B. Smith1, S. Zampini4, H. Zhang5, and H. Zhang1
1Mathematics and Computer Science Division, Argonne National Laboratory
2Electricity Infrastructure and Buildings Division, Pacific Northwest National Laboratory
3Computational Research, Lawrence Berkeley National Laboratory
4Extreme Computing Research Center, King Abdullah University of Science and Technology
5Computer Science Department, Illinois Institute of Technology
6Texas Advanced Computing Center, University of Texas at Austin
7Department of Earth Sciences, University of Oxford
8Institute of Geophysics, ETH Zurich
March 2020
This work was supported by the Office of Advanced Scientific Computing Research,
Office of Science, U.S. Department of Energy, under Contract DE-AC02-06CH11357.

This manual describes the use of PETSc for the numerical solution of partial differential equations and related problems on high-performance computers. The Portable, Extensible Toolkit for Scientific Computation (PETSc) is a suite of data structures and routines that provide the building blocks for the implementation of large-scale application codes on parallel (and serial) computers. PETSc uses the MPI standard for all message-passing communication.

PETSc includes an expanding suite of parallel linear solvers, nonlinear solvers, and time integrators that may be used in application codes written in Fortran, C, C++, and Python (via petsc4py; see page ). PETSc provides many of the mechanisms needed within parallel application codes, such as parallel matrix and vector assembly routines. The library is organized hierarchically, enabling users to employ the level of abstraction that is most appropriate for a particular problem. By using techniques of object-oriented programming, PETSc provides enormous flexibility for users.

PETSc is a sophisticated set of software tools; as such, for some users it initially has a much steeper learning curve than a simple subroutine library. In particular, for individuals without some computer science background, experience programming in C, C++, python, or Fortran and experience using a debugger such as gdb or dbx, it may require a significant amount of time to take full advantage of the features that enable efficient software use. However, the power of the PETSc design and the algorithms it incorporates may make the efficient implementation of many application codes simpler than “rolling them” yourself.

  • For many tasks a package such as MATLAB is often the best tool; PETSc is not intended for the classes of problems for which effective MATLAB code can be written.

  • There are several packages (listed on, built on PETSc, that may satisfy your needs without requiring directly using PETSc. We recommend reviewing these packages functionality before using PETSc.

  • PETSc should not be used to attempt to provide a “parallel linear solver” in an otherwise sequential code. Certainly all parts of a previously sequential code need not be parallelized but the matrix generation portion must be parallelized to expect any kind of reasonable performance. Do not expect to generate your matrix sequentially and then “use PETSc” to solve the linear system in parallel.

Since PETSc is under continued development, small changes in usage and calling sequences of routines will occur. PETSc is supported; see for information on contacting support.

A list of publications and web sites that feature work involving PETSc may be found at

We welcome any reports of corrections for this document at


Manual pages and example usage :

Installing PETSc :

Tutorials :