xref: /petsc/doc/developers/style.md (revision 6dd63270497ad23dcf16ae500a87ff2b2a0b7474)
1(style)=
2
3# PETSc Style and Usage Guide
4
5The PETSc team uses certain conventions to make the source code
6consistent and easier to maintain. We will interchangeably use the
7terminology *subclass*, *implementation*, or *type* [^footnote-1] to refer to a
8concrete realization of an abstract base class. For example,
9`KSPGMRES` is a type for the base class `KSP`.
10
11## Names
12
13Consistency of names for variables, functions, and so on is extremely
14important. We use several conventions
15
1601. All function names and enum types consist of acronyms or words, each
17    of which is capitalized, for example, `KSPSolve()` and
18    `MatGetOrdering()`.
19
2002. All enum elements and macro variables are named with all capital
21    letters. When they consist of several complete words, there is an
22    underscore between each word. For example, `MAT_FINAL_ASSEMBLY`.
23
2403. Functions that are private to PETSc (not callable by the application
25    code) either
26
27    - have an appended `_Private` (for example, `StashValues_Private`)
28      or
29    - have an appended `_Subtype` (for example, `MatMultSeq_AIJ`).
30
31    In addition, functions that are not intended for use outside of a
32    particular file are declared `static`. Also, see the item
33    on symbol visibility in {ref}`usage_of_petsc_functions_and_macros`.
34
3504. Function names in structures (for example, `_matops`) are the same
36    as the base application function name without the object prefix and
37    in lowercase. For example, `MatMultTranspose()` has a
38    structure name of `multtranspose`.
39
4005. Names of implementations of class functions should begin with the
41    function name, an underscore, and the name of the implementation, for
42    example, `KSPSolve_GMRES()`.
43
4406. Each application-usable function begins with the name of the class
45    object, followed by any subclass name, for example,
46    `ISInvertPermutation()`, `MatMult()`, or
47    `KSPGMRESSetRestart()`.
48
4907. Functions that PETSc provides as defaults for user-providable
50    functions end with `Default` (for example, `PetscSignalHandlerDefault()`).
51
5208. Options database keys are lower case, have an underscore between
53    words, and match the function name associated with the option without
54    the word “set” or “get”, for example, `-ksp_gmres_restart`.
55
5609. Specific `XXXType` values (for example, `MATSEQAIJ`) do not have
57    an underscore in them unless they refer to another package that uses
58    an underscore, for example, `MATSOLVERSUPERLU_DIST`.
59
6010. Typedefs for functions should end in `Fn` as in, for example, `SNESFunctionFn`.
61
62(stylepetsccount)=
63
64## PETSc and standard datatypes
65
661. `PetscInt` is generally used for array indices, and array lengths. It
67   is a signed 32-bit or 64-bit `int` depending on the `./configure` option
68   `--with-64-bit-indices`. There is the possibility of integer overflow with the
69   32-bit version.
70
712. `PetscCount` is `ptrdiff_t`, (on 64-bit systems it is 64-bits) and should be used for array sizes (number of entries)
72   and indices that may become large. `PetscIntCast()` should always be used when converting
73   to `PetscInt` from `PetscCount`. Since, in most configurations an array of `PetscCount` requires twice the memory
74   of an array of `PetscInt` most index arrays (such as `ISGetIndices()` use `PetscInt`,
75   when these arrays get too large then `--with-64-bit-indices` must be used to
76   `./configure` PETSc. In most cases it is appropriate to use `PetscCount` in lieu of `PetscInt64`.
77
783. `size_t` is used for variables that contain the amount of memory, generally in bytes.
79   It should **not** be used for the number of
80   entries in an array, or to index into an array, that should be `PetscCount`, or `PetscInt`.
81   Though `size_t` is unsigned and hence can have values larger then those that can be stored
82   in a `PetscCount` those sizes will never be reached in practice so it is ok to cast with `(PetscCount)`
83   from a `size_t` variable to a `PetscCount` variable, but **not** a `PetscInt`.
84   One should not blindly cast from a `PetscCount` or a `PetscInt`
85   to `size_t` since, when the value is negative, it will produce garbage.
86
874. **Never** blindly put in a cast from a potentially longer (in number of bits) to a shorter integer such as
88
89   ```
90   PetscInt64 a
91   PetscInt b
92   b = (PetscInt)a
93   ```
94
95   simply to prevent a compiler warning. Use the appropriate PETSc cast function unless you
96   absolutely know the value will fit in the lesser number of bits.
97
985. MPI 4.0 supports the use of `MPI_Count` (large count) for many MPI functions that previously used `int` in a new API where the MPI function
99   names end in `_c`. Since not all installed MPI implementations have such support, use `MPIU_XXX()` routines
100   that use `PetscCount` for count arguments and use the large count MPI versions when possible.
101   When not possible they first check the size of the input count arguments and error if they
102   will not fit in the MPI required `int`, if they fit then the standard MPI functions are automatically called.
103
104   ```
105   sizeof(MPI_Count) >= sizeof(PetscCount) >= sizeof(PetscInt)
106   sizeof(PetscInt64) >= sizeof(PetscCount) >= sizeof(PetscInt)
107   sizeof(MPI_Count) may be strictly greater than sizeof(PetscInt64)
108   ```
109
110## Coding Conventions and Style
111
112Within the PETSc source code, we adhere to the following guidelines so
113that the code is uniform and easily maintained.
114
115### C Formatting
116
117The `.clang-format` file in the PETSc root directory controls the white space and basic layout. You can run the formatter in the entire repository with `make clangformat`. All merge requests must be properly formatted; this is automatically checked for merge requests with `make checkclangformat`.
118
119Even with the use of `clang-format` there are still many decisions about code formatting that must be constantly made. A subset of these is automatically checked for merge requests with `make checkbadSource`.
120
12101. The prototypes for functions should not include the names of the
122    variables
123
124    ```
125    PETSC_EXTERN PetscErrorCode MyFunction(PetscInt); // Correct
126    PETSC_EXTERN PetscErrorCode MyFunction(PetscInt myvalue); // Incorrect
127    ```
128
12902. All local variables of a particular type (for example, `PetscInt`) should be listed
130    on the same line if possible; otherwise, they should be listed on adjacent lines. Note
131    that pointers of different arity (levels of indirection) are considered to be different types. `clang-format` automatically
132    handles the indenting shown below.
133
134    ```
135    // Correct
136    PetscInt   a, b, c;
137    PetscInt  *d, *e;
138    PetscInt **f;
139
140    // Incorrect
141    PetscInt a, b, c, *d, *e, **f;
142    ```
143
14403. Local variables should be initialized in their declaration when possible
145
146    ```
147    // Correct
148    PetscInt a = 11;
149
150    PetscFunctionBegin;
151    // use a
152
153    // Incorrect
154    PetscInt a;
155
156    PetscFunctionBegin;
157    a = 11;
158    // use a
159    ```
160
16104. All PETSc subroutine code blocks *must* start with a single blank line between the local variable
162    declarations followed by `PetscFunctionBegin`.
163
164    ```
165    // Correct
166    PetscInt x;
167
168    PetscFunctionBegin;
169
170    // Incorrect
171    PetscInt x;
172    PetscFunctionBegin;
173
174    // Incorrect
175    PetscInt x;
176    y = 11;
177    ```
178
17905. Functions in PETSc examples, including `main()` should have `PetscFunctionBeginUser` as the first line after the local variable declarations.
180
18106. PETSc functions that begin `PetscFunctionBegin` must always return via `PetscFunctionReturn()`, or `PetscFunctionReturnVoid()`, not `return`. If the function returns a `PetscErrorCode`, then it must always return with `PetscFunctionReturn(PETSC_SUCCESS)`.
182
18307. Functions that do use return should use `return xx;` rather than `return(xx);`
184
18508. All PETSc function calls must have their return value checked for errors using the
186    `PetscCall()` macro. This should be wrapped around the function in question.
187
188    ```
189    PetscCall(MyFunction(...)); // Correct
190    PetscErrorCode ierr = MyFunction(...);PetscCall(ierr); // Incorrect
191    ```
192
193    The only exceptions to this rule are begin-end style macros which embed local variables
194    or loops as part of their expansion
195    (e.g. `PetscOptionsBegin()`/`PetscOptionsEnd()`). These handle errors internally
196    and do not need error checking.
197
198    ```
199    // Correct
200    PetscOptionsBegin(...);
201    PetscOptionsEnd();
202    ```
203
204    As a rule, always try to wrap the function first; if this fails to compile, you do
205    not need to add the error checking.
206
207    Calls to external package functions are generally made with `PetscCallExternal()` or its variants that are specialized for particular packages, for example `PetscCallBLAS()`
208
20909. Single operation `if` and `else` commands should not be wrapped in braces. They should be done as follows,
210
211    ```
212    if ( ) XXXX;
213    else YYY;
214    ```
215
216    not
217
218    ```
219    if ( ) {XXXX;}
220    else {YYY;}
221    ```
222
22310. Do not leave sections of commented-out code or dead source code protected with `ifdef foo` in the source files.
224
22511. Use classic block comments (`/* There must be a space before the first word in the comment and a space at the end */`,
226    (`/*Do not do this*/`) for multi-line comments, and `// Comment` for single-line comments in source files.
227
22812. Do not put a `*` at the beginning or end of each line of a multi-line comment.
229
23013. Do not use `/* ---- ... ----- */` or similar constructs to separate parts of source code files.
231
23214. Use appropriate grammar and spelling in the comments.
233
23415. All variables must be declared at the beginning of the code block (C89
235    style), never mixed in with code. However, when variables are only used in a limited
236    scope, it is encouraged to declare them in that scope. For example:
237
238    ```
239    if (cond) {
240      PetscScalar *tmp;
241
242      PetscCall(PetscMalloc1(10, &tmp));
243      // use tmp
244      PetscCall(PetscFree(tmp));
245    }
246    ```
247
248    The only exception to this is variables used exclusively within a `for` loop, which must
249    be declared inside the loop initializer:
250
251    ```
252    // Correct
253    for (PetscInt i = 0; i < n; ++i) {
254      // loop body
255    }
256    ```
257
258    ```
259    // Correct, variable used outside of loop
260    PetscInt i;
261    ```
262
263    ```
264    for (i = 0; i < n; ++i) {
265      // loop body
266    }
267    j = i;
268    ```
269
270    ```
271    // Incorrect
272    PetscInt i;
273    ...
274    for (i = 0; i < n; ++i) {
275      // loop body
276    }
277    ```
278
27916. Developers can use // to split very long lines when it improves code readability. For example
280
281    ```
282    f[j][i].omega = xdot[j][i].omega + uxx + uyy //
283                  + (vxp * (u - x[j][i - 1].omega) + vxm * (x[j][i + 1].omega - u)) * hy //
284                  + (vyp * (u - x[j - 1][i].omega) + vym * (x[j + 1][i].omega - u)) * hx //
285                  - .5 * grashof * (x[j][i + 1].temp - x[j][i - 1].temp) * hy;
286    ```
287
28817. The use of `// clang-format off` is allowed in the source code but should only be used when necessary. It should not
289    be used when trailing // to split lines works.
290
291    ```
292    // clang-format off
293    f ...
294    // clang-format on
295    ```
296
29718. `size` and `rank` should be used exclusively for the results of `MPI_Comm_size()` and `MPI_Comm_rank()` and other variable names for these values should be avoided unless necessary.
298
299### C Usage
300
30101. Do not use language features that are not in the intersection of C99, C++11, and MSVC
302    v1900+ (Visual Studio 2015). Examples of such banned features include variable-length arrays.
303    Note that variable-length arrays (including VLA-pointers) are not supported in C++ and
304    were made optional in C11. You may use designated initializers via the
305    `PetscDesignatedInitializer()` macro.
306
30702. Array and pointer arguments where the array values are not changed
308    should be labeled as `const` arguments.
309
31003. Scalar values passed to functions should *never* be labeled as
311    `const`.
312
31304. Subroutines that would normally have a `void **` argument to return
314    a pointer to some data should be prototyped as `void *`.
315    This prevents the caller from having to put a `(void **)` cast in
316    each function call. See, for example, `DMDAVecGetArray()`.
317
31805. Do not use the `register` directive.
319
32006. Use `if (v == NULL)` or `if (flg == PETSC_TRUE)`, instead of using `if (!v)` or `if (flg)` or `if (!flg)`.
321
32207. Avoid `#ifdef` or `#ifndef` when possible. Rather, use `#if defined` or `#if
323    !defined`. Better, use `PetscDefined()` (see below). The only exception to this
324    rule is for header guards, where the `#ifndef` form is preferred (see below).
325
32608. Header guard macros should be done using `#pragma once`. This must be the very first
327    non-comment line of the file. There must be no leading or trailing empty (non-comment)
328    lines in the header. For example, do
329
330    ```
331    /*
332      It's OK to have
333
334      comments
335    */
336    // before the guard
337    #pragma once
338
339    // OK, other headers included after the guard
340    #include <petscdm.h>
341    #include <petscdevice.h>
342
343    // OK, other preprocessor symbols defined after the guard
344    #define FOO_BAR_BAZ
345
346    // OK, regular symbols defined after the guard
347    typedef struct _p_PetscFoo *PetscFoo;
348    ...
349    ```
350
351    Do not do
352
353    ```
354    // ERROR, empty lines at the beginning of the header
355
356
357
358    // ERROR, included other headers before the guard
359    #include <petscdm.h>
360    #include <petscdevice.h>
361
362    // ERROR, defined other preprocessor symbols before the guard
363    #define FOO_BAR_BAZ
364
365    // ERROR, defined regular symbols before the guard
366    typedef struct _p_PetscFoo *PetscFoo;
367
368    #pragma once
369    ```
370
37109. Never use system random number generators such as `rand()` in PETSc
372    code or examples because these can produce different results on
373    different systems, thus making portability testing difficult. Instead,
374    use `PetscRandom` which produces the same results regardless
375    of the system used.
376
37710. Variadic macros may be used in PETSc, but must work with MSVC v1900+ (Visual Studio
378    2015). Most compilers have conforming implementations of the C99/C++11 rules for
379    `__VA_ARGS__`, but MSVC's implementation is not conforming and may need workarounds.
380    See `PetscDefined()` for an example of how to work around MSVC's limitations to write
381    a macro that is usable in both.
382
383(usage_of_petsc_functions_and_macros)=
384
385### Usage of PETSc Functions and Macros
386
38701. Lengthy conditional preprocessor blocks should mark any `#else` or `#endif`
388    directives with a comment containing (or explaining) either the boolean condition or
389    the macro's name if the first directive tests whether one is defined. One
390    should be able to read any part of the macroblock and find or deduce the
391    initial `#if`. That is:
392
393    ```
394    #if defined(MY_MACRO)
395    // many lines of code
396    #else // MY_MACRO (use name of macro)
397    // many more lines of code
398    #endif // MY_MACRO
399
400    #if MY_MACRO > 10
401    // code
402    #else // MY_MACRO < 10
403    // more code
404    #endif // MY_MACRO > 10
405    ```
406
40702. Public PETSc include files, `petsc*.h`, should not reference
408    private PETSc `petsc/private/*impl.h` include files.
409
41003. Public and private PETSc include files cannot reference include files
411    located in the PETSc source tree.
412
41304. All public functions must sanity-check their arguments using the appropriate
414    `PetscValidXXX()` macros. These must appear between `PetscFunctionBegin` and
415    `PetscFunctionReturn()` For example
416
417    ```
418    PetscErrorCode PetscPublicFunction(Vec v, PetscScalar *array, PetscInt collectiveInt)
419    {
420      PetscFunctionBegin;
421      PetscValidHeaderSpecific(v, VEC_CLASSID, 1);
422      PetscAssertPointer(array, 2);
423      PetscValidLogicalCollectiveInt(v, collectiveInt, 3);
424      ...
425      PetscFunctionReturn(PETSC_SUCCESS);
426    }
427    ```
428
429    See `include/petsc/private/petscimpl.h` and search for "PetscValid" to see all
430    available checker macros.
431
43205. When possible, use `PetscDefined()` instead of preprocessor conditionals.
433    For example, use:
434
435    ```
436    if (PetscDefined(USE_DEBUG)) { ... }
437    ```
438
439    instead of:
440
441    ```
442    #if defined(PETSC_USE_DEBUG)
443      ...
444    #endif
445    ```
446
447    The former usage allows syntax and type-checking in all configurations of
448    PETSc, whereas the latter needs to be compiled with and without debugging
449    to confirm that it compiles.
450
45106. *Never* put a function call in a `return` statement; do not write
452
453    ```
454    PetscFunctionReturn( somefunction(...) ); /* Incorrect */
455    ```
456
45707. Do *not* put a blank line immediately after `PetscFunctionBegin;`
458    or a blank line immediately before `PetscFunctionReturn(PETSC_SUCCESS);`.
459
46008. Do not include `assert.h` in PETSc source code. Do not use
461    `assert()`, it doesn’t play well in the parallel MPI world.
462    You may use `PetscAssert()` where appropriate. See `PetscCall()` documentation
463    for guidance of when to use `PetscCheck()` vs. `PetscAssert()`.
464
46509. Make error messages short but informative. The user should be able to reasonably
466    diagnose the greater problem from your error message.
467
46810. Except in code that may be called before PETSc is fully initialized,
469    always use `PetscMallocN()` (for example, `PetscMalloc1()`),
470    `PetscCallocN()`, `PetscNew()`, and `PetscFree()`, not
471    `malloc()` and `free()`.
472
47311. MPI routines and macros that are not part of the 2.1 standard
474    should not be used in PETSc without appropriate `configure`
475    checks and `#if PetscDefined()` checks. Code should also be provided
476    that works if the MPI feature is not available; for example,
477
478    ```
479    #if PetscDefined(HAVE_MPI_REDUCE_LOCAL)
480      PetscCallMPI(MPI_Reduce_local(inbuf, inoutbuf, count, MPIU_INT, MPI_SUM));
481    #else
482      PetscCallMPI(MPI_Reduce(inbuf, inoutbuf, count, MPIU_INT, MPI_SUM, 0, PETSC_COMM_SELF);
483    #endif
484    ```
485
48612. Do not introduce PETSc routines that provide essentially the same
487    functionality as an available MPI routine. For example, do not write
488    a routine `PetscGlobalSum()` that takes a scalar value and performs
489    an `MPI_Allreduce()` on it. Instead, use the MPI routine
490    `MPI_Allreduce()` directly in the code.
491
49213. Never use a local variable counter such as `PetscInt flops = 0;` to
493    accumulate flops and then call `PetscLogFlops();` *always* just
494    call `PetscLogFlops()` directly when needed.
495
49614. Library symbols meant to be directly usable by the user should be declared
497    `PETSC_EXTERN` in their respective public header file. Symbols intended for internal use should instead be declared `PETSC_INTERN`. Note that doing so is
498    unnecessary in the case of symbols local to a single translation unit; these should
499    be declared `static`. PETSc can be configured to build a separate shared
500    library for each top-level class (`Mat`, `Vec`, `KSP`, and so on), and that plugin
501    implementations of these classes can be included as separate shared libraries; thus,
502    otherwise private symbols may need to be marked `PETSC_SINGLE_LIBRARY_INTERN`. For
503    example
504
505    - `MatStashCreate_Private()` is marked `PETSC_INTERN` as it is used
506      across compilation units, but only within the `Mat` package;
507    - all functions, such as `KSPCreate()`, included in the public
508      headers (`include/petsc*.h`) should be marked `PETSC_EXTERN`;
509    - `VecLoad_Default()` is marked
510      `PETSC_SINGLE_LIBRARY_INTERN` as it may be used across library boundaries, but is
511      not intended to be visible to users;
512
51315. Before removing or renaming an API function, type, or enumerator,
514    `PETSC_DEPRECATED_XXX()` should be used in the relevant header file
515    to indicate the new usage and the PETSc version number where the
516    deprecation will first appear. The old function or type, with the
517    deprecation warning, should remain for at least one major release. We do not remove support for the
518    deprecated functionality unless there is a specific reason to remove it; it is not removed simply because
519    it has been deprecated for "a long time."
520
521    The function or type’s manual page should be updated (see {ref}`manual_page_format`).
522    For example,
523
524    ```
525    typedef NewType OldType PETSC_DEPRECATED_TYPEDEF("Use NewType (since version 3.9)");
526
527    PETSC_DEPRECATED_FUNCTION("Use NewFunction() (since version 3.9)") PetscErrorCode OldFunction();
528
529    #define OLD_ENUMERATOR_DEPRECATED  OLD_ENUMERATOR PETSC_DEPRECATED_ENUM("Use NEW_ENUMERATOR (since version 3.9)")
530    typedef enum {
531      OLD_ENUMERATOR_DEPRECATED = 3,
532      NEW_ENUMERATOR = 3
533    } MyEnum;
534    ```
535
536    Note that after compiler preprocessing, the enum above would be transformed into something like
537
538    ```
539    typedef enum {
540      OLD_ENUMERATOR __attribute__((deprecated)) = 3,
541      NEW_ENUMERATOR = 3
542    } MyEnum;
543    ```
544
54516. Before removing or renaming an options database key,
546    `PetscOptionsDeprecated()` should be used for at least one major
547    release. We do not remove support for the
548    deprecated functionality unless there is a specific reason to remove it; it is not removed simply because
549    it has been deprecated for "a long time."
550
55117. The format strings in PETSc ASCII output routines, such as
552    `PetscPrintf()`, take a `%" PetscInt_FMT "` for all PETSc variables of type `PetscInt`,
553    not a `%d`.
554
55518. All arguments of type `PetscReal` to PETSc ASCII output routines,
556    such as `PetscPrintf`, must be cast to `double`, for example,
557
558    ```
559    PetscPrintf(PETSC_COMM_WORLD, "Norm %g\n", (double)norm);
560    ```
561
562## Formatted Comments
563
564PETSc uses formatted comments and the Sowing packages {cite}`gropp1993sowing` {cite}`gropp1993sowing2`
565to generate documentation (manual pages) and the Fortran interfaces. Documentation
566for Sowing and the formatting may be found at
567<http://wgropp.cs.illinois.edu/projects/software/sowing/>; in particular,
568see the documentation for `doctext`. Currently, doctext produces Markdown files ending in `.md`, which
569Sphinx later processes.
570
571- `/*@`
572  a formatted comment of a function that will be used for documentation and a Fortran interface.
573- `/*@C`
574  a formatted comment of a function that will be used only for documentation, not to generate a Fortran interface. Certain constructs and usages do not yet support automatically generating a Fortran interface. In general, such labeled C functions should have a custom Fortran interface provided.
575- `/*E`
576  a formatted comment of an enum used for documentation only.
577  .
578- `/*S`
579  a formatted comment for a data type such as
580  `KSP`
581  .
582- `/*J`
583  a formatted comment for a string type such as
584  `KSPType`
585  .
586- `/*MC`
587  a formatted comment of a CPP macro or enum value for documentation.
588
589The Fortran interface files supplied manually by the developer go into the
590directory `ftn-custom`, while those automatically generated
591go into directories in the \$PETSC_ARCH/ftn\`\` directory tree.
592
593Each include file that contains formatted comments needs to have a line of the form
594
595> ```
596> /* SUBMANSEC = submansec (for example Sys) */
597> ```
598
599preceded by and followed by a blank line. For source code, this information is found in the makefile in that source code's directory in the format
600
601> ```
602> MANSEC   = DM
603> SUBMANSEC= DMPlex
604> ```
605
606(manual_page_format)=
607
608### Manual Page Format
609
610Each function, typedef, class, macro, enum, and so on in the public API
611should include the following data, correctly formatted (see codes
612section) to generate complete manual pages and (possibly) Fortran interfaces with
613Sowing. All entries below should be separated by blank lines. Except
614where noted, add a newline after the section headings.
615
61601. The item’s name, followed by a dash and brief (one-sentence)
617    description.
618
61902. If documenting a function implemented with a preprocessor macro
620    (e.g., `PetscOptionsBegin()`), an explicit `Synopsis:` section
621    noting the required header and the function signature.
622
62303. If documenting a function, a description of the function’s
624    “collectivity”.
625
626    - `Not Collective` if the function need not be called on multiple (or possibly all) MPI
627      processes
628    - `Collective` if the function is a collective operation.
629    - `Logically Collective; yyy must contain common value]`
630      if the function is collective but does not require any actual
631      synchronization (e.g., setting class parameters uniformly). Any
632      argument yyy, which must have the same value on all ranks of the
633      MPI communicator should be noted here.
634
63504. If the function is not supported in Fortran, then after the collective information, on the same line,
636    one should provide `; No Fortran support`.
637
63805. If documenting a function with input parameters, a list of input
639    parameter descriptions in an `Input Parameter(s):` section.
640
64106. If documenting a function with output parameters, a list of output
642    parameter descriptions in an `Output Parameter(s):` section.
643
64407. If any input or output parameters are function pointers, they should be documented in the style
645
646    ```console
647    Calling sequence of `func()`:
648    . arg - the integer argument description
649    ```
650
65108. If documenting a function that interacts with the options database, a
652    list of options database keys in an `Options Database Key(s):`
653    section.
654
65509. `Level:` (no newline) followed by `beginner`,
656    `intermediate`, `advanced`, `developer`, or `deprecated`. This
657    should be listed before the various `Note(s):` sections.
658
65910. (Optional) a `Note(s):` section containing in-depth discussion,
660    technical caveats, special cases, and so on. If it is ambiguous
661    whether returned pointers/objects need to be freed/destroyed by the
662    user or not, this information should be mentioned here.
663
66411. (If applicable) a `Fortran Note(s):` section detailing any relevant
665    differences in calling or using the item from Fortran.
666
66712. (If applicable) a `Developer Note(s):` section detailing any relevant
668    information about the code for developers, for example, why a
669    particular algorithm was implemented.
670
67113. (If applicable) references should be indicated inline with \{cite}\`Bibtex-key\` where
672    Bibtex-key is in the file `doc/petsc.bib`, as in the manual page for `PCFIELDSPLIT`.
673
67414. `.seealso:` (no newline, no spaces to the left of this text), followed by a list of related manual
675    pages. These manual pages should usually also point back to this
676    manual page in their `.seealso:` sections. This is the final entry in the
677    comment. There should be no blank line after the `.seealso:` items.
678
67915. All PETSc functions that appear in a manual page (except the one in the header at the top) should end with a `()` and be enclosed
680    in single back tick marks. All PETSc enum types and macros etc, should also be enclosed in single back tick marks.
681    This includes each item listed in the `.seealso:` lines.
682
683[^footnote-1]: Type also refers to the string name of the subclass.
684
685### Spelling and Capitalization
686
6871. Proper nouns, including Unix, Linux, X Windows, and Microsoft Windows, should be fully written and capitalized. This includes all operating systems.
688   The Apple computer operating system is written as macOS.
6892. Company names and product names should be capitalized.
6903. Company names and terms that are traditionally all capitalized, for example, MATLAB, NVIDIA, and CUDA, should be all capitalized.
6914. ARM is a family of processor designs, while Arm is the company that licenses them.
6925. Unix should not be all capitalized.
6936. Microsoft Windows should always be written out with two words. That is, it should not be shortened to Windows or MS Win etc.
6947. CMake should be capitalized as shown.
6958. BLAS and LAPACK are written in full capitalization.
6969. Open MPI is written as two words.
697
698## References
699
700```{bibliography} /petsc.bib
701:filter: docname in docnames
702```
703