User Tools

Site Tools


dev:codingconventions

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Last revision Both sides next revision
dev:codingconventions [2018/12/19 12:01]
tmueller reformat
dev:codingconventions [2018/12/19 12:19]
tmueller [Use existing infrastructure]
Line 39: Line 39:
  
 ===== Use existing infrastructure ===== ===== Use existing infrastructure =====
 +
 +Always prefer [[https://​gcc.gnu.org/​onlinedocs/​gcc-8.2.0/​gfortran/​Intrinsic-Procedures.html|built-in (intrinsic) functions]] instead of hand-coded routines since they usually include extra numerical checks to avoid intermediate under- or overflow while still performing optimally. Example:
 +
 +  * ''​NORM2''​ instead of ''​%%SQRT(x(1)**2 + x(2)**2 + x(3)**2)%%''​
 +
 +
 +
 For many common operations there exist wrappers in CP2K to prevent usage errors and to allow for central redirections,​ i.e. avoid to use direct calls to external libraries in CP2K For many common operations there exist wrappers in CP2K to prevent usage errors and to allow for central redirections,​ i.e. avoid to use direct calls to external libraries in CP2K
 +
   * Use the routines from ''​cp_files.F''​ instead of calling ''​OPEN''​ and ''​CLOSE''​ directly.   * Use the routines from ''​cp_files.F''​ instead of calling ''​OPEN''​ and ''​CLOSE''​ directly.
   * Use the routines from the full-matrix ''​fm''​-package instead of calling BLAS or Scalapack directly.   * Use the routines from the full-matrix ''​fm''​-package instead of calling BLAS or Scalapack directly.
dev/codingconventions.txt ยท Last modified: 2018/12/21 08:41 by tmueller