Skip to content

Coding style

mrachh edited this page Jul 22, 2021 · 1 revision

Code quality

  1. All code should be sufficiently documented
  2. Max 80 characters per line in all files, .c, .cpp, .h, .py, .f90, .f etc. Anything wider makes remote login work difficult.
  3. Use implicit none or implicit double precision (a-h,o-z)
  4. Use spaces and not tabs in code. Preferably two spaces per level of indent
  5. For fortran codes, all variables in a subroutine should be either intent in, or intent out (no intent inout) and the declaration should be explicit
  6. save or entry statements in fortran should not be used
  7. The dimensions of input/output variables should be explicit and not deferred
  8. 5 lines between subroutines
  9. All fortran code should be subroutines or test programs. No modules and user defined data types
  10. Static variables should be less than 1kb in size
  11. goto statements should point to a later point in the subroutine only

Code preferences

  1. Integer variables to the extent possible should start with the letters (i-n)
  2. Real and complex variables to the extent possible should start with letters (a-h,o-z)
  3. Avoid using vector notation to the extent possible. The code runs at O(1k pts/per sec/core), there are a lot of operations that can be afforded for smaller tasks. Use Blas or simplified blas routines in lapack_wrap.f90 in case speed is critical
Clone this wiki locally