14bcd95a3SBarry Smith(style)= 24bcd95a3SBarry Smith 34bcd95a3SBarry Smith# PETSc Style and Usage Guide 44bcd95a3SBarry Smith 54bcd95a3SBarry SmithThe PETSc team uses certain conventions to make the source code 64bcd95a3SBarry Smithconsistent and easier to maintain. We will interchangeably use the 74bcd95a3SBarry Smithterminology *subclass*, *implementation*, or *type* [^footnote-1] to refer to a 84bcd95a3SBarry Smithconcrete realization of an abstract base class. For example, 94bcd95a3SBarry Smith`KSPGMRES` is a type for the base class `KSP`. 104bcd95a3SBarry Smith 114bcd95a3SBarry Smith## Names 124bcd95a3SBarry Smith 134bcd95a3SBarry SmithConsistency of names for variables, functions, and so on is extremely 144bcd95a3SBarry Smithimportant. We use several conventions 154bcd95a3SBarry Smith 164bcd95a3SBarry Smith01. All function names and enum types consist of acronyms or words, each 174bcd95a3SBarry Smith of which is capitalized, for example, `KSPSolve()` and 184bcd95a3SBarry Smith `MatGetOrdering()`. 194bcd95a3SBarry Smith 204bcd95a3SBarry Smith02. All enum elements and macro variables are named with all capital 214bcd95a3SBarry Smith letters. When they consist of several complete words, there is an 224bcd95a3SBarry Smith underscore between each word. For example, `MAT_FINAL_ASSEMBLY`. 234bcd95a3SBarry Smith 244bcd95a3SBarry Smith03. Functions that are private to PETSc (not callable by the application 254bcd95a3SBarry Smith code) either 264bcd95a3SBarry Smith 274bcd95a3SBarry Smith - have an appended `_Private` (for example, `StashValues_Private`) 284bcd95a3SBarry Smith or 294bcd95a3SBarry Smith - have an appended `_Subtype` (for example, `MatMultSeq_AIJ`). 304bcd95a3SBarry Smith 314bcd95a3SBarry Smith In addition, functions that are not intended for use outside of a 324bcd95a3SBarry Smith particular file are declared `static`. Also, see the item 334bcd95a3SBarry Smith on symbol visibility in {ref}`usage_of_petsc_functions_and_macros`. 344bcd95a3SBarry Smith 354bcd95a3SBarry Smith04. Function names in structures (for example, `_matops`) are the same 364bcd95a3SBarry Smith as the base application function name without the object prefix and 374bcd95a3SBarry Smith in lowercase. For example, `MatMultTranspose()` has a 384bcd95a3SBarry Smith structure name of `multtranspose`. 394bcd95a3SBarry Smith 404bcd95a3SBarry Smith05. Names of implementations of class functions should begin with the 414bcd95a3SBarry Smith function name, an underscore, and the name of the implementation, for 424bcd95a3SBarry Smith example, `KSPSolve_GMRES()`. 434bcd95a3SBarry Smith 444bcd95a3SBarry Smith06. Each application-usable function begins with the name of the class 454bcd95a3SBarry Smith object, followed by any subclass name, for example, 464bcd95a3SBarry Smith `ISInvertPermutation()`, `MatMult()`, or 474bcd95a3SBarry Smith `KSPGMRESSetRestart()`. 484bcd95a3SBarry Smith 494bcd95a3SBarry Smith07. Functions that PETSc provides as defaults for user-providable 504bcd95a3SBarry Smith functions end with `Default` (for example, `PetscSignalHandlerDefault()`). 514bcd95a3SBarry Smith 524bcd95a3SBarry Smith08. Options database keys are lower case, have an underscore between 534bcd95a3SBarry Smith words, and match the function name associated with the option without 544bcd95a3SBarry Smith the word “set” or “get”, for example, `-ksp_gmres_restart`. 554bcd95a3SBarry Smith 564bcd95a3SBarry Smith09. Specific `XXXType` values (for example, `MATSEQAIJ`) do not have 574bcd95a3SBarry Smith an underscore in them unless they refer to another package that uses 584bcd95a3SBarry Smith an underscore, for example, `MATSOLVERSUPERLU_DIST`. 594bcd95a3SBarry Smith 604bcd95a3SBarry Smith10. Typedefs for functions should end in `Fn` as in, for example, `SNESFunctionFn`. 614bcd95a3SBarry Smith 6276c63389SBarry Smith11. Use the phrase `infinity or NaN` not `NaN or infinity`. 6376c63389SBarry Smith 6476c63389SBarry Smith12. Use the abbreviation NaN for Not-a-Number. 6576c63389SBarry Smith 664bcd95a3SBarry Smith(stylepetsccount)= 674bcd95a3SBarry Smith 684bcd95a3SBarry Smith## PETSc and standard datatypes 694bcd95a3SBarry Smith 704bcd95a3SBarry Smith1. `PetscInt` is generally used for array indices, and array lengths. It 714bcd95a3SBarry Smith is a signed 32-bit or 64-bit `int` depending on the `./configure` option 724bcd95a3SBarry Smith `--with-64-bit-indices`. There is the possibility of integer overflow with the 734bcd95a3SBarry Smith 32-bit version. 744bcd95a3SBarry Smith 754bcd95a3SBarry Smith2. `PetscCount` is `ptrdiff_t`, (on 64-bit systems it is 64-bits) and should be used for array sizes (number of entries) 764bcd95a3SBarry Smith and indices that may become large. `PetscIntCast()` should always be used when converting 774bcd95a3SBarry Smith to `PetscInt` from `PetscCount`. Since, in most configurations an array of `PetscCount` requires twice the memory 784bcd95a3SBarry Smith of an array of `PetscInt` most index arrays (such as `ISGetIndices()` use `PetscInt`, 794bcd95a3SBarry Smith when these arrays get too large then `--with-64-bit-indices` must be used to 804bcd95a3SBarry Smith `./configure` PETSc. In most cases it is appropriate to use `PetscCount` in lieu of `PetscInt64`. 814bcd95a3SBarry Smith 824bcd95a3SBarry Smith3. `size_t` is used for variables that contain the amount of memory, generally in bytes. 834bcd95a3SBarry Smith It should **not** be used for the number of 844bcd95a3SBarry Smith entries in an array, or to index into an array, that should be `PetscCount`, or `PetscInt`. 85e87b5d96SPierre Jolivet Though `size_t` is unsigned and hence can have values larger than those that can be stored 864bcd95a3SBarry Smith in a `PetscCount` those sizes will never be reached in practice so it is ok to cast with `(PetscCount)` 874bcd95a3SBarry Smith from a `size_t` variable to a `PetscCount` variable, but **not** a `PetscInt`. 884bcd95a3SBarry Smith One should not blindly cast from a `PetscCount` or a `PetscInt` 894bcd95a3SBarry Smith to `size_t` since, when the value is negative, it will produce garbage. 904bcd95a3SBarry Smith 914bcd95a3SBarry Smith4. **Never** blindly put in a cast from a potentially longer (in number of bits) to a shorter integer such as 924bcd95a3SBarry Smith 934bcd95a3SBarry Smith ``` 944bcd95a3SBarry Smith PetscInt64 a 954bcd95a3SBarry Smith PetscInt b 964bcd95a3SBarry Smith b = (PetscInt)a 974bcd95a3SBarry Smith ``` 984bcd95a3SBarry Smith 994bcd95a3SBarry Smith simply to prevent a compiler warning. Use the appropriate PETSc cast function unless you 1004bcd95a3SBarry Smith absolutely know the value will fit in the lesser number of bits. 1014bcd95a3SBarry Smith 1024bcd95a3SBarry Smith5. 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 1034bcd95a3SBarry Smith names end in `_c`. Since not all installed MPI implementations have such support, use `MPIU_XXX()` routines 1044bcd95a3SBarry Smith that use `PetscCount` for count arguments and use the large count MPI versions when possible. 1054bcd95a3SBarry Smith When not possible they first check the size of the input count arguments and error if they 1064bcd95a3SBarry Smith will not fit in the MPI required `int`, if they fit then the standard MPI functions are automatically called. 1074bcd95a3SBarry Smith 1084bcd95a3SBarry Smith ``` 1094bcd95a3SBarry Smith sizeof(MPI_Count) >= sizeof(PetscCount) >= sizeof(PetscInt) 1104bcd95a3SBarry Smith sizeof(PetscInt64) >= sizeof(PetscCount) >= sizeof(PetscInt) 1114bcd95a3SBarry Smith sizeof(MPI_Count) may be strictly greater than sizeof(PetscInt64) 1124bcd95a3SBarry Smith ``` 1134bcd95a3SBarry Smith 1144bcd95a3SBarry Smith## Coding Conventions and Style 1154bcd95a3SBarry Smith 1164bcd95a3SBarry SmithWithin the PETSc source code, we adhere to the following guidelines so 1174bcd95a3SBarry Smiththat the code is uniform and easily maintained. 1184bcd95a3SBarry Smith 1194bcd95a3SBarry Smith### C Formatting 1204bcd95a3SBarry Smith 1214bcd95a3SBarry SmithThe `.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`. 1224bcd95a3SBarry Smith 1234bcd95a3SBarry SmithEven 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`. 1244bcd95a3SBarry Smith 1254bcd95a3SBarry Smith01. The prototypes for functions should not include the names of the 1264bcd95a3SBarry Smith variables 1274bcd95a3SBarry Smith 1284bcd95a3SBarry Smith ``` 1294bcd95a3SBarry Smith PETSC_EXTERN PetscErrorCode MyFunction(PetscInt); // Correct 1304bcd95a3SBarry Smith PETSC_EXTERN PetscErrorCode MyFunction(PetscInt myvalue); // Incorrect 1314bcd95a3SBarry Smith ``` 1324bcd95a3SBarry Smith 1334bcd95a3SBarry Smith02. All local variables of a particular type (for example, `PetscInt`) should be listed 1344bcd95a3SBarry Smith on the same line if possible; otherwise, they should be listed on adjacent lines. Note 1354bcd95a3SBarry Smith that pointers of different arity (levels of indirection) are considered to be different types. `clang-format` automatically 1364bcd95a3SBarry Smith handles the indenting shown below. 1374bcd95a3SBarry Smith 1384bcd95a3SBarry Smith ``` 1394bcd95a3SBarry Smith // Correct 1404bcd95a3SBarry Smith PetscInt a, b, c; 1414bcd95a3SBarry Smith PetscInt *d, *e; 1424bcd95a3SBarry Smith PetscInt **f; 1434bcd95a3SBarry Smith 1444bcd95a3SBarry Smith // Incorrect 1454bcd95a3SBarry Smith PetscInt a, b, c, *d, *e, **f; 1464bcd95a3SBarry Smith ``` 1474bcd95a3SBarry Smith 1484bcd95a3SBarry Smith03. Local variables should be initialized in their declaration when possible 1494bcd95a3SBarry Smith 1504bcd95a3SBarry Smith ``` 1514bcd95a3SBarry Smith // Correct 1524bcd95a3SBarry Smith PetscInt a = 11; 1534bcd95a3SBarry Smith 1544bcd95a3SBarry Smith PetscFunctionBegin; 1554bcd95a3SBarry Smith // use a 1564bcd95a3SBarry Smith 1574bcd95a3SBarry Smith // Incorrect 1584bcd95a3SBarry Smith PetscInt a; 1594bcd95a3SBarry Smith 1604bcd95a3SBarry Smith PetscFunctionBegin; 1614bcd95a3SBarry Smith a = 11; 1624bcd95a3SBarry Smith // use a 1634bcd95a3SBarry Smith ``` 1644bcd95a3SBarry Smith 1654bcd95a3SBarry Smith04. All PETSc subroutine code blocks *must* start with a single blank line between the local variable 1664bcd95a3SBarry Smith declarations followed by `PetscFunctionBegin`. 1674bcd95a3SBarry Smith 1684bcd95a3SBarry Smith ``` 1694bcd95a3SBarry Smith // Correct 1704bcd95a3SBarry Smith PetscInt x; 1714bcd95a3SBarry Smith 1724bcd95a3SBarry Smith PetscFunctionBegin; 1734bcd95a3SBarry Smith 1744bcd95a3SBarry Smith // Incorrect 1754bcd95a3SBarry Smith PetscInt x; 1764bcd95a3SBarry Smith PetscFunctionBegin; 1774bcd95a3SBarry Smith 1784bcd95a3SBarry Smith // Incorrect 1794bcd95a3SBarry Smith PetscInt x; 1804bcd95a3SBarry Smith y = 11; 1814bcd95a3SBarry Smith ``` 1824bcd95a3SBarry Smith 1834bcd95a3SBarry Smith05. Functions in PETSc examples, including `main()` should have `PetscFunctionBeginUser` as the first line after the local variable declarations. 1844bcd95a3SBarry Smith 1854bcd95a3SBarry Smith06. 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)`. 1864bcd95a3SBarry Smith 1874bcd95a3SBarry Smith07. Functions that do use return should use `return xx;` rather than `return(xx);` 1884bcd95a3SBarry Smith 1894bcd95a3SBarry Smith08. All PETSc function calls must have their return value checked for errors using the 1904bcd95a3SBarry Smith `PetscCall()` macro. This should be wrapped around the function in question. 1914bcd95a3SBarry Smith 1924bcd95a3SBarry Smith ``` 1934bcd95a3SBarry Smith PetscCall(MyFunction(...)); // Correct 1944bcd95a3SBarry Smith PetscErrorCode ierr = MyFunction(...);PetscCall(ierr); // Incorrect 1954bcd95a3SBarry Smith ``` 1964bcd95a3SBarry Smith 1974bcd95a3SBarry Smith The only exceptions to this rule are begin-end style macros which embed local variables 1984bcd95a3SBarry Smith or loops as part of their expansion 1994bcd95a3SBarry Smith (e.g. `PetscOptionsBegin()`/`PetscOptionsEnd()`). These handle errors internally 2004bcd95a3SBarry Smith and do not need error checking. 2014bcd95a3SBarry Smith 2024bcd95a3SBarry Smith ``` 2034bcd95a3SBarry Smith // Correct 2044bcd95a3SBarry Smith PetscOptionsBegin(...); 2054bcd95a3SBarry Smith PetscOptionsEnd(); 2064bcd95a3SBarry Smith ``` 2074bcd95a3SBarry Smith 2084bcd95a3SBarry Smith As a rule, always try to wrap the function first; if this fails to compile, you do 2094bcd95a3SBarry Smith not need to add the error checking. 2104bcd95a3SBarry Smith 2114bcd95a3SBarry Smith Calls to external package functions are generally made with `PetscCallExternal()` or its variants that are specialized for particular packages, for example `PetscCallBLAS()` 2124bcd95a3SBarry Smith 2134bcd95a3SBarry Smith09. Single operation `if` and `else` commands should not be wrapped in braces. They should be done as follows, 2144bcd95a3SBarry Smith 2154bcd95a3SBarry Smith ``` 2164bcd95a3SBarry Smith if ( ) XXXX; 2174bcd95a3SBarry Smith else YYY; 2184bcd95a3SBarry Smith ``` 2194bcd95a3SBarry Smith 2204bcd95a3SBarry Smith not 2214bcd95a3SBarry Smith 2224bcd95a3SBarry Smith ``` 2234bcd95a3SBarry Smith if ( ) {XXXX;} 2244bcd95a3SBarry Smith else {YYY;} 2254bcd95a3SBarry Smith ``` 2264bcd95a3SBarry Smith 2274bcd95a3SBarry Smith10. Do not leave sections of commented-out code or dead source code protected with `ifdef foo` in the source files. 2284bcd95a3SBarry Smith 2294bcd95a3SBarry Smith11. Use classic block comments (`/* There must be a space before the first word in the comment and a space at the end */`, 2304bcd95a3SBarry Smith (`/*Do not do this*/`) for multi-line comments, and `// Comment` for single-line comments in source files. 2314bcd95a3SBarry Smith 2324bcd95a3SBarry Smith12. Do not put a `*` at the beginning or end of each line of a multi-line comment. 2334bcd95a3SBarry Smith 2344bcd95a3SBarry Smith13. Do not use `/* ---- ... ----- */` or similar constructs to separate parts of source code files. 2354bcd95a3SBarry Smith 2364bcd95a3SBarry Smith14. Use appropriate grammar and spelling in the comments. 2374bcd95a3SBarry Smith 238ab69f2f7SSatish Balay15. All variables must be declared at the beginning of the code block (C90 2394bcd95a3SBarry Smith style), never mixed in with code. However, when variables are only used in a limited 2404bcd95a3SBarry Smith scope, it is encouraged to declare them in that scope. For example: 2414bcd95a3SBarry Smith 2424bcd95a3SBarry Smith ``` 2434bcd95a3SBarry Smith if (cond) { 2444bcd95a3SBarry Smith PetscScalar *tmp; 2454bcd95a3SBarry Smith 2464bcd95a3SBarry Smith PetscCall(PetscMalloc1(10, &tmp)); 2474bcd95a3SBarry Smith // use tmp 2484bcd95a3SBarry Smith PetscCall(PetscFree(tmp)); 2494bcd95a3SBarry Smith } 2504bcd95a3SBarry Smith ``` 2514bcd95a3SBarry Smith 2524bcd95a3SBarry Smith The only exception to this is variables used exclusively within a `for` loop, which must 2534bcd95a3SBarry Smith be declared inside the loop initializer: 2544bcd95a3SBarry Smith 2554bcd95a3SBarry Smith ``` 2564bcd95a3SBarry Smith // Correct 2574bcd95a3SBarry Smith for (PetscInt i = 0; i < n; ++i) { 2584bcd95a3SBarry Smith // loop body 2594bcd95a3SBarry Smith } 2604bcd95a3SBarry Smith ``` 2614bcd95a3SBarry Smith 2624bcd95a3SBarry Smith ``` 2634bcd95a3SBarry Smith // Correct, variable used outside of loop 2644bcd95a3SBarry Smith PetscInt i; 2654bcd95a3SBarry Smith ``` 2664bcd95a3SBarry Smith 2674bcd95a3SBarry Smith ``` 2684bcd95a3SBarry Smith for (i = 0; i < n; ++i) { 2694bcd95a3SBarry Smith // loop body 2704bcd95a3SBarry Smith } 2714bcd95a3SBarry Smith j = i; 2724bcd95a3SBarry Smith ``` 2734bcd95a3SBarry Smith 2744bcd95a3SBarry Smith ``` 2754bcd95a3SBarry Smith // Incorrect 2764bcd95a3SBarry Smith PetscInt i; 2774bcd95a3SBarry Smith ... 2784bcd95a3SBarry Smith for (i = 0; i < n; ++i) { 2794bcd95a3SBarry Smith // loop body 2804bcd95a3SBarry Smith } 2814bcd95a3SBarry Smith ``` 2824bcd95a3SBarry Smith 2834bcd95a3SBarry Smith16. Developers can use // to split very long lines when it improves code readability. For example 2844bcd95a3SBarry Smith 2854bcd95a3SBarry Smith ``` 2864bcd95a3SBarry Smith f[j][i].omega = xdot[j][i].omega + uxx + uyy // 2874bcd95a3SBarry Smith + (vxp * (u - x[j][i - 1].omega) + vxm * (x[j][i + 1].omega - u)) * hy // 2884bcd95a3SBarry Smith + (vyp * (u - x[j - 1][i].omega) + vym * (x[j + 1][i].omega - u)) * hx // 2894bcd95a3SBarry Smith - .5 * grashof * (x[j][i + 1].temp - x[j][i - 1].temp) * hy; 2904bcd95a3SBarry Smith ``` 2914bcd95a3SBarry Smith 2924bcd95a3SBarry Smith17. The use of `// clang-format off` is allowed in the source code but should only be used when necessary. It should not 2934bcd95a3SBarry Smith be used when trailing // to split lines works. 2944bcd95a3SBarry Smith 2954bcd95a3SBarry Smith ``` 2964bcd95a3SBarry Smith // clang-format off 2974bcd95a3SBarry Smith f ... 2984bcd95a3SBarry Smith // clang-format on 2994bcd95a3SBarry Smith ``` 3004bcd95a3SBarry Smith 3014bcd95a3SBarry Smith18. `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. 3024bcd95a3SBarry Smith 3034bcd95a3SBarry Smith### C Usage 3044bcd95a3SBarry Smith 3054bcd95a3SBarry Smith01. Do not use language features that are not in the intersection of C99, C++11, and MSVC 3064bcd95a3SBarry Smith v1900+ (Visual Studio 2015). Examples of such banned features include variable-length arrays. 3074bcd95a3SBarry Smith Note that variable-length arrays (including VLA-pointers) are not supported in C++ and 3084bcd95a3SBarry Smith were made optional in C11. You may use designated initializers via the 3094bcd95a3SBarry Smith `PetscDesignatedInitializer()` macro. 3104bcd95a3SBarry Smith 3114bcd95a3SBarry Smith02. Array and pointer arguments where the array values are not changed 3124bcd95a3SBarry Smith should be labeled as `const` arguments. 3134bcd95a3SBarry Smith 3144bcd95a3SBarry Smith03. Scalar values passed to functions should *never* be labeled as 3154bcd95a3SBarry Smith `const`. 3164bcd95a3SBarry Smith 3174bcd95a3SBarry Smith04. Subroutines that would normally have a `void **` argument to return 3184bcd95a3SBarry Smith a pointer to some data should be prototyped as `void *`. 3194bcd95a3SBarry Smith This prevents the caller from having to put a `(void **)` cast in 3204bcd95a3SBarry Smith each function call. See, for example, `DMDAVecGetArray()`. 3214bcd95a3SBarry Smith 3224bcd95a3SBarry Smith05. Do not use the `register` directive. 3234bcd95a3SBarry Smith 3244bcd95a3SBarry Smith06. Use `if (v == NULL)` or `if (flg == PETSC_TRUE)`, instead of using `if (!v)` or `if (flg)` or `if (!flg)`. 3254bcd95a3SBarry Smith 3264bcd95a3SBarry Smith07. Avoid `#ifdef` or `#ifndef` when possible. Rather, use `#if defined` or `#if 3274bcd95a3SBarry Smith !defined`. Better, use `PetscDefined()` (see below). The only exception to this 3284bcd95a3SBarry Smith rule is for header guards, where the `#ifndef` form is preferred (see below). 3294bcd95a3SBarry Smith 3304bcd95a3SBarry Smith08. Header guard macros should be done using `#pragma once`. This must be the very first 3314bcd95a3SBarry Smith non-comment line of the file. There must be no leading or trailing empty (non-comment) 3324bcd95a3SBarry Smith lines in the header. For example, do 3334bcd95a3SBarry Smith 3344bcd95a3SBarry Smith ``` 3354bcd95a3SBarry Smith /* 3364bcd95a3SBarry Smith It's OK to have 3374bcd95a3SBarry Smith 3384bcd95a3SBarry Smith comments 3394bcd95a3SBarry Smith */ 3404bcd95a3SBarry Smith // before the guard 3414bcd95a3SBarry Smith #pragma once 3424bcd95a3SBarry Smith 3434bcd95a3SBarry Smith // OK, other headers included after the guard 3444bcd95a3SBarry Smith #include <petscdm.h> 3454bcd95a3SBarry Smith #include <petscdevice.h> 3464bcd95a3SBarry Smith 3474bcd95a3SBarry Smith // OK, other preprocessor symbols defined after the guard 3484bcd95a3SBarry Smith #define FOO_BAR_BAZ 3494bcd95a3SBarry Smith 3504bcd95a3SBarry Smith // OK, regular symbols defined after the guard 3514bcd95a3SBarry Smith typedef struct _p_PetscFoo *PetscFoo; 3524bcd95a3SBarry Smith ... 3534bcd95a3SBarry Smith ``` 3544bcd95a3SBarry Smith 3554bcd95a3SBarry Smith Do not do 3564bcd95a3SBarry Smith 3574bcd95a3SBarry Smith ``` 3584bcd95a3SBarry Smith // ERROR, empty lines at the beginning of the header 3594bcd95a3SBarry Smith 3604bcd95a3SBarry Smith 3614bcd95a3SBarry Smith 3624bcd95a3SBarry Smith // ERROR, included other headers before the guard 3634bcd95a3SBarry Smith #include <petscdm.h> 3644bcd95a3SBarry Smith #include <petscdevice.h> 3654bcd95a3SBarry Smith 3664bcd95a3SBarry Smith // ERROR, defined other preprocessor symbols before the guard 3674bcd95a3SBarry Smith #define FOO_BAR_BAZ 3684bcd95a3SBarry Smith 3694bcd95a3SBarry Smith // ERROR, defined regular symbols before the guard 3704bcd95a3SBarry Smith typedef struct _p_PetscFoo *PetscFoo; 3714bcd95a3SBarry Smith 3724bcd95a3SBarry Smith #pragma once 3734bcd95a3SBarry Smith ``` 3744bcd95a3SBarry Smith 3754bcd95a3SBarry Smith09. Never use system random number generators such as `rand()` in PETSc 3764bcd95a3SBarry Smith code or examples because these can produce different results on 3774bcd95a3SBarry Smith different systems, thus making portability testing difficult. Instead, 3784bcd95a3SBarry Smith use `PetscRandom` which produces the same results regardless 3794bcd95a3SBarry Smith of the system used. 3804bcd95a3SBarry Smith 3814bcd95a3SBarry Smith10. Variadic macros may be used in PETSc, but must work with MSVC v1900+ (Visual Studio 3824bcd95a3SBarry Smith 2015). Most compilers have conforming implementations of the C99/C++11 rules for 3834bcd95a3SBarry Smith `__VA_ARGS__`, but MSVC's implementation is not conforming and may need workarounds. 3844bcd95a3SBarry Smith See `PetscDefined()` for an example of how to work around MSVC's limitations to write 3854bcd95a3SBarry Smith a macro that is usable in both. 3864bcd95a3SBarry Smith 3874bcd95a3SBarry Smith(usage_of_petsc_functions_and_macros)= 3884bcd95a3SBarry Smith 3894bcd95a3SBarry Smith### Usage of PETSc Functions and Macros 3904bcd95a3SBarry Smith 3914bcd95a3SBarry Smith01. Lengthy conditional preprocessor blocks should mark any `#else` or `#endif` 3924bcd95a3SBarry Smith directives with a comment containing (or explaining) either the boolean condition or 3934bcd95a3SBarry Smith the macro's name if the first directive tests whether one is defined. One 3944bcd95a3SBarry Smith should be able to read any part of the macroblock and find or deduce the 3954bcd95a3SBarry Smith initial `#if`. That is: 3964bcd95a3SBarry Smith 3974bcd95a3SBarry Smith ``` 3984bcd95a3SBarry Smith #if defined(MY_MACRO) 3994bcd95a3SBarry Smith // many lines of code 4004bcd95a3SBarry Smith #else // MY_MACRO (use name of macro) 4014bcd95a3SBarry Smith // many more lines of code 4024bcd95a3SBarry Smith #endif // MY_MACRO 4034bcd95a3SBarry Smith 4044bcd95a3SBarry Smith #if MY_MACRO > 10 4054bcd95a3SBarry Smith // code 4064bcd95a3SBarry Smith #else // MY_MACRO < 10 4074bcd95a3SBarry Smith // more code 4084bcd95a3SBarry Smith #endif // MY_MACRO > 10 4094bcd95a3SBarry Smith ``` 4104bcd95a3SBarry Smith 4114bcd95a3SBarry Smith02. Public PETSc include files, `petsc*.h`, should not reference 4124bcd95a3SBarry Smith private PETSc `petsc/private/*impl.h` include files. 4134bcd95a3SBarry Smith 4144bcd95a3SBarry Smith03. Public and private PETSc include files cannot reference include files 4154bcd95a3SBarry Smith located in the PETSc source tree. 4164bcd95a3SBarry Smith 4174bcd95a3SBarry Smith04. All public functions must sanity-check their arguments using the appropriate 4184bcd95a3SBarry Smith `PetscValidXXX()` macros. These must appear between `PetscFunctionBegin` and 4194bcd95a3SBarry Smith `PetscFunctionReturn()` For example 4204bcd95a3SBarry Smith 4214bcd95a3SBarry Smith ``` 4224bcd95a3SBarry Smith PetscErrorCode PetscPublicFunction(Vec v, PetscScalar *array, PetscInt collectiveInt) 4234bcd95a3SBarry Smith { 4244bcd95a3SBarry Smith PetscFunctionBegin; 4254bcd95a3SBarry Smith PetscValidHeaderSpecific(v, VEC_CLASSID, 1); 4264bcd95a3SBarry Smith PetscAssertPointer(array, 2); 4274bcd95a3SBarry Smith PetscValidLogicalCollectiveInt(v, collectiveInt, 3); 4284bcd95a3SBarry Smith ... 4294bcd95a3SBarry Smith PetscFunctionReturn(PETSC_SUCCESS); 4304bcd95a3SBarry Smith } 4314bcd95a3SBarry Smith ``` 4324bcd95a3SBarry Smith 4334bcd95a3SBarry Smith See `include/petsc/private/petscimpl.h` and search for "PetscValid" to see all 4344bcd95a3SBarry Smith available checker macros. 4354bcd95a3SBarry Smith 4364bcd95a3SBarry Smith05. When possible, use `PetscDefined()` instead of preprocessor conditionals. 4374bcd95a3SBarry Smith For example, use: 4384bcd95a3SBarry Smith 4394bcd95a3SBarry Smith ``` 4404bcd95a3SBarry Smith if (PetscDefined(USE_DEBUG)) { ... } 4414bcd95a3SBarry Smith ``` 4424bcd95a3SBarry Smith 4434bcd95a3SBarry Smith instead of: 4444bcd95a3SBarry Smith 4454bcd95a3SBarry Smith ``` 4464bcd95a3SBarry Smith #if defined(PETSC_USE_DEBUG) 4474bcd95a3SBarry Smith ... 4484bcd95a3SBarry Smith #endif 4494bcd95a3SBarry Smith ``` 4504bcd95a3SBarry Smith 4514bcd95a3SBarry Smith The former usage allows syntax and type-checking in all configurations of 4524bcd95a3SBarry Smith PETSc, whereas the latter needs to be compiled with and without debugging 4534bcd95a3SBarry Smith to confirm that it compiles. 4544bcd95a3SBarry Smith 4554bcd95a3SBarry Smith06. *Never* put a function call in a `return` statement; do not write 4564bcd95a3SBarry Smith 4574bcd95a3SBarry Smith ``` 4584bcd95a3SBarry Smith PetscFunctionReturn( somefunction(...) ); /* Incorrect */ 4594bcd95a3SBarry Smith ``` 4604bcd95a3SBarry Smith 4614bcd95a3SBarry Smith07. Do *not* put a blank line immediately after `PetscFunctionBegin;` 4624bcd95a3SBarry Smith or a blank line immediately before `PetscFunctionReturn(PETSC_SUCCESS);`. 4634bcd95a3SBarry Smith 4644bcd95a3SBarry Smith08. Do not include `assert.h` in PETSc source code. Do not use 4654bcd95a3SBarry Smith `assert()`, it doesn’t play well in the parallel MPI world. 4664bcd95a3SBarry Smith You may use `PetscAssert()` where appropriate. See `PetscCall()` documentation 4674bcd95a3SBarry Smith for guidance of when to use `PetscCheck()` vs. `PetscAssert()`. 4684bcd95a3SBarry Smith 4694bcd95a3SBarry Smith09. Make error messages short but informative. The user should be able to reasonably 4704bcd95a3SBarry Smith diagnose the greater problem from your error message. 4714bcd95a3SBarry Smith 4724bcd95a3SBarry Smith10. Except in code that may be called before PETSc is fully initialized, 4734bcd95a3SBarry Smith always use `PetscMallocN()` (for example, `PetscMalloc1()`), 4744bcd95a3SBarry Smith `PetscCallocN()`, `PetscNew()`, and `PetscFree()`, not 4754bcd95a3SBarry Smith `malloc()` and `free()`. 4764bcd95a3SBarry Smith 4774bcd95a3SBarry Smith11. MPI routines and macros that are not part of the 2.1 standard 4784bcd95a3SBarry Smith should not be used in PETSc without appropriate `configure` 4794bcd95a3SBarry Smith checks and `#if PetscDefined()` checks. Code should also be provided 4804bcd95a3SBarry Smith that works if the MPI feature is not available; for example, 4814bcd95a3SBarry Smith 4824bcd95a3SBarry Smith ``` 4834bcd95a3SBarry Smith #if PetscDefined(HAVE_MPI_REDUCE_LOCAL) 4844bcd95a3SBarry Smith PetscCallMPI(MPI_Reduce_local(inbuf, inoutbuf, count, MPIU_INT, MPI_SUM)); 4854bcd95a3SBarry Smith #else 4864bcd95a3SBarry Smith PetscCallMPI(MPI_Reduce(inbuf, inoutbuf, count, MPIU_INT, MPI_SUM, 0, PETSC_COMM_SELF); 4874bcd95a3SBarry Smith #endif 4884bcd95a3SBarry Smith ``` 4894bcd95a3SBarry Smith 4904bcd95a3SBarry Smith12. Do not introduce PETSc routines that provide essentially the same 4914bcd95a3SBarry Smith functionality as an available MPI routine. For example, do not write 4924bcd95a3SBarry Smith a routine `PetscGlobalSum()` that takes a scalar value and performs 4934bcd95a3SBarry Smith an `MPI_Allreduce()` on it. Instead, use the MPI routine 4944bcd95a3SBarry Smith `MPI_Allreduce()` directly in the code. 4954bcd95a3SBarry Smith 4964bcd95a3SBarry Smith13. Never use a local variable counter such as `PetscInt flops = 0;` to 4974bcd95a3SBarry Smith accumulate flops and then call `PetscLogFlops();` *always* just 4984bcd95a3SBarry Smith call `PetscLogFlops()` directly when needed. 4994bcd95a3SBarry Smith 5004bcd95a3SBarry Smith14. Library symbols meant to be directly usable by the user should be declared 5014bcd95a3SBarry Smith `PETSC_EXTERN` in their respective public header file. Symbols intended for internal use should instead be declared `PETSC_INTERN`. Note that doing so is 5024bcd95a3SBarry Smith unnecessary in the case of symbols local to a single translation unit; these should 5034bcd95a3SBarry Smith be declared `static`. PETSc can be configured to build a separate shared 5044bcd95a3SBarry Smith library for each top-level class (`Mat`, `Vec`, `KSP`, and so on), and that plugin 5054bcd95a3SBarry Smith implementations of these classes can be included as separate shared libraries; thus, 5064bcd95a3SBarry Smith otherwise private symbols may need to be marked `PETSC_SINGLE_LIBRARY_INTERN`. For 5074bcd95a3SBarry Smith example 5084bcd95a3SBarry Smith 5094bcd95a3SBarry Smith - `MatStashCreate_Private()` is marked `PETSC_INTERN` as it is used 5104bcd95a3SBarry Smith across compilation units, but only within the `Mat` package; 5114bcd95a3SBarry Smith - all functions, such as `KSPCreate()`, included in the public 5124bcd95a3SBarry Smith headers (`include/petsc*.h`) should be marked `PETSC_EXTERN`; 5134bcd95a3SBarry Smith - `VecLoad_Default()` is marked 5144bcd95a3SBarry Smith `PETSC_SINGLE_LIBRARY_INTERN` as it may be used across library boundaries, but is 5154bcd95a3SBarry Smith not intended to be visible to users; 5164bcd95a3SBarry Smith 5174bcd95a3SBarry Smith15. Before removing or renaming an API function, type, or enumerator, 5184bcd95a3SBarry Smith `PETSC_DEPRECATED_XXX()` should be used in the relevant header file 5194bcd95a3SBarry Smith to indicate the new usage and the PETSc version number where the 5204bcd95a3SBarry Smith deprecation will first appear. The old function or type, with the 5214bcd95a3SBarry Smith deprecation warning, should remain for at least one major release. We do not remove support for the 5224bcd95a3SBarry Smith deprecated functionality unless there is a specific reason to remove it; it is not removed simply because 5234bcd95a3SBarry Smith it has been deprecated for "a long time." 5244bcd95a3SBarry Smith 5254bcd95a3SBarry Smith The function or type’s manual page should be updated (see {ref}`manual_page_format`). 5264bcd95a3SBarry Smith For example, 5274bcd95a3SBarry Smith 5284bcd95a3SBarry Smith ``` 5294bcd95a3SBarry Smith typedef NewType OldType PETSC_DEPRECATED_TYPEDEF("Use NewType (since version 3.9)"); 5304bcd95a3SBarry Smith 5314bcd95a3SBarry Smith PETSC_DEPRECATED_FUNCTION("Use NewFunction() (since version 3.9)") PetscErrorCode OldFunction(); 5324bcd95a3SBarry Smith 5334bcd95a3SBarry Smith #define OLD_ENUMERATOR_DEPRECATED OLD_ENUMERATOR PETSC_DEPRECATED_ENUM("Use NEW_ENUMERATOR (since version 3.9)") 5344bcd95a3SBarry Smith typedef enum { 5354bcd95a3SBarry Smith OLD_ENUMERATOR_DEPRECATED = 3, 5364bcd95a3SBarry Smith NEW_ENUMERATOR = 3 5374bcd95a3SBarry Smith } MyEnum; 5384bcd95a3SBarry Smith ``` 5394bcd95a3SBarry Smith 5404bcd95a3SBarry Smith Note that after compiler preprocessing, the enum above would be transformed into something like 5414bcd95a3SBarry Smith 5424bcd95a3SBarry Smith ``` 5434bcd95a3SBarry Smith typedef enum { 5444bcd95a3SBarry Smith OLD_ENUMERATOR __attribute__((deprecated)) = 3, 5454bcd95a3SBarry Smith NEW_ENUMERATOR = 3 5464bcd95a3SBarry Smith } MyEnum; 5474bcd95a3SBarry Smith ``` 5484bcd95a3SBarry Smith 5494bcd95a3SBarry Smith16. Before removing or renaming an options database key, 5504bcd95a3SBarry Smith `PetscOptionsDeprecated()` should be used for at least one major 5514bcd95a3SBarry Smith release. We do not remove support for the 5524bcd95a3SBarry Smith deprecated functionality unless there is a specific reason to remove it; it is not removed simply because 5534bcd95a3SBarry Smith it has been deprecated for "a long time." 5544bcd95a3SBarry Smith 5554bcd95a3SBarry Smith17. The format strings in PETSc ASCII output routines, such as 5564bcd95a3SBarry Smith `PetscPrintf()`, take a `%" PetscInt_FMT "` for all PETSc variables of type `PetscInt`, 5574bcd95a3SBarry Smith not a `%d`. 5584bcd95a3SBarry Smith 5594bcd95a3SBarry Smith18. All arguments of type `PetscReal` to PETSc ASCII output routines, 5604bcd95a3SBarry Smith such as `PetscPrintf`, must be cast to `double`, for example, 5614bcd95a3SBarry Smith 5624bcd95a3SBarry Smith ``` 5634bcd95a3SBarry Smith PetscPrintf(PETSC_COMM_WORLD, "Norm %g\n", (double)norm); 5644bcd95a3SBarry Smith ``` 5654bcd95a3SBarry Smith 5664bcd95a3SBarry Smith## Formatted Comments 5674bcd95a3SBarry Smith 5684bcd95a3SBarry SmithPETSc uses formatted comments and the Sowing packages {cite}`gropp1993sowing` {cite}`gropp1993sowing2` 5694bcd95a3SBarry Smithto generate documentation (manual pages) and the Fortran interfaces. Documentation 5704bcd95a3SBarry Smithfor Sowing and the formatting may be found at 5714bcd95a3SBarry Smith<http://wgropp.cs.illinois.edu/projects/software/sowing/>; in particular, 5724bcd95a3SBarry Smithsee the documentation for `doctext`. Currently, doctext produces Markdown files ending in `.md`, which 5734bcd95a3SBarry SmithSphinx later processes. 5744bcd95a3SBarry Smith 5754bcd95a3SBarry Smith- `/*@` 5764bcd95a3SBarry Smith a formatted comment of a function that will be used for documentation and a Fortran interface. 5774bcd95a3SBarry Smith- `/*@C` 5784bcd95a3SBarry Smith 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. 5794bcd95a3SBarry Smith- `/*E` 580fa084801SBarry Smith a formatted comment of an enum used for documentation only. 5814bcd95a3SBarry Smith . 5824bcd95a3SBarry Smith- `/*S` 5834bcd95a3SBarry Smith a formatted comment for a data type such as 5844bcd95a3SBarry Smith `KSP` 5854bcd95a3SBarry Smith . 5864bcd95a3SBarry Smith- `/*J` 5874bcd95a3SBarry Smith a formatted comment for a string type such as 5884bcd95a3SBarry Smith `KSPType` 5894bcd95a3SBarry Smith . 5904bcd95a3SBarry Smith- `/*MC` 5914bcd95a3SBarry Smith a formatted comment of a CPP macro or enum value for documentation. 5924bcd95a3SBarry Smith 5936dd63270SBarry SmithThe Fortran interface files supplied manually by the developer go into the 5946dd63270SBarry Smithdirectory `ftn-custom`, while those automatically generated 5956dd63270SBarry Smithgo into directories in the \$PETSC_ARCH/ftn\`\` directory tree. 5964bcd95a3SBarry Smith 5974bcd95a3SBarry SmithEach include file that contains formatted comments needs to have a line of the form 5984bcd95a3SBarry Smith 5994bcd95a3SBarry Smith> ``` 6004bcd95a3SBarry Smith> /* SUBMANSEC = submansec (for example Sys) */ 6014bcd95a3SBarry Smith> ``` 6024bcd95a3SBarry Smith 6034bcd95a3SBarry Smithpreceded 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 6044bcd95a3SBarry Smith 6054bcd95a3SBarry Smith> ``` 6064bcd95a3SBarry Smith> MANSEC = DM 6074bcd95a3SBarry Smith> SUBMANSEC= DMPlex 6084bcd95a3SBarry Smith> ``` 6094bcd95a3SBarry Smith 6104bcd95a3SBarry Smith(manual_page_format)= 6114bcd95a3SBarry Smith 6124bcd95a3SBarry Smith### Manual Page Format 6134bcd95a3SBarry Smith 6144bcd95a3SBarry SmithEach function, typedef, class, macro, enum, and so on in the public API 6154bcd95a3SBarry Smithshould include the following data, correctly formatted (see codes 6164bcd95a3SBarry Smithsection) to generate complete manual pages and (possibly) Fortran interfaces with 6174bcd95a3SBarry SmithSowing. All entries below should be separated by blank lines. Except 6184bcd95a3SBarry Smithwhere noted, add a newline after the section headings. 6194bcd95a3SBarry Smith 6204bcd95a3SBarry Smith01. The item’s name, followed by a dash and brief (one-sentence) 6214bcd95a3SBarry Smith description. 6224bcd95a3SBarry Smith 6234bcd95a3SBarry Smith02. If documenting a function implemented with a preprocessor macro 6244bcd95a3SBarry Smith (e.g., `PetscOptionsBegin()`), an explicit `Synopsis:` section 6254bcd95a3SBarry Smith noting the required header and the function signature. 6264bcd95a3SBarry Smith 6274bcd95a3SBarry Smith03. If documenting a function, a description of the function’s 6284bcd95a3SBarry Smith “collectivity”. 6294bcd95a3SBarry Smith 6304bcd95a3SBarry Smith - `Not Collective` if the function need not be called on multiple (or possibly all) MPI 6314bcd95a3SBarry Smith processes 6324bcd95a3SBarry Smith - `Collective` if the function is a collective operation. 6334bcd95a3SBarry Smith - `Logically Collective; yyy must contain common value]` 6344bcd95a3SBarry Smith if the function is collective but does not require any actual 6354bcd95a3SBarry Smith synchronization (e.g., setting class parameters uniformly). Any 6364bcd95a3SBarry Smith argument yyy, which must have the same value on all ranks of the 6374bcd95a3SBarry Smith MPI communicator should be noted here. 6384bcd95a3SBarry Smith 6394bcd95a3SBarry Smith04. If the function is not supported in Fortran, then after the collective information, on the same line, 6404bcd95a3SBarry Smith one should provide `; No Fortran support`. 6414bcd95a3SBarry Smith 6424bcd95a3SBarry Smith05. If documenting a function with input parameters, a list of input 6434bcd95a3SBarry Smith parameter descriptions in an `Input Parameter(s):` section. 6444bcd95a3SBarry Smith 6454bcd95a3SBarry Smith06. If documenting a function with output parameters, a list of output 6464bcd95a3SBarry Smith parameter descriptions in an `Output Parameter(s):` section. 6474bcd95a3SBarry Smith 6484bcd95a3SBarry Smith07. If any input or output parameters are function pointers, they should be documented in the style 6494bcd95a3SBarry Smith 6504bcd95a3SBarry Smith ```console 6514bcd95a3SBarry Smith Calling sequence of `func()`: 6524bcd95a3SBarry Smith . arg - the integer argument description 6534bcd95a3SBarry Smith ``` 6544bcd95a3SBarry Smith 6554bcd95a3SBarry Smith08. If documenting a function that interacts with the options database, a 6564bcd95a3SBarry Smith list of options database keys in an `Options Database Key(s):` 6574bcd95a3SBarry Smith section. 6584bcd95a3SBarry Smith 6594bcd95a3SBarry Smith09. `Level:` (no newline) followed by `beginner`, 6604bcd95a3SBarry Smith `intermediate`, `advanced`, `developer`, or `deprecated`. This 6614bcd95a3SBarry Smith should be listed before the various `Note(s):` sections. 6624bcd95a3SBarry Smith 6634bcd95a3SBarry Smith10. (Optional) a `Note(s):` section containing in-depth discussion, 6644bcd95a3SBarry Smith technical caveats, special cases, and so on. If it is ambiguous 6654bcd95a3SBarry Smith whether returned pointers/objects need to be freed/destroyed by the 6664bcd95a3SBarry Smith user or not, this information should be mentioned here. 6674bcd95a3SBarry Smith 6684bcd95a3SBarry Smith11. (If applicable) a `Fortran Note(s):` section detailing any relevant 6694bcd95a3SBarry Smith differences in calling or using the item from Fortran. 6704bcd95a3SBarry Smith 6714bcd95a3SBarry Smith12. (If applicable) a `Developer Note(s):` section detailing any relevant 6724bcd95a3SBarry Smith information about the code for developers, for example, why a 6734bcd95a3SBarry Smith particular algorithm was implemented. 6744bcd95a3SBarry Smith 6754bcd95a3SBarry Smith13. (If applicable) references should be indicated inline with \{cite}\`Bibtex-key\` where 6764bcd95a3SBarry Smith Bibtex-key is in the file `doc/petsc.bib`, as in the manual page for `PCFIELDSPLIT`. 6774bcd95a3SBarry Smith 6784bcd95a3SBarry Smith14. `.seealso:` (no newline, no spaces to the left of this text), followed by a list of related manual 6794bcd95a3SBarry Smith pages. These manual pages should usually also point back to this 680f8d70eaaSPierre Jolivet manual page in their `.seealso:` sections. This is the final entry in the 6814bcd95a3SBarry Smith comment. There should be no blank line after the `.seealso:` items. 6824bcd95a3SBarry Smith 6834bcd95a3SBarry Smith15. 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 6844bcd95a3SBarry Smith in single back tick marks. All PETSc enum types and macros etc, should also be enclosed in single back tick marks. 6854bcd95a3SBarry Smith This includes each item listed in the `.seealso:` lines. 6864bcd95a3SBarry Smith 6874bcd95a3SBarry Smith[^footnote-1]: Type also refers to the string name of the subclass. 6884bcd95a3SBarry Smith 689*1199fdcbSBarry Smith### Makefile formatting 690*1199fdcbSBarry Smith 691*1199fdcbSBarry Smith1. The line continuation character `"\"` should not have any spaces to its left or right 692*1199fdcbSBarry Smith 693*1199fdcbSBarry Smith2. Avoid double spaces in makefile rules. For example `"cat file | tr ..."` not `"cat file | tr ..."` 694*1199fdcbSBarry Smith 695*1199fdcbSBarry Smith3. Single space after `";"` but not before it. For example `"make ex1; make ex2"` not `"make ex1 ;make ex2"` 696*1199fdcbSBarry Smith 6974bcd95a3SBarry Smith### Spelling and Capitalization 6984bcd95a3SBarry Smith 6994bcd95a3SBarry Smith1. Proper nouns, including Unix, Linux, X Windows, and Microsoft Windows, should be fully written and capitalized. This includes all operating systems. 7004bcd95a3SBarry Smith The Apple computer operating system is written as macOS. 7014bcd95a3SBarry Smith2. Company names and product names should be capitalized. 7024bcd95a3SBarry Smith3. Company names and terms that are traditionally all capitalized, for example, MATLAB, NVIDIA, and CUDA, should be all capitalized. 7034bcd95a3SBarry Smith4. ARM is a family of processor designs, while Arm is the company that licenses them. 7044bcd95a3SBarry Smith5. Unix should not be all capitalized. 7054bcd95a3SBarry Smith6. Microsoft Windows should always be written out with two words. That is, it should not be shortened to Windows or MS Win etc. 7064bcd95a3SBarry Smith7. CMake should be capitalized as shown. 7074bcd95a3SBarry Smith8. BLAS and LAPACK are written in full capitalization. 7084bcd95a3SBarry Smith9. Open MPI is written as two words. 7094bcd95a3SBarry Smith 7104bcd95a3SBarry Smith## References 7114bcd95a3SBarry Smith 7124bcd95a3SBarry Smith```{bibliography} /petsc.bib 7134bcd95a3SBarry Smith:filter: docname in docnames 7144bcd95a3SBarry Smith``` 715