Coding style
The aim of this style guide is the make the uEMEP code base as easy as possible to read and collaborate on.
Note
The style guide is currently not complete or finalized.
Module structure
Structure code in modules (
module)In most cases, module variables should be
privateby default. Declare public variables and procedures using thepublickeywordUse explicit import when possible (i.e., use module, only: var, func is better than ude module)
Example of module structure:
module module_name
use module, only: imported_variable, imported_procedure
implicit none
private
public :: public_function
real, public :: public_real
real :: private_real
contains
function public_function(par) result(res)
real, intent(in) :: par
real :: res
...
end public_function
subroutine private_subroutine(par, res)
real, intent(in) :: par
real, intent(out) :: res
...
end subroutine private_subroutine
end module module_name
Indentation and white space
Indent using 4 spaces
Lines should be no longer than 132 characters, including indentation
Use vertical white space to structure code into logical units
Use horizontal white space to help reader, e.g.,
a = 2.0is better thana=2.02.0 + 3.0*sqrt(r) - 2.0is better than2.0+3.0*sqrt(r)-2.0if (i == 1 .and. l <= limit) thenis better thanif(i==1.and.l<=limit)then
Variable names
Variables names should be lower case only
Use descriptive variable names, and use underscore to seperate words (e.g., use_meteorology)
Values
Explicitly state preceeding or exceeding zeroes (e.g.,
2.0and0.5is better than2.and.5)