Changes between Version 9 and Version 10 of doc/tec/developerrules/palmstandard


Ignore:
Timestamp:
Nov 6, 2018 5:54:15 PM (6 years ago)
Author:
kanani
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • doc/tec/developerrules/palmstandard

    v9 v10  
    1313* Use ASCII characters only
    1414* Use SI units as physical units
     15* '''NO''' use of tab characters\\(only exception: Makefile)
    1516
    1617|| '''AVOID''' || '''USE INSTEAD''' ||
     
    2627\\
    2728= (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!
    2837
    2938\\
     
    3140Line length limit: '''80''' characters (soft) | '''120''' characters (hard). The absolute limit for compilers is '''132''' characters!
    3241
    33 == (4.1) Indenting, spaces & line breaks ==
     42== (4.1) Indentation, spaces & line breaks ==
    3443'''__General module/subroutine structure'''
    3544(see Fig. 1)
     
    3746#!div style="align:'left'; width: 450px; border: 0px solid; float:right"
    3847[[Image(rules_indent_general.png, 450px, right, margin-right=2, margin-top=0, border=0)]]\\
    39 '''Fig. 1''' Indention example with highlighted whitespaces. Click to enlarge.
     48'''Fig. 1''' Indentation example with highlighted whitespaces. Click to enlarge.
    4049}}}
    4150* '''0 whitespace''' in front of pre-processor directives
    42 * '''1 whitespace''' before MODULE, CONTAINS, SUBROUTINE (= first indention level)
    43 * '''+3 whitespaces''' for all following indention 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''')\\\\
    4453* '''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))
    4656* '''1 whitespace''' before '''::''' \\(at minimum, see Sect. [#align Alignment])
    4757* '''2 whitespace''' after ''':''' and '''::'''\\\\
    4858* '''1 blank line''' between enclosed/unrelated blocks of instructions, assignments, clauses, statements, etc.
    4959* '''2 blank lines''' in front of each SUBROUTINE within a MODULE
    50 * '''&''' character for line continuation at position 80 (minimum), max at position 120
     60* place '''&''' character for line continuation at position 80 (minimum), max at position 120\\('''Note:''' FORTRAN-2003 defines a limit of 39 continuation lines)
    5161
    5262'''__Whitespaces between brackets'''
    5363(see Fig. 1)
    5464* '''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)
    5666
    5767\\\\\\\\\\\\\\\\\\\\\\\\
    58 '''__Whitespaces in DO, IF blocks'''
     68'''__Whitespaces in DO loops, IF blocks, CASE structures'''
    5969(see Fig. 2)
    6070{{{
    6171#!div style="align:'left'; width: 450px; border: 0px solid; float:right"
    6272[[Image(rules_indent_loops.png, 450px, right, margin-right=2, margin-top=0, border=0)]]\\
    63 '''Fig. 2''' Indention & whitespaces in loops. Click to enlarge.
     73'''Fig. 2''' Indentation & whitespaces in loops. Click to enlarge.
    6474}}}
    65 * In general: '''1 whitespace''' everywhere and '''3 whitespace''' for each indention level
     75* In general: '''1 whitespace''' everywhere and '''3 whitespace''' for each indentation level
    6676* But: '''2 whitespace'''\\
    6777  * between '''DO''' and '''loop index'''
    6878  * after '''IF (  )''' --> see {{{CALL}}}, {{{THEN}}}
    69   * in front of and after logical or 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])
    7080
    7181
     
    7888'''Fig. 3''' Alignment example. Click to enlarge.
    7989}}}
    80 * Block-wise alignment of continuation line marker '''&'''
     90* Block-wise alignment of continuation line mark '''&'''
    8191* Alignment of ONLY lists
    8292* At least block-wise alignment for same type/group of declaration statement
    8393* Alignment of message_string values
    8494* 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)'''
    8696
    8797\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
    8898== (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)
    90103
    91 == Lower/upper case ==
     104
    92105
    93106== Commenting & documentation ==
     
    160173* Files always start with a doxygen-readable comment line including the FORTRAN file name.
    161174* 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]
    163178* 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.
    164179
     
    172187* I/O error conditions via IOSTAT (is this fail-safe for different compilers?)
    173188
     189== Code optimization ==
     190???
    174191
    175192== (X) Final steps ==