User Tools

Site Tools


dev:formattingconventions

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
dev:formattingconventions [2016/03/16 13:34] – Changed title pseewalddev:formattingconventions [2018/03/20 12:38] – [Editor integration] 130.60.136.206
Line 1: Line 1:
 ====== Code Formatting Conventions and Prettify Tool ====== ====== Code Formatting Conventions and Prettify Tool ======
-Uniform formatting of CP2K source code will be enabled in the near future by a prettify script that is an almost complete auto-formatter for Fortran 90 source code. As a rule of thumb, developers should not worry about the format of their code and just let prettify do its magic by running ''make -j pretty''. The chosen formatting conventions for CP2K are as follows:+Uniform formatting of CP2K source code is enabled by a prettify script that is an almost complete auto-formatter for Fortran 90 source code. As a rule of thumb, developers should not worry about the format of their code and just let prettify do its magic by running ''make -j pretty''. 
 +===== Formatting conventions ===== 
 +The following formatting conventions are automatically enforced by the ''make -j pretty'' command:
   * Sorting and alignment of variable declarations and ''USE'' statements, removal of unused list entries.   * Sorting and alignment of variable declarations and ''USE'' statements, removal of unused list entries.
   * Indentation with a relative width of 3 characters.   * Indentation with a relative width of 3 characters.
Line 7: Line 9:
   * Removal of extraneous whitespace and consecutive blank lines.   * Removal of extraneous whitespace and consecutive blank lines.
   * Uppercase notation for all Fortran and OpenMP keywords.   * Uppercase notation for all Fortran and OpenMP keywords.
 +
 +===== Manual formatting =====
 The following formatting decisions are still manual and are never changed by prettify: The following formatting decisions are still manual and are never changed by prettify:
   * Positions of line breaks (except for variable declarations and ''USE'' statements).   * Positions of line breaks (except for variable declarations and ''USE'' statements).
   * No indentation of subsequent ''DO'' / ''IF'' statements that are aligned with each other.   * No indentation of subsequent ''DO'' / ''IF'' statements that are aligned with each other.
-There may be cases where manual alignment is preferred over the rules stated above. The following options for manual formatting are provided:+There may be cases where manual alignment is preferred over the automatic formatting conventions. The following options for manual formatting are provided:
   * No automatic realignment of line continuations that are prefixed with an ''&''.   * No automatic realignment of line continuations that are prefixed with an ''&''.
   * No auto-formatting of lines to which a comment starting with ''!&'' is attached.   * No auto-formatting of lines to which a comment starting with ''!&'' is attached.
   * No auto-formatting of code blocks enclosed between two comment lines starting with ''!&<'' and ''!&>''.   * No auto-formatting of code blocks enclosed between two comment lines starting with ''!&<'' and ''!&>''.
 +===== Examples =====
 A few examples to illustrate how to deal with cases where auto-formatting produces unsatisfying results: A few examples to illustrate how to deal with cases where auto-formatting produces unsatisfying results:
  
dev/formattingconventions.txt · Last modified: 2020/08/21 10:15 by 127.0.0.1