Version 3 (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 (no: °, 2, µ, etc.)
  • Line length limit: 80 (soft) | 120 (hard)

*

Indenting & spaces

General module structure


Indention example with highlighted whitespaces. Click to enlarge.

  • 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
  • 1 whitespace after ,
  • 1 whitespace before ::
  • 2 whitespace after :

Whitespaces between brackets

  • 0 whitespace between string and (
  • 1 whitespace after ( and before )




































Alphabetical sorting

except for CALLs to modules/subroutines

Lower/upper case

Commenting

Naming conventions

New modules

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.
    !> @file new_module_mod.f90
    !-----------------------------------------------------------------------------!
    ! This file is part of the PALM model system.
    !
    ! PALM is free software: you can redistribute it and/or modify it under the
    ! terms of the GNU General Public License as published by the Free Software
    ! Foundation, either version 3 of the License, or (at your option) any later
    ! version.
    !
    ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
    ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
    ! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
    !
    ! You should have received a copy of the GNU General Public License along with
    ! PALM. If not, see <http://www.gnu.org/licenses/>.
    !
    ! Copyright 2018-2018 Leibniz Universitaet Hannover, <your institution>
    !-----------------------------------------------------------------------------!
    !
    ! Current revisions:
    ! -----------------
    ! Initial revision
    ! 
    ! Former revisions:
    ! -----------------
    ! $Id$
    !
    ! Authors:
    ! --------
    !> @author <Author 1> (<Affiliation>)
    !> @author <Author 2> (<Affiliation>)
    !
    !
    ! Description:
    ! ------------
    !> <Description of the new module>
    !>
    !>
    !> @todo <Enter things that remain to be done>
    !> @note <Enter notes on the module>
    !> @bug  <Enter known bugs here>
    !------------------------------------------------------------------------------!
    

Attachments (5)

Download all attachments as: .zip