xref: /petsc/doc/developers/contributing/index.md (revision 4bcd95a3096906c174cd1a87ff30988eadf5695d)
1*4bcd95a3SBarry Smith(ch_contributing)=
2*4bcd95a3SBarry Smith
3*4bcd95a3SBarry Smith# Contributing to PETSc
4*4bcd95a3SBarry Smith
5*4bcd95a3SBarry SmithAs you gain experience in building, using, and debugging with PETSc, you
6*4bcd95a3SBarry Smithwill be able to contribute!
7*4bcd95a3SBarry Smith
8*4bcd95a3SBarry SmithBefore contributing code to PETSc, please read {any}`style`. You may also
9*4bcd95a3SBarry Smithbe interested to read about {any}`design`.
10*4bcd95a3SBarry Smith
11*4bcd95a3SBarry SmithPETSc uses [Git](https://git-scm.com/), [GitLab](https://gitlab.com/petsc/petsc),
12*4bcd95a3SBarry Smithand it's testing system, for its source code management.
13*4bcd95a3SBarry SmithAll new code in PETSc is accepted via merge requests (MRs).
14*4bcd95a3SBarry Smith
15*4bcd95a3SBarry SmithBy submitting code, the contributor gives irretrievable consent to the
16*4bcd95a3SBarry Smithredistribution and/or modification of the contributed source code as
17*4bcd95a3SBarry Smithdescribed in the [PETSc open-source license](https://gitlab.com/petsc/petsc/-/blob/main/CONTRIBUTING).
18*4bcd95a3SBarry Smith
19*4bcd95a3SBarry Smith## How-Tos
20*4bcd95a3SBarry Smith
21*4bcd95a3SBarry SmithSome of the source code is documented to provide direct examples/templates for common
22*4bcd95a3SBarry Smithcontributions, adding new implementations for solver components:
23*4bcd95a3SBarry Smith
24*4bcd95a3SBarry Smith- [Add a new PC type](https://gitlab.com/petsc/petsc/-/blob/main/src/ksp/pc/impls/jacobi/jacobi.c)
25*4bcd95a3SBarry Smith- [Add a new KSP type](https://gitlab.com/petsc/petsc/-/blob/main/src/ksp/ksp/impls/cg/cg.c.html)
26*4bcd95a3SBarry Smith- [Add a new subclass of a matrix type (implementation inheritance)](https://gitlab.com/petsc/petsc/-/blob/main/src/mat/impls/aij/seq/superlu/superlu.c.html)
27*4bcd95a3SBarry Smith
28*4bcd95a3SBarry Smith(sec_git)=
29*4bcd95a3SBarry Smith
30*4bcd95a3SBarry Smith(sec_setup_git)=
31*4bcd95a3SBarry Smith
32*4bcd95a3SBarry Smith## Setting up Git
33*4bcd95a3SBarry Smith
34*4bcd95a3SBarry SmithWe provide some information on common operations here; for more details, see `git help`, `man git`, or [the Git book](https://git-scm.com/book/en/).
35*4bcd95a3SBarry Smith
36*4bcd95a3SBarry Smith- [Install Git](https://git-scm.com/downloads) if it is not already installed on your machine, then see below to obtain PETSc.
37*4bcd95a3SBarry Smith- [Set up your Git environment](https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup) to establish your identity.
38*4bcd95a3SBarry Smith- To stay oriented when working with branches, we encourage configuring
39*4bcd95a3SBarry Smith  [git-prompt](https://raw.github.com/git/git/master/contrib/completion/git-prompt.sh).
40*4bcd95a3SBarry Smith- To get tab-completion for Git commands, one can download and then source
41*4bcd95a3SBarry Smith  [git-completion.bash](https://raw.github.com/git/git/master/contrib/completion/git-completion.bash).
42*4bcd95a3SBarry Smith
43*4bcd95a3SBarry Smith## Obtaining the development version of PETSc
44*4bcd95a3SBarry Smith
45*4bcd95a3SBarry Smith- If you have write access to the PETSc [GitLab repository](https://gitlab.com/petsc/petsc), use `git clone git@gitlab.com/petsc/petsc`
46*4bcd95a3SBarry Smith  (or use a clone you already have).
47*4bcd95a3SBarry Smith
48*4bcd95a3SBarry Smith- Otherwise, [Create a fork](https://gitlab.com/petsc/petsc/-/forks/new) (your own copy of the PETSc repository).
49*4bcd95a3SBarry Smith
50*4bcd95a3SBarry Smith  - You will be asked to "Select a namespace to fork the project"; click the green "Select" button.
51*4bcd95a3SBarry Smith
52*4bcd95a3SBarry Smith  - If you already have a clone on your machine of the PETSc repository you would like to reuse
53*4bcd95a3SBarry Smith
54*4bcd95a3SBarry Smith    ```console
55*4bcd95a3SBarry Smith    $ git remote set-url origin git@gitlab.com:YOURGITLABUSERNAME/petsc.git
56*4bcd95a3SBarry Smith    ```
57*4bcd95a3SBarry Smith
58*4bcd95a3SBarry Smith  - otherwise
59*4bcd95a3SBarry Smith
60*4bcd95a3SBarry Smith    ```console
61*4bcd95a3SBarry Smith    $ git clone git@gitlab.com:YOURGITLABUSERNAME/petsc.git
62*4bcd95a3SBarry Smith    ```
63*4bcd95a3SBarry Smith
64*4bcd95a3SBarry SmithPETSc can now be configured as specified on the
65*4bcd95a3SBarry Smith[Installation page](https://petsc.org/release/install/)
66*4bcd95a3SBarry Smith
67*4bcd95a3SBarry SmithTo update your copy of PETSc
68*4bcd95a3SBarry Smith
69*4bcd95a3SBarry Smith```console
70*4bcd95a3SBarry Smith$ git pull
71*4bcd95a3SBarry Smith```
72*4bcd95a3SBarry Smith
73*4bcd95a3SBarry SmithOnce updated, you will usually want to rebuild it completely
74*4bcd95a3SBarry Smith
75*4bcd95a3SBarry Smith```console
76*4bcd95a3SBarry Smith$ make reconfigure all
77*4bcd95a3SBarry Smith```
78*4bcd95a3SBarry Smith
79*4bcd95a3SBarry SmithThis is equivalent to
80*4bcd95a3SBarry Smith
81*4bcd95a3SBarry Smith```console
82*4bcd95a3SBarry Smith$ $PETSC_DIR/$PETSC_ARCH/lib/petsc/conf/reconfigure-$PETSC_ARCH.py && make all
83*4bcd95a3SBarry Smith```
84*4bcd95a3SBarry Smith
85*4bcd95a3SBarry Smith```{toctree}
86*4bcd95a3SBarry Smith:maxdepth: 1
87*4bcd95a3SBarry Smith
88*4bcd95a3SBarry Smithdevelopingmr
89*4bcd95a3SBarry Smithsubmittingmr
90*4bcd95a3SBarry Smithpipelines
91*4bcd95a3SBarry Smith```
92