Version 6 (modified by kanani, 6 years ago) (diff) |
---|
PALM coding rules
Why to follow some standards? - Because everyone has her/his own programming style, sort of a dialect. And as it is, no one can understand all the possible dialects. So what do we do? We learn and apply the coding standard to make PALM more easily readable for all current and future developers. Let's all work on that - together.
General
- Only ASCII characters allowed
- Line length limit: 80 (soft) | 120 (hard)
Indenting, spaces & line breaks
General module/subroutine structure (see Fig. 1)
- 0 whitespace in front of pre-processor directives
- 1 whitespace before MODULE, CONTAINS, SUBROUTINE (= first indention level)
- +3 whitespaces for all following indention levels
(only exception: ONLY list in USE statements +4 whitespaces)
- 1 whitespace between individual strings, and between strings and symbols/numbers
- 1 whitespace after ,
(only exception: 0 whitespace between array dimensions) - 1 whitespace before ::
(at minimum, see Sect. Alignment) - 2 whitespace after : and ::
- 1 blank line between enclosed blocks of instructions, assignments, clauses, statements, etc.
- "&" character for line continuation at position 80 (minimum), max at position 120
Whitespaces between brackets (see Fig. 1)
- 0 whitespace between string and (
- 1 whitespace after ( and before )
(only exception: 0 whitespace in dimensions)
Whitespaces in DO, IF blocks
(see Fig. 2)
Alignment
- Linebreaks
- ONLY lists
- at least block-wise alignment for same type of declaration
- of messages
Alphabetical sorting
except for CALLs to modules/subroutines
Lower/upper case
Commenting
Naming conventions
Operators
- e.g. /=, <, <=, ==, >, >=, etc. (not .GE., .LT., etc)
- .AND., .OR., .NOT.
Preprocessor directives
File header
- Files always start with a doxygen-readable comment line including the FORTRAN file name.
- This is followed by the license section. If your code originates from another model, please clarify the license and permissions for this code to enter the PALM model system. It might be necessary in that case to add some more information to this header.
- The revisions section will later include short notes of the changes applied to a specific svn revision of this file. The $Id$ string is required so that svn knows to generate the respective time stamp for a revision (see existing SOURCE files).
- Finally, involved authors are included, followed by a description of the purpose and functions of the module. If necessary, TODOs, notes and known bugs can be added. The "!>" indicate doxygen-readable comment lines, the "@" marks doxygen variables.
Attachments (5)
- rules_indent_loops.png (23.7 KB) - added by kanani 6 years ago.
- rules_align.png (137.0 KB) - added by kanani 6 years ago.
- rules_indent_general.png (75.4 KB) - added by kanani 6 years ago.
- rules_header.png (90.5 KB) - added by kanani 6 years ago.
- european_standards-1.pdf (99.2 KB) - added by kanani 6 years ago.
Download all attachments as: .zip