6. Programming rules#

6.1. Fortran#

The suffix for Fortran files is necessarily .F90. The programming rules require the writing in lower case, an indentation of 4-character blocks (same in Python and C++). implicit none is mandatory.

Other general programming rules:

  • only one routine per file,

  • derived types must be defined in files suffixed with _type.F90 and the modules named x_Module.f90,

  • a routine cannot exceed 500 lines, 20 arguments at most,

  • use names of routines (we are no longer limited to 6 characters) and explicit variables,

  • do not pass bogus arguments, use optional,

  • comment on the role of each argument,

  • comment on the code (in English),

  • use do/enddo (no do/continue, no goto),

  • intelligently store new routines in one of the ``bibfor/ » directories

  • the code is systematically reformatted with*fprettify*.

Some of these rules (and others) are checked at the time of submission by the aslint utility.

6.2. Python#

Most of the programming rules are those in PEP8 (Style Guide for Python Code). The history of the code means that the old functions do not yet respect all the rules. Everyone must contribute in this direction.

The code is always reformatted with*black*.

Some of these rules (and others) are checked at the time of submission by the aslint utility.

6.3. Aslint#

You can check these rules at any time by running aslint on the command line. For aslint to be accessible, add ``source $ HOME /dev/codeaster/devtools/etc/env.sh « , add ``source $ «  » in the file ``$ HOME /.bashrc « or equivalent.

See aslint --help for details.

In particular, check the files monitored by Git that are currently modified (list returned by git status):

aslint --git

To check all files monitored by Git that have been modified from the main branch:

aslint --git origin/main

aslint can correct some shortcomings (absence of the license, update of the copyright) … ):

aslint --fix --git
# or
aslint --fix --git origin/main
# or
aslint --fix Bibfor/OP/OP0190.f90

aslint is started during each commit thanks to hooks (set up by install_env, see Compiling the reference version).

Note

If your branch did not start from origin/main, you must change with the name of the starting development branch or revision identifier (bifurcation point).