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 6211. Use the phrase `infinity or NaN` not `NaN or infinity`. 63 6412. Use the abbreviation NaN for Not-a-Number. 65 66(stylepetsccount)= 67 68## PETSc and standard datatypes 69 701. `PetscInt` is generally used for array indices, and array lengths. It 71 is a signed 32-bit or 64-bit `int` depending on the `./configure` option 72 `--with-64-bit-indices`. There is the possibility of integer overflow with the 73 32-bit version. 74 752. `PetscCount` is `ptrdiff_t`, (on 64-bit systems it is 64-bits) and should be used for array sizes (number of entries) 76 and indices that may become large. `PetscIntCast()` should always be used when converting 77 to `PetscInt` from `PetscCount`. Since, in most configurations an array of `PetscCount` requires twice the memory 78 of an array of `PetscInt` most index arrays (such as `ISGetIndices()` use `PetscInt`, 79 when these arrays get too large then `--with-64-bit-indices` must be used to 80 `./configure` PETSc. In most cases it is appropriate to use `PetscCount` in lieu of `PetscInt64`. 81 823. `size_t` is used for variables that contain the amount of memory, generally in bytes. 83 It should **not** be used for the number of 84 entries in an array, or to index into an array, that should be `PetscCount`, or `PetscInt`. 85 Though `size_t` is unsigned and hence can have values larger than those that can be stored 86 in a `PetscCount` those sizes will never be reached in practice so it is ok to cast with `(PetscCount)` 87 from a `size_t` variable to a `PetscCount` variable, but **not** a `PetscInt`. 88 One should not blindly cast from a `PetscCount` or a `PetscInt` 89 to `size_t` since, when the value is negative, it will produce garbage. 90 914. **Never** blindly put in a cast from a potentially longer (in number of bits) to a shorter integer such as 92 93 ``` 94 PetscInt64 a 95 PetscInt b 96 b = (PetscInt)a 97 ``` 98 99 simply to prevent a compiler warning. Use the appropriate PETSc cast function unless you 100 absolutely know the value will fit in the lesser number of bits. 101 1025. 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 103 names end in `_c`. Since not all installed MPI implementations have such support, use `MPIU_XXX()` routines 104 that use `PetscCount` for count arguments and use the large count MPI versions when possible. 105 When not possible they first check the size of the input count arguments and error if they 106 will not fit in the MPI required `int`, if they fit then the standard MPI functions are automatically called. 107 108 ``` 109 sizeof(MPI_Count) >= sizeof(PetscCount) >= sizeof(PetscInt) 110 sizeof(PetscInt64) >= sizeof(PetscCount) >= sizeof(PetscInt) 111 sizeof(MPI_Count) may be strictly greater than sizeof(PetscInt64) 112 ``` 113 114## Coding Conventions and Style 115 116Within the PETSc source code, we adhere to the following guidelines so 117that the code is uniform and easily maintained. 118 119### C Formatting 120 121The `.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`. 122 123Even 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`. 124 12501. The prototypes for functions should not include the names of the 126 variables 127 128 ``` 129 PETSC_EXTERN PetscErrorCode MyFunction(PetscInt); // Correct 130 PETSC_EXTERN PetscErrorCode MyFunction(PetscInt myvalue); // Incorrect 131 ``` 132 13302. All local variables of a particular type (for example, `PetscInt`) should be listed 134 on the same line if possible; otherwise, they should be listed on adjacent lines. Note 135 that pointers of different arity (levels of indirection) are considered to be different types. `clang-format` automatically 136 handles the indenting shown below. 137 138 ``` 139 // Correct 140 PetscInt a, b, c; 141 PetscInt *d, *e; 142 PetscInt **f; 143 144 // Incorrect 145 PetscInt a, b, c, *d, *e, **f; 146 ``` 147 14803. Local variables should be initialized in their declaration when possible 149 150 ``` 151 // Correct 152 PetscInt a = 11; 153 154 PetscFunctionBegin; 155 // use a 156 157 // Incorrect 158 PetscInt a; 159 160 PetscFunctionBegin; 161 a = 11; 162 // use a 163 ``` 164 16504. All PETSc subroutine code blocks *must* start with a single blank line between the local variable 166 declarations followed by `PetscFunctionBegin`. 167 168 ``` 169 // Correct 170 PetscInt x; 171 172 PetscFunctionBegin; 173 174 // Incorrect 175 PetscInt x; 176 PetscFunctionBegin; 177 178 // Incorrect 179 PetscInt x; 180 y = 11; 181 ``` 182 18305. Functions in PETSc examples, including `main()` should have `PetscFunctionBeginUser` as the first line after the local variable declarations. 184 18506. 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)`. 186 18707. Functions that do use return should use `return xx;` rather than `return(xx);` 188 18908. All PETSc function calls must have their return value checked for errors using the 190 `PetscCall()` macro. This should be wrapped around the function in question. 191 192 ``` 193 PetscCall(MyFunction(...)); // Correct 194 PetscErrorCode ierr = MyFunction(...);PetscCall(ierr); // Incorrect 195 ``` 196 197 The only exceptions to this rule are begin-end style macros which embed local variables 198 or loops as part of their expansion 199 (e.g. `PetscOptionsBegin()`/`PetscOptionsEnd()`). These handle errors internally 200 and do not need error checking. 201 202 ``` 203 // Correct 204 PetscOptionsBegin(...); 205 PetscOptionsEnd(); 206 ``` 207 208 As a rule, always try to wrap the function first; if this fails to compile, you do 209 not need to add the error checking. 210 211 Calls to external package functions are generally made with `PetscCallExternal()` or its variants that are specialized for particular packages, for example `PetscCallBLAS()` 212 21309. Single operation `if` and `else` commands should not be wrapped in braces. They should be done as follows, 214 215 ``` 216 if ( ) XXXX; 217 else YYY; 218 ``` 219 220 not 221 222 ``` 223 if ( ) {XXXX;} 224 else {YYY;} 225 ``` 226 22710. Do not leave sections of commented-out code or dead source code protected with `ifdef foo` in the source files. 228 22911. Use classic block comments (`/* There must be a space before the first word in the comment and a space at the end */`, 230 (`/*Do not do this*/`) for multi-line comments, and `// Comment` for single-line comments in source files. 231 23212. Do not put a `*` at the beginning or end of each line of a multi-line comment. 233 23413. Do not use `/* ---- ... ----- */` or similar constructs to separate parts of source code files. 235 23614. Use appropriate grammar and spelling in the comments. 237 23815. All variables must be declared at the beginning of the code block (C90 239 style), never mixed in with code. However, when variables are only used in a limited 240 scope, it is encouraged to declare them in that scope. For example: 241 242 ``` 243 if (cond) { 244 PetscScalar *tmp; 245 246 PetscCall(PetscMalloc1(10, &tmp)); 247 // use tmp 248 PetscCall(PetscFree(tmp)); 249 } 250 ``` 251 252 The only exception to this is variables used exclusively within a `for` loop, which must 253 be declared inside the loop initializer: 254 255 ``` 256 // Correct 257 for (PetscInt i = 0; i < n; ++i) { 258 // loop body 259 } 260 ``` 261 262 ``` 263 // Correct, variable used outside of loop 264 PetscInt i; 265 ``` 266 267 ``` 268 for (i = 0; i < n; ++i) { 269 // loop body 270 } 271 j = i; 272 ``` 273 274 ``` 275 // Incorrect 276 PetscInt i; 277 ... 278 for (i = 0; i < n; ++i) { 279 // loop body 280 } 281 ``` 282 28316. Developers can use // to split very long lines when it improves code readability. For example 284 285 ``` 286 f[j][i].omega = xdot[j][i].omega + uxx + uyy // 287 + (vxp * (u - x[j][i - 1].omega) + vxm * (x[j][i + 1].omega - u)) * hy // 288 + (vyp * (u - x[j - 1][i].omega) + vym * (x[j + 1][i].omega - u)) * hx // 289 - .5 * grashof * (x[j][i + 1].temp - x[j][i - 1].temp) * hy; 290 ``` 291 29217. The use of `// clang-format off` is allowed in the source code but should only be used when necessary. It should not 293 be used when trailing // to split lines works. 294 295 ``` 296 // clang-format off 297 f ... 298 // clang-format on 299 ``` 300 30118. `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. 302 303### C Usage 304 30501. Do not use language features that are not in the intersection of C99, C++11, and MSVC 306 v1900+ (Visual Studio 2015). Examples of such banned features include variable-length arrays. 307 Note that variable-length arrays (including VLA-pointers) are not supported in C++ and 308 were made optional in C11. You may use designated initializers via the 309 `PetscDesignatedInitializer()` macro. 310 31102. Array and pointer arguments where the array values are not changed 312 should be labeled as `const` arguments. 313 31403. Scalar values passed to functions should *never* be labeled as 315 `const`. 316 31704. Subroutines that would normally have a `void **` argument to return 318 a pointer to some data should be prototyped as `void *`. 319 This prevents the caller from having to put a `(void **)` cast in 320 each function call. See, for example, `DMDAVecGetArray()`. 321 32205. Do not use the `register` directive. 323 32406. Use `if (v == NULL)` or `if (flg == PETSC_TRUE)`, instead of using `if (!v)` or `if (flg)` or `if (!flg)`. 325 32607. Avoid `#ifdef` or `#ifndef` when possible. Rather, use `#if defined` or `#if 327 !defined`. Better, use `PetscDefined()` (see below). The only exception to this 328 rule is for header guards, where the `#ifndef` form is preferred (see below). 329 33008. Header guard macros should be done using `#pragma once`. This must be the very first 331 non-comment line of the file. There must be no leading or trailing empty (non-comment) 332 lines in the header. For example, do 333 334 ``` 335 /* 336 It's OK to have 337 338 comments 339 */ 340 // before the guard 341 #pragma once 342 343 // OK, other headers included after the guard 344 #include <petscdm.h> 345 #include <petscdevice.h> 346 347 // OK, other preprocessor symbols defined after the guard 348 #define FOO_BAR_BAZ 349 350 // OK, regular symbols defined after the guard 351 typedef struct _p_PetscFoo *PetscFoo; 352 ... 353 ``` 354 355 Do not do 356 357 ``` 358 // ERROR, empty lines at the beginning of the header 359 360 361 362 // ERROR, included other headers before the guard 363 #include <petscdm.h> 364 #include <petscdevice.h> 365 366 // ERROR, defined other preprocessor symbols before the guard 367 #define FOO_BAR_BAZ 368 369 // ERROR, defined regular symbols before the guard 370 typedef struct _p_PetscFoo *PetscFoo; 371 372 #pragma once 373 ``` 374 37509. Never use system random number generators such as `rand()` in PETSc 376 code or examples because these can produce different results on 377 different systems, thus making portability testing difficult. Instead, 378 use `PetscRandom` which produces the same results regardless 379 of the system used. 380 38110. Variadic macros may be used in PETSc, but must work with MSVC v1900+ (Visual Studio 382 2015). Most compilers have conforming implementations of the C99/C++11 rules for 383 `__VA_ARGS__`, but MSVC's implementation is not conforming and may need workarounds. 384 See `PetscDefined()` for an example of how to work around MSVC's limitations to write 385 a macro that is usable in both. 386 387(usage_of_petsc_functions_and_macros)= 388 389### Usage of PETSc Functions and Macros 390 39101. Lengthy conditional preprocessor blocks should mark any `#else` or `#endif` 392 directives with a comment containing (or explaining) either the boolean condition or 393 the macro's name if the first directive tests whether one is defined. One 394 should be able to read any part of the macroblock and find or deduce the 395 initial `#if`. That is: 396 397 ``` 398 #if defined(MY_MACRO) 399 // many lines of code 400 #else // MY_MACRO (use name of macro) 401 // many more lines of code 402 #endif // MY_MACRO 403 404 #if MY_MACRO > 10 405 // code 406 #else // MY_MACRO < 10 407 // more code 408 #endif // MY_MACRO > 10 409 ``` 410 41102. Public PETSc include files, `petsc*.h`, should not reference 412 private PETSc `petsc/private/*impl.h` include files. 413 41403. Public and private PETSc include files cannot reference include files 415 located in the PETSc source tree. 416 41704. All public functions must sanity-check their arguments using the appropriate 418 `PetscValidXXX()` macros. These must appear between `PetscFunctionBegin` and 419 `PetscFunctionReturn()` For example 420 421 ``` 422 PetscErrorCode PetscPublicFunction(Vec v, PetscScalar *array, PetscInt collectiveInt) 423 { 424 PetscFunctionBegin; 425 PetscValidHeaderSpecific(v, VEC_CLASSID, 1); 426 PetscAssertPointer(array, 2); 427 PetscValidLogicalCollectiveInt(v, collectiveInt, 3); 428 ... 429 PetscFunctionReturn(PETSC_SUCCESS); 430 } 431 ``` 432 433 See `include/petsc/private/petscimpl.h` and search for "PetscValid" to see all 434 available checker macros. 435 43605. When possible, use `PetscDefined()` instead of preprocessor conditionals. 437 For example, use: 438 439 ``` 440 if (PetscDefined(USE_DEBUG)) { ... } 441 ``` 442 443 instead of: 444 445 ``` 446 #if defined(PETSC_USE_DEBUG) 447 ... 448 #endif 449 ``` 450 451 The former usage allows syntax and type-checking in all configurations of 452 PETSc, whereas the latter needs to be compiled with and without debugging 453 to confirm that it compiles. 454 45506. *Never* put a function call in a `return` statement; do not write 456 457 ``` 458 PetscFunctionReturn( somefunction(...) ); /* Incorrect */ 459 ``` 460 46107. Do *not* put a blank line immediately after `PetscFunctionBegin;` 462 or a blank line immediately before `PetscFunctionReturn(PETSC_SUCCESS);`. 463 46408. Do not include `assert.h` in PETSc source code. Do not use 465 `assert()`, it doesn’t play well in the parallel MPI world. 466 You may use `PetscAssert()` where appropriate. See `PetscCall()` documentation 467 for guidance of when to use `PetscCheck()` vs. `PetscAssert()`. 468 46909. Make error messages short but informative. The user should be able to reasonably 470 diagnose the greater problem from your error message. 471 47210. Except in code that may be called before PETSc is fully initialized, 473 always use `PetscMallocN()` (for example, `PetscMalloc1()`), 474 `PetscCallocN()`, `PetscNew()`, and `PetscFree()`, not 475 `malloc()` and `free()`. 476 47711. MPI routines and macros that are not part of the 2.1 standard 478 should not be used in PETSc without appropriate `configure` 479 checks and `#if PetscDefined()` checks. Code should also be provided 480 that works if the MPI feature is not available; for example, 481 482 ``` 483 #if PetscDefined(HAVE_MPI_REDUCE_LOCAL) 484 PetscCallMPI(MPI_Reduce_local(inbuf, inoutbuf, count, MPIU_INT, MPI_SUM)); 485 #else 486 PetscCallMPI(MPI_Reduce(inbuf, inoutbuf, count, MPIU_INT, MPI_SUM, 0, PETSC_COMM_SELF); 487 #endif 488 ``` 489 49012. Do not introduce PETSc routines that provide essentially the same 491 functionality as an available MPI routine. For example, do not write 492 a routine `PetscGlobalSum()` that takes a scalar value and performs 493 an `MPI_Allreduce()` on it. Instead, use the MPI routine 494 `MPI_Allreduce()` directly in the code. 495 49613. Never use a local variable counter such as `PetscInt flops = 0;` to 497 accumulate flops and then call `PetscLogFlops();` *always* just 498 call `PetscLogFlops()` directly when needed. 499 50014. Library symbols meant to be directly usable by the user should be declared 501 `PETSC_EXTERN` in their respective public header file. Symbols intended for internal use should instead be declared `PETSC_INTERN`. Note that doing so is 502 unnecessary in the case of symbols local to a single translation unit; these should 503 be declared `static`. PETSc can be configured to build a separate shared 504 library for each top-level class (`Mat`, `Vec`, `KSP`, and so on), and that plugin 505 implementations of these classes can be included as separate shared libraries; thus, 506 otherwise private symbols may need to be marked `PETSC_SINGLE_LIBRARY_INTERN`. For 507 example 508 509 - `MatStashCreate_Private()` is marked `PETSC_INTERN` as it is used 510 across compilation units, but only within the `Mat` package; 511 - all functions, such as `KSPCreate()`, included in the public 512 headers (`include/petsc*.h`) should be marked `PETSC_EXTERN`; 513 - `VecLoad_Default()` is marked 514 `PETSC_SINGLE_LIBRARY_INTERN` as it may be used across library boundaries, but is 515 not intended to be visible to users; 516 51715. Before removing or renaming an API function, type, or enumerator, 518 `PETSC_DEPRECATED_XXX()` should be used in the relevant header file 519 to indicate the new usage and the PETSc version number where the 520 deprecation will first appear. The old function or type, with the 521 deprecation warning, should remain for at least one major release. We do not remove support for the 522 deprecated functionality unless there is a specific reason to remove it; it is not removed simply because 523 it has been deprecated for "a long time." 524 525 The function or type’s manual page should be updated (see {ref}`manual_page_format`). 526 For example, 527 528 ``` 529 typedef NewType OldType PETSC_DEPRECATED_TYPEDEF("Use NewType (since version 3.9)"); 530 531 PETSC_DEPRECATED_FUNCTION("Use NewFunction() (since version 3.9)") PetscErrorCode OldFunction(); 532 533 #define OLD_ENUMERATOR_DEPRECATED OLD_ENUMERATOR PETSC_DEPRECATED_ENUM("Use NEW_ENUMERATOR (since version 3.9)") 534 typedef enum { 535 OLD_ENUMERATOR_DEPRECATED = 3, 536 NEW_ENUMERATOR = 3 537 } MyEnum; 538 ``` 539 540 Note that after compiler preprocessing, the enum above would be transformed into something like 541 542 ``` 543 typedef enum { 544 OLD_ENUMERATOR __attribute__((deprecated)) = 3, 545 NEW_ENUMERATOR = 3 546 } MyEnum; 547 ``` 548 54916. Before removing or renaming an options database key, 550 `PetscOptionsDeprecated()` should be used for at least one major 551 release. We do not remove support for the 552 deprecated functionality unless there is a specific reason to remove it; it is not removed simply because 553 it has been deprecated for "a long time." 554 55517. The format strings in PETSc ASCII output routines, such as 556 `PetscPrintf()`, take a `%" PetscInt_FMT "` for all PETSc variables of type `PetscInt`, 557 not a `%d`. 558 55918. All arguments of type `PetscReal` to PETSc ASCII output routines, 560 such as `PetscPrintf`, must be cast to `double`, for example, 561 562 ``` 563 PetscPrintf(PETSC_COMM_WORLD, "Norm %g\n", (double)norm); 564 ``` 565 566## Formatted Comments 567 568PETSc uses formatted comments and the Sowing packages {cite}`gropp1993sowing` {cite}`gropp1993sowing2` 569to generate documentation (manual pages) and the Fortran interfaces. Documentation 570for Sowing and the formatting may be found at 571<http://wgropp.cs.illinois.edu/projects/software/sowing/>; in particular, 572see the documentation for `doctext`. Currently, doctext produces Markdown files ending in `.md`, which 573Sphinx later processes. 574 575- `/*@` 576 a formatted comment of a function that will be used for documentation and a Fortran interface. 577- `/*@C` 578 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. 579- `/*E` 580 a formatted comment of an enum used for documentation only. 581 . 582- `/*S` 583 a formatted comment for a data type such as 584 `KSP` 585 . 586- `/*J` 587 a formatted comment for a string type such as 588 `KSPType` 589 . 590- `/*MC` 591 a formatted comment of a CPP macro or enum value for documentation. 592 593The Fortran interface files supplied manually by the developer go into the 594directory `ftn-custom`, while those automatically generated 595go into directories in the \$PETSC_ARCH/ftn\`\` directory tree. 596 597Each include file that contains formatted comments needs to have a line of the form 598 599> ``` 600> /* SUBMANSEC = submansec (for example Sys) */ 601> ``` 602 603preceded 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 604 605> ``` 606> MANSEC = DM 607> SUBMANSEC= DMPlex 608> ``` 609 610(manual_page_format)= 611 612### Manual Page Format 613 614Each function, typedef, class, macro, enum, and so on in the public API 615should include the following data, correctly formatted (see codes 616section) to generate complete manual pages and (possibly) Fortran interfaces with 617Sowing. All entries below should be separated by blank lines. Except 618where noted, add a newline after the section headings. 619 62001. The item’s name, followed by a dash and brief (one-sentence) 621 description. 622 62302. If documenting a function implemented with a preprocessor macro 624 (e.g., `PetscOptionsBegin()`), an explicit `Synopsis:` section 625 noting the required header and the function signature. 626 62703. If documenting a function, a description of the function’s 628 “collectivity”. 629 630 - `Not Collective` if the function need not be called on multiple (or possibly all) MPI 631 processes 632 - `Collective` if the function is a collective operation. 633 - `Logically Collective; yyy must contain common value]` 634 if the function is collective but does not require any actual 635 synchronization (e.g., setting class parameters uniformly). Any 636 argument yyy, which must have the same value on all ranks of the 637 MPI communicator should be noted here. 638 63904. If the function is not supported in Fortran, then after the collective information, on the same line, 640 one should provide `; No Fortran support`. 641 64205. If documenting a function with input parameters, a list of input 643 parameter descriptions in an `Input Parameter(s):` section. 644 64506. If documenting a function with output parameters, a list of output 646 parameter descriptions in an `Output Parameter(s):` section. 647 64807. If any input or output parameters are function pointers, they should be documented in the style 649 650 ```console 651 Calling sequence of `func()`: 652 . arg - the integer argument description 653 ``` 654 65508. If documenting a function that interacts with the options database, a 656 list of options database keys in an `Options Database Key(s):` 657 section. 658 65909. `Level:` (no newline) followed by `beginner`, 660 `intermediate`, `advanced`, `developer`, or `deprecated`. This 661 should be listed before the various `Note(s):` sections. 662 66310. (Optional) a `Note(s):` section containing in-depth discussion, 664 technical caveats, special cases, and so on. If it is ambiguous 665 whether returned pointers/objects need to be freed/destroyed by the 666 user or not, this information should be mentioned here. 667 66811. (If applicable) a `Fortran Note(s):` section detailing any relevant 669 differences in calling or using the item from Fortran. 670 67112. (If applicable) a `Developer Note(s):` section detailing any relevant 672 information about the code for developers, for example, why a 673 particular algorithm was implemented. 674 67513. (If applicable) references should be indicated inline with \{cite}\`Bibtex-key\` where 676 Bibtex-key is in the file `doc/petsc.bib`, as in the manual page for `PCFIELDSPLIT`. 677 67814. `.seealso:` (no newline, no spaces to the left of this text), followed by a list of related manual 679 pages. These manual pages should usually also point back to this 680 manual page in their `.seealso:` sections. This is the final entry in the 681 comment. There should be no blank line after the `.seealso:` items. 682 68315. 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 684 in single back tick marks. All PETSc enum types and macros etc, should also be enclosed in single back tick marks. 685 This includes each item listed in the `.seealso:` lines. 686 687[^footnote-1]: Type also refers to the string name of the subclass. 688 689### Makefile formatting 690 6911. The line continuation character `"\"` should not have any spaces to its left or right 692 6932. Avoid double spaces in makefile rules. For example `"cat file | tr ..."` not `"cat file | tr ..."` 694 6953. Single space after `";"` but not before it. For example `"make ex1; make ex2"` not `"make ex1 ;make ex2"` 696 697### Spelling and Capitalization 698 6991. Proper nouns, including Unix, Linux, X Windows, and Microsoft Windows, should be fully written and capitalized. This includes all operating systems. 700 The Apple computer operating system is written as macOS. 7012. Company names and product names should be capitalized. 7023. Company names and terms that are traditionally all capitalized, for example, MATLAB, NVIDIA, and CUDA, should be all capitalized. 7034. ARM is a family of processor designs, while Arm is the company that licenses them. 7045. Unix should not be all capitalized. 7056. Microsoft Windows should always be written out with two words. That is, it should not be shortened to Windows or MS Win etc. 7067. CMake should be capitalized as shown. 7078. BLAS and LAPACK are written in full capitalization. 7089. Open MPI is written as two words. 709 710## References 711 712```{bibliography} /petsc.bib 713:filter: docname in docnames 714``` 715