xref: /petsc/doc/developers/contributing/index.md (revision 07e0cce2f581d3ca33bb5a422361c95101fcc977)
14bcd95a3SBarry Smith(ch_contributing)=
24bcd95a3SBarry Smith
34bcd95a3SBarry Smith# Contributing to PETSc
44bcd95a3SBarry Smith
54bcd95a3SBarry SmithAs you gain experience in building, using, and debugging with PETSc, you
64bcd95a3SBarry Smithwill be able to contribute!
74bcd95a3SBarry Smith
84bcd95a3SBarry SmithBefore contributing code to PETSc, please read {any}`style`. You may also
94bcd95a3SBarry Smithbe interested to read about {any}`design`.
104bcd95a3SBarry Smith
114bcd95a3SBarry SmithPETSc uses [Git](https://git-scm.com/), [GitLab](https://gitlab.com/petsc/petsc),
1235ec42e5SMassimiliano Leoniand its testing system, for its source code management.
134bcd95a3SBarry SmithAll new code in PETSc is accepted via merge requests (MRs).
144bcd95a3SBarry Smith
154bcd95a3SBarry SmithBy submitting code, the contributor gives irretrievable consent to the
164bcd95a3SBarry Smithredistribution and/or modification of the contributed source code as
174bcd95a3SBarry Smithdescribed in the [PETSc open-source license](https://gitlab.com/petsc/petsc/-/blob/main/CONTRIBUTING).
184bcd95a3SBarry Smith
194bcd95a3SBarry Smith## How-Tos
204bcd95a3SBarry Smith
214bcd95a3SBarry SmithSome of the source code is documented to provide direct examples/templates for common
224bcd95a3SBarry Smithcontributions, adding new implementations for solver components:
234bcd95a3SBarry Smith
244bcd95a3SBarry Smith- [Add a new PC type](https://gitlab.com/petsc/petsc/-/blob/main/src/ksp/pc/impls/jacobi/jacobi.c)
25*4fd5e42dSJared Frazier- [Add a new KSP type](https://gitlab.com/petsc/petsc/-/blob/main/src/ksp/ksp/impls/cg/cg.c)
26*4fd5e42dSJared Frazier- [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)
274bcd95a3SBarry Smith
284bcd95a3SBarry Smith(sec_git)=
294bcd95a3SBarry Smith
304bcd95a3SBarry Smith(sec_setup_git)=
314bcd95a3SBarry Smith
324bcd95a3SBarry Smith## Setting up Git
334bcd95a3SBarry Smith
344bcd95a3SBarry 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/).
354bcd95a3SBarry Smith
364bcd95a3SBarry Smith- [Install Git](https://git-scm.com/downloads) if it is not already installed on your machine, then see below to obtain PETSc.
374bcd95a3SBarry Smith- [Set up your Git environment](https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup) to establish your identity.
384bcd95a3SBarry Smith- To stay oriented when working with branches, we encourage configuring
394bcd95a3SBarry Smith  [git-prompt](https://raw.github.com/git/git/master/contrib/completion/git-prompt.sh).
404bcd95a3SBarry Smith- To get tab-completion for Git commands, one can download and then source
414bcd95a3SBarry Smith  [git-completion.bash](https://raw.github.com/git/git/master/contrib/completion/git-completion.bash).
424bcd95a3SBarry Smith
434bcd95a3SBarry Smith## Obtaining the development version of PETSc
444bcd95a3SBarry Smith
454bcd95a3SBarry Smith- If you have write access to the PETSc [GitLab repository](https://gitlab.com/petsc/petsc), use `git clone git@gitlab.com/petsc/petsc`
464bcd95a3SBarry Smith  (or use a clone you already have).
474bcd95a3SBarry Smith
484bcd95a3SBarry Smith- Otherwise, [Create a fork](https://gitlab.com/petsc/petsc/-/forks/new) (your own copy of the PETSc repository).
494bcd95a3SBarry Smith
504bcd95a3SBarry Smith  - You will be asked to "Select a namespace to fork the project"; click the green "Select" button.
514bcd95a3SBarry Smith
524bcd95a3SBarry Smith  - If you already have a clone on your machine of the PETSc repository you would like to reuse
534bcd95a3SBarry Smith
544bcd95a3SBarry Smith    ```console
554bcd95a3SBarry Smith    $ git remote set-url origin git@gitlab.com:YOURGITLABUSERNAME/petsc.git
564bcd95a3SBarry Smith    ```
574bcd95a3SBarry Smith
584bcd95a3SBarry Smith  - otherwise
594bcd95a3SBarry Smith
604bcd95a3SBarry Smith    ```console
614bcd95a3SBarry Smith    $ git clone git@gitlab.com:YOURGITLABUSERNAME/petsc.git
624bcd95a3SBarry Smith    ```
634bcd95a3SBarry Smith
644bcd95a3SBarry SmithPETSc can now be configured as specified on the
654bcd95a3SBarry Smith[Installation page](https://petsc.org/release/install/)
664bcd95a3SBarry Smith
674bcd95a3SBarry SmithTo update your copy of PETSc
684bcd95a3SBarry Smith
694bcd95a3SBarry Smith```console
704bcd95a3SBarry Smith$ git pull
714bcd95a3SBarry Smith```
724bcd95a3SBarry Smith
734bcd95a3SBarry SmithOnce updated, you will usually want to rebuild it completely
744bcd95a3SBarry Smith
754bcd95a3SBarry Smith```console
764bcd95a3SBarry Smith$ make reconfigure all
774bcd95a3SBarry Smith```
784bcd95a3SBarry Smith
794bcd95a3SBarry SmithThis is equivalent to
804bcd95a3SBarry Smith
814bcd95a3SBarry Smith```console
824bcd95a3SBarry Smith$ $PETSC_DIR/$PETSC_ARCH/lib/petsc/conf/reconfigure-$PETSC_ARCH.py && make all
834bcd95a3SBarry Smith```
844bcd95a3SBarry Smith
854bcd95a3SBarry Smith```{toctree}
864bcd95a3SBarry Smith:maxdepth: 1
874bcd95a3SBarry Smith
884bcd95a3SBarry Smithdevelopingmr
894bcd95a3SBarry Smithsubmittingmr
904bcd95a3SBarry Smithpipelines
914bcd95a3SBarry Smith```
92