dev:codingconventions
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| dev:codingconventions [2016/03/16 13:32] – moved formatting conventions to separate page pseewald | dev:codingconventions [2026/10/14 08:40] (current) – fstein | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Coding Conventions ====== | ====== Coding Conventions ====== | ||
| - | ===== Stick to the standard ===== | ||
| - | * Code enabled by default should be standard Fortran2003 [-std=f2003] | ||
| - | * Avoid using new OOP aspects, because compilers do not yet support them well enough. | ||
| - | * OpenMP code should follow the version 3.X of the standard | ||
| - | * MPI should should follow the version 2.X of the standard | ||
| - | * Extended functionality should match [[wp> | ||
| - | ===== Write explicit code ===== | + | This page has been moved to [[https://manual.cp2k.org/trunk/development/coding-conventions.html]] |
| - | * Every '' | + | |
| - | * Every '' | + | |
| - | * Every static variable should be marked with the '' | + | |
| - | * Every Fortran module should contain the line '' | + | |
| - | * Every conversion that might change value should be explicit [-Wconversion]. Rationale: | + | |
| - | * INTEGER i=4.9999, i.e. i=INT(4.9999) implies i==4. Use NINT(4.9999) as appropriate. | + | |
| - | * natom*natom, | + | |
| - | * the global number of grid points (pw_grid_type%ngpts, | + | |
| - | + | ||
| - | ===== Don't use poorly designed language features ===== | + | |
| - | * Do not use the '' | + | |
| - | * Do not use left-hand-side (lhs) reallocations of allocatables [-Wrealloc-lhs-all]. [[http:// | + | |
| - | * Do not use '' | + | |
| - | * Do not use '' | + | |
| - | * Do not query the '' | + | |
| - | * Do not use '' | + | |
| - | + | ||
| - | ===== Fight spaghetti code ===== | + | |
| - | There are two measure of defense against [[wp> | + | |
| - | - Decoupling on the module and package level: | + | |
| - | * Every module should depend on as few other modules as possible. | + | |
| - | * Every package should depend on as few other packages as possible. | + | |
| - | - [[wp> | + | |
| - | * External libraries should be wrapped within a single module or package. | + | |
| - | * Every module should hide its content by containing the line '' | + | |
| - | * Every package should hide its content by providing only a small public API through a single module. | + | |
| - | + | ||
| - | ===== Use existing infrastructure ===== | + | |
| - | For many common operation there exist wrappers in CP2K to prevent usage errors and to allow for central redirections. | + | |
| - | * Use the routines from '' | + | |
| - | * Use the routines from the full-matrix '' | + | |
| - | * Use the routines from '' | + | |
| - | * Use the routines from '' | + | |
| - | * Don't use '' | + | |
| - | * Use [[error_handling|CP2K' | + | |
| - | + | ||
| - | ===== Remove dead code ===== | + | |
| - | * Every line of code has to be compiled and maintained. Hence, unused variables and code poses an unnecessary burden and should be removed | + | |
| - | * Sometimes it is beneficial to keep debugging code around nevertheless. Such code should be put into a '' | + | |
| - | + | ||
| - | ===== Format and document code ===== | + | |
| - | * Each files should start with the official CP2K header. | + | |
| - | * Each '' | + | |
| - | * Each module and routine should be annotated with [[dev: | + | |
| - | * Each preprocessor flag should start with two underscores and be documented in the '' | + | |
| - | * The code should be formatted with the prettify-tool by running '' | + | |
| - | + | ||
| - | ===== Write tests ===== | + | |
| - | * Every feature should be tested, with the goal of complete [[ http://www.cp2k.org/static/coverage/ | code coverage by regtesting ]]. | + | |
| - | + | ||
| - | ===== Doxygen documentation ===== | + | |
| - | + | ||
| - | * Every '' | + | |
| - | * The following keywords are required: '' | + | |
| - | * The following keywords are optional: '' | + | |
| - | * Please run '' | + | |
| - | * See our [[ http:// | + | |
dev/codingconventions.1458135132.txt.gz · Last modified: (external edit)
