Version 2 (modified by kanani, 6 years ago) (diff)

--

PALM coding rules

This is.....

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.

Indenting

General module structure

  • 1 blank before MODULE, CONTAINS, SUBROUTINE (= first indention level)
  • +3 blanks for all following indention levels
    (only exception: ONLY list in USE statements +4 blanks)
  • 1 blank between individual strings
  • 1 blank after ","
  • 1 blank before "::"
  • 2 blanks after ":"
     MODULE new_module_mod
    
        USE arrays_3d,                                                        &
            ONLY:  tend, u, v, w, zu, zw
    
        IMPLICIT NONE
    
        CHARACTER ::  global_string_a
    
        SAVE
    
        PRIVATE
    
        PUBLIC global_string_a
    
        INTERFACE newmod_3d_data_averaging
           MODULE PROCEDURE newmod_3d_data_averaging
        END INTERFACE newmod_3d_data_averaging
    
     CONTAINS
    
     SUBROUTINE newmod_3d_data_averaging( mode, variable )
    
        USE control_parameters
    
     END SUBROUTINE newmod_3d_data_averaging
    
     END MODULE new_module_mod
    

Sorting

except for CALLs to modules/subroutines

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>
    !------------------------------------------------------------------------------!