Changes between Version 9 and Version 10 of doc/tec/developerrules/palmstandard
- Timestamp:
- Nov 6, 2018 5:54:15 PM (6 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
doc/tec/developerrules/palmstandard
v9 v10 13 13 * Use ASCII characters only 14 14 * Use SI units as physical units 15 * '''NO''' use of tab characters\\(only exception: Makefile) 15 16 16 17 || '''AVOID''' || '''USE INSTEAD''' || … … 26 27 \\ 27 28 = (3) Naming conventions = 29 == (3.1) Use of lower & upper case letters == 30 * '''Upper case:''' FORTRAN keywords and intrinsic functions or routines, e.g. 31 * SUBROUTINE, MODULE, etc. 32 * INTEGER, REAL, PARAMETER, etc. 33 * DO, ENDDO, IF, ELSE, etc. 34 * READ, WRITE, CALL, etc. 35 * MPI_ALLTOALL (MPI functions), NF90_CREATE (NetCDF functions), etc.\\ 36 * '''Lower case:''' Everything else! 28 37 29 38 \\ … … 31 40 Line length limit: '''80''' characters (soft) | '''120''' characters (hard). The absolute limit for compilers is '''132''' characters! 32 41 33 == (4.1) Indent ing, spaces & line breaks ==42 == (4.1) Indentation, spaces & line breaks == 34 43 '''__General module/subroutine structure''' 35 44 (see Fig. 1) … … 37 46 #!div style="align:'left'; width: 450px; border: 0px solid; float:right" 38 47 [[Image(rules_indent_general.png, 450px, right, margin-right=2, margin-top=0, border=0)]]\\ 39 '''Fig. 1''' Indent ion example with highlighted whitespaces. Click to enlarge.48 '''Fig. 1''' Indentation example with highlighted whitespaces. Click to enlarge. 40 49 }}} 41 50 * '''0 whitespace''' in front of pre-processor directives 42 * '''1 whitespace''' before MODULE, CONTAINS, SUBROUTINE (= first indent ion level)43 * '''+3 whitespaces''' for all following indent ion levels \\(only exception: ONLY list in USE statements '''+4 whitespaces''')\\\\51 * '''1 whitespace''' before MODULE, CONTAINS, SUBROUTINE (= first indentation level) 52 * '''+3 whitespaces''' for all following indentation levels \\(only exception: ONLY list in USE statements '''+4 whitespaces''')\\\\ 44 53 * '''1 whitespace''' between individual strings, and between strings and symbols/numbers 45 * '''1 whitespace''' after ''','''\\(only exception: '''0 whitespace''' between array dimensions) 54 * '''1 whitespace''' before and after all operators (+, -, *, =, /)\\(exception: '''0 whitespace''' for ** (exponent operator, e.g. u**2) and operators within expressions for array indices, e.g. u(i+1)) 55 * '''1 whitespace''' after ''','''\\(only exception: '''0 whitespace''' between array dimensions, e.g. (i,j,k)) 46 56 * '''1 whitespace''' before '''::''' \\(at minimum, see Sect. [#align Alignment]) 47 57 * '''2 whitespace''' after ''':''' and '''::'''\\\\ 48 58 * '''1 blank line''' between enclosed/unrelated blocks of instructions, assignments, clauses, statements, etc. 49 59 * '''2 blank lines''' in front of each SUBROUTINE within a MODULE 50 * '''&''' character for line continuation at position 80 (minimum), max at position 12060 * place '''&''' character for line continuation at position 80 (minimum), max at position 120\\('''Note:''' FORTRAN-2003 defines a limit of 39 continuation lines) 51 61 52 62 '''__Whitespaces between brackets''' 53 63 (see Fig. 1) 54 64 * '''0 whitespace''' between string and '''(''' 55 * '''1 whitespace''' after '''(''' and before ''')'''\\(only exception: '''0 whitespace''' in dimensions)65 * '''1 whitespace''' after '''(''' and before ''')'''\\(only exception: '''0 whitespace''' for brackets containing array indices) 56 66 57 67 \\\\\\\\\\\\\\\\\\\\\\\\ 58 '''__Whitespaces in DO , IF blocks'''68 '''__Whitespaces in DO loops, IF blocks, CASE structures''' 59 69 (see Fig. 2) 60 70 {{{ 61 71 #!div style="align:'left'; width: 450px; border: 0px solid; float:right" 62 72 [[Image(rules_indent_loops.png, 450px, right, margin-right=2, margin-top=0, border=0)]]\\ 63 '''Fig. 2''' Indent ion & whitespaces in loops. Click to enlarge.73 '''Fig. 2''' Indentation & whitespaces in loops. Click to enlarge. 64 74 }}} 65 * In general: '''1 whitespace''' everywhere and '''3 whitespace''' for each indent ion level75 * In general: '''1 whitespace''' everywhere and '''3 whitespace''' for each indentation level 66 76 * But: '''2 whitespace'''\\ 67 77 * between '''DO''' and '''loop index''' 68 78 * after '''IF ( )''' --> see {{{CALL}}}, {{{THEN}}} 69 * in front of and after logical o r relational operators (e.g. '''.OR.''', see [#operators list of allowed operators])79 * in front of and after logical operators (e.g. '''.OR.''', see [#operators list of allowed operators]) 70 80 71 81 … … 78 88 '''Fig. 3''' Alignment example. Click to enlarge. 79 89 }}} 80 * Block-wise alignment of continuation line mark er'''&'''90 * Block-wise alignment of continuation line mark '''&''' 81 91 * Alignment of ONLY lists 82 92 * At least block-wise alignment for same type/group of declaration statement 83 93 * Alignment of message_string values 84 94 * Alignment of expressions between brackets (e.g. in '''IF ( ) THEN''' or in argument list of subroutine calls) 85 * Alignment of same level of mathematical expressions or array indices '''(missing in png)'''95 * Alignment of related code, e.g. in complex equations or setting of initial values for variables '''(missing in png)''' 86 96 87 97 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 88 98 == (4.3) Alphabetical sorting == 89 except for CALLs to modules/subroutines 99 * Members in ONLY lists of USE statements (see e.g. Fig. 3) 100 * Parameters in NAMELISTS (see e.g. initialization_parameters NAMELIST in parin.f90) 101 * Declaration types (first CHARACTERs, then INTEGERs, etc., see Fig. 3) 102 * Variables in declaration statements (see Fig. 3) 90 103 91 == Lower/upper case == 104 92 105 93 106 == Commenting & documentation == … … 160 173 * Files always start with a doxygen-readable comment line including the FORTRAN file name. 161 174 * 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. 162 * 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). 175 * 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 automatically generate the respective time stamp for a revision (see existing SOURCE files).\\ 176 --> [link-to How to initialize Id keyword in svn] 177 * mention revision history and link to [How to commit] 163 178 * 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. 164 179 … … 172 187 * I/O error conditions via IOSTAT (is this fail-safe for different compilers?) 173 188 189 == Code optimization == 190 ??? 174 191 175 192 == (X) Final steps ==