The following guidelines describe some coding recommendations to write Fortran source files.
Notus developers strive to keep an homogeneous and coherent source code. The Fortran 90 free form is used as a baseline. Please consider the additional rules that follows when coding.
Use lowercase characters.
Lowercase character are more readable than uppercase.
Avoid long lines.
Fortran 90's free form does not accept lines longer than 132 characters. Splitting long lines often increases readability.
Comment your code.
Code comments are good practice, but its better to avoid the need for comments!
Think twice before comment: do not paraphrase yourself, reduce or delete the need for comment by using self-explanatory names.
Use doxygen.
Write one routine per file as much as possible.
Its easier to find routines this way.
Use Emacs indentation.
The shell script formatCode.sh automatically indents the code.
Use alphabetical order by default.
It's easier to find in such lists.
Use self explanatory variable names.
Thus every one knows what is your variable every time he sees it in the source code.
Use as little as possible abbreviations.
An abbreviation may not be clear for every one, so try not to use them. Although, very long variable names is sometimes not quite readable either, then abbreviations becomes a better alternative.
For this situation, a list of common abbreviations has been written below; have a look before creating your own. If you really need new ones, try to reduce their number to a minimum.
coef
for coefficient.dir
for direction.ib
for immersed boundary.ibc
for immersed boundary condition.isd
for immersed subdomain._u
, _v
, _w
suffixes for fields discretized at the \(x\)-, \(y\)-, \(z\)-faces, respectively.is_
prefix for variables of type logical._n
suffix for variables at the current time step \(t_n.\)_mn1
suffix for variables at the last time step \(t_{n-1}.\)variable_
.field_
.Module prefixes:
variables_
for modules defining global variables.mod_
.type_
for modules defining new derived types.mod_
for modules defining subroutines.Write one routine per file.
Its easier to find routines this way.