= 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 === {{{ #!div style="align:'left'; width: 450px; border: 0px solid; float:right" [[Image(rules_indent_general.png, 450px, right, margin-right=2, margin-top=0, border=0)]]\\ Fig. 1 Indention example with highlighted whitespaces. Click to enlarge. }}} * '''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. [#align Alignment]) * '''2 whitespace''' after ''':''' and '''::'''\\ * '''1 blank line''' between enclosed instructions, assignments, clauses, statements, etc. * "&" minimum at 80, max at 120 === Whitespaces between brackets === * '''0 whitespace''' between string and '''(''' * '''1 whitespace''' after '''(''' and before ''')'''\\(only exception: '''0 whitespace''' in dimensions) === Whitespaces in DO, IF blocks === \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ == 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. == 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.