Neko
0.9.99
A portable framework for high-order spectral element flow simulations
|
Fortran code should conform to the Fortran 2008 standard and should use an indentation level of 2, except for the extra indentation within do
if
, select
or where
statements and for each level inside a structure e.g. type
, interface
, where the indentation level is 3, continuation statements, which should be indented by 5 and a 0 indentation is used for module
or contains
(except for contains
inside a derived type, where a single indentation level is used).
These are the default rules in Emacs' Fortran mode, an example is given below, additional information on the Emacs' Fortran mode can be found at https://emacsdocs.org.
For portability reasons, it is essential to only use data type kinds defined in num_types.f90 and avoid legacy constructs like real*8
or integer(kind=8)
Floating-point numbers should be declared using real
with the kind rp
, which is the configured working precision for Neko (defaults to double). If single, double or quad precision is explicitly needed, use the kinds sp
, dp
or qp
, respectively. For 16, 32, or 64-bit integers, Neko has defined the kinds i2
, i4
or i8
, respectively; however, for standard integers, it is perfectly fine to use a plain integer
.
Submitting a pull request to Neko requires that the code passes the linting rules. The linting rules are enforced by the flint tool. The rules are defined in the flinter_rc.yml
file in the root of the repository.
Please note, newer versions of flint fails to execute for some of our large files (htable.f90 and stack.f90).
One way to install flint is thorugh pip:
To test your code against the linting rules, you can run the following command:
The whole src directory can be checked with:
The rules are as follows:
do i = 1, 10
.a .eq. b
.::
must have a spaces around it.foo(b, c)
.if (a .eq. b)
.!$
.type(kind)
instead of type*8
.!
must have a space before and after them ! This is a comment
.end if
.end if
.a = b
.sp
, dp
or qp
.use mpi_f08
instead (or use mpi
if not available).exit
statement is not allowed.goto
statement is not allowed.pause
statement is not allowed.include
statement is not allowed.However, there are some exceptions to these rules:
::
may not have spaces around it in the case of a type declaration.foo(a,b)
and foo(a,10)
are allowed, but foo(a,bb)
and foo(a,100)
are not.=
operator is not required in type declarations.In order to simplify compliance to the indentation rules the findent tool can be used to enforce these rules by assigning the following options. The documentation of findent
provide details for emacs, vim and gedit. For VSCode, the Modern Fortran extension provide an integration.