Contributing to PETSc#

As you gain experience in building, using, and debugging with PETSc, you will be able to contribute!

Before contributing code to PETSc, please read PETSc Style and Usage Guide. You may also be interested to read about The Design of PETSc.

PETSc uses Git, GitLab, and it’s testing system, for its source code management. All new code in PETSc is accepted via merge requests (MRs).

By submitting code, the contributor gives irretrievable consent to the redistribution and/or modification of the contributed source code as described in the PETSc open source license.


Some of the source code is documented to provide direct examples/templates for common contributions, adding new implementations for solver components:

Setting up Git#

We provide some information on common operations here; for more details, see git help, man git, or the Git book.

Obtaining the development version of PETSc#

  • If you have write access to the PETSc GitLab repository, use git clone (or use a clone you already have).

  • Otherwise, Create a fork (your own copy of the PETSc repository).

    • You will be asked to “Select a namespace to fork the project”; click the green “Select” button.

    • If you already have a clone on your machine of the PETSc repository you would like to reuse

      $ git remote set-url origin
    • otherwise

      $ git clone

PETSc can now be configured as specified on the Installation page

To update your copy of PETSc

$ git pull

Once updated, you will usually want to rebuild it completely

$ make reconfigure all

This is equivalent to

$ $PETSC_DIR/$PETSC_ARCH/lib/petsc/conf/reconfigure-$ && make all