Changes between Version 7 and Version 8 of doc/tec/developerrules/palmstandard
- Timestamp:
- Nov 5, 2018 6:50:45 PM (6 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
doc/tec/developerrules/palmstandard
v7 v8 1 1 = PALM coding rules = 2 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. 2 Why to follow some standards? - Because everyone has her/his own programming style, sort of a dialect, making it difficult for other developers to understand, extend, debug, or optimize the code. 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. We are aware that the PALM core doesn't completely comply with the following rules yet, but we are working on that. 3 \\ 4 Formulated rules and specifications are based on the specifications given for the ocean dynamics model [add-new-link-to NEMO]. 5 Other work that influenced the development of this standard are [add-link Community Climate System Model], [add-link Software Developer's Guide], [add-link Report on Column Physics Standards], and [add-link European Standards For Writing and Documenting Exchangeable FORTRAN 90 Code]. 3 6 4 == General == 5 * Only ASCII characters allowed 6 * Line length limit: 80 (soft) | 120 (hard) 7 \\ 8 == (1) General language & form requirements == 9 * FORTRAN-2003 standard (all FORTRAN compilers can handle this, FORTRAN-2008 standard not yet supported by all compilers) 10 * Use English language only 11 * Use ASCII characters only 12 * Use SI units as physical units 13 * Line length limit: 80 characters (soft) | 120 characters (hard) --> Optimize readability (FORTRAN-2003 standard allows '''max. 132''' characters) 7 14 8 == Indenting, spaces & line breaks == 15 || '''AVOID''' || '''USE INSTEAD''' || 16 || COMMON blocks || ... || 17 18 \\ 19 == (2) Indenting, spaces & line breaks == 9 20 '''__General module/subroutine structure''' 10 21 (see Fig. 1) … … 12 23 #!div style="align:'left'; width: 450px; border: 0px solid; float:right" 13 24 [[Image(rules_indent_general.png, 450px, right, margin-right=2, margin-top=0, border=0)]]\\ 14 Fig. 1Indention example with highlighted whitespaces. Click to enlarge.25 '''Fig. 1''' Indention example with highlighted whitespaces. Click to enlarge. 15 26 }}} 16 27 … … 25 36 26 37 * '''1 blank line''' between enclosed blocks of instructions, assignments, clauses, statements, etc. 27 * "&"character for line continuation at position 80 (minimum), max at position 12038 * '''&''' character for line continuation at position 80 (minimum), max at position 120 28 39 29 40 '''__Whitespaces between brackets''' … … 38 49 #!div style="align:'left'; width: 450px; border: 0px solid; float:right" 39 50 [[Image(rules_indent_loops.png, 450px, right, margin-right=2, margin-top=0, border=0)]]\\ 40 Fig. 2Indention & whitespaces in loops. Click to enlarge.51 '''Fig. 2''' Indention & whitespaces in loops. Click to enlarge. 41 52 }}} 42 53 … … 48 59 49 60 50 \\\\\\\\\\ \\\\\\\\\\\\\\\\51 == Alignment ==61 \\\\\\\\\\ 62 == (3) Alignment == 52 63 (see Fig. 3) 53 64 {{{ 54 65 #!div style="align:'left'; width: 450px; border: 0px solid; float:right" 55 66 [[Image(rules_align.png, 450px, right, margin-right=2, margin-top=0, border=0)]]\\ 56 Fig. 2 Indention & whitespaces in loops. Click to enlarge.67 '''Fig. 3''' Alignment example. Click to enlarge. 57 68 }}} 58 69 * Block-wise alignment of continuation line marker '''&''' … … 60 71 * At least block-wise alignment for same type/group of declaration statement 61 72 * Alignment of message_string values 62 * Alignment of inputbetween brackets (e.g. in '''IF ( ) THEN''' or in argument list in subroutine calls)73 * Alignment of expressions between brackets (e.g. in '''IF ( ) THEN''' or in argument list in subroutine calls) 63 74 64 75 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ … … 72 83 == Naming conventions == 73 84 74 == Operators ==75 * e.g. /=, <, <=, ==, >, >=, etc. (not .GE., .LT., etc)76 * .AND., .OR., .NOT.85 == Allowed operators == 86 * Use /=, <, <=, ==, >, >=, etc. as relational operators instead of .GE., .LT., etc. 87 * Use .AND., .OR., .NOT. as logical operators 77 88 78 89 == Preprocessor directives == 90 91 == Declaration statements == 92 * for long lists form groups 79 93 80 94 == File header == … … 83 97 * 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). 84 98 * 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. 99 100 == Check compilation == 101 * no warning/error message should remain