yaeos
Style GuideAdopting a consistent style can improve code legibility through the choice of good naming conventions.
In addition, style checks will be run during CI to flag any severe non-conformance.
This allows code review discussions to focus on semantics and substance rather than pedantry.
Consistent whitespace usage, and not polluting line endings with trailing white space makes git diff
s considerably more legible.
This style guide is a living document and proposed changes may be adopted after discussing them and coming to a consensus.
common
, pause
, entry
, arithmetic if
and computed goto
real*8
or etime()
, use real(pr)
R
gas constant) should be upper casev
and the total volume would be V
.dXdy
for first derivatives and dXdyz
or dXdy2
for second order derivatives. The only exception is with energetic properties, like Ar
, where derivatives are written like ArV
, ArVn
, etc.n, V, T
n, P, T
has_failed
is preferred over hasfailed
linspace
is preferred over lin_space
ArModel
program
, module
, or submodule
.f90
or .F90
if preprocessing is requiredmodule
names should include it’s subdirectory, using yaeos__
for the parent
src
directory. For example the module in src/phase_equilibria/flash.f90
should be named yaeos__phase_equilibria_flash
._implementation
E.g., string_class.f90
and string_class_implementation.f90
test
subdirectory and have the same name as the module they are testing with the test_
prefix
added E.g., string_class.f90
and test/test_string_class.f90
By setting and following a convention for indentation and whitespace, code reviews and git-diffs can focus on the semantics of the proposed changes rather than style and formatting.
We recommend ~~enforce~~ the use of findent
to format your files.
intent
for dummy arguments.dimension
attribute to declare arrays because it is more verbose.
Use this:real, allocatable :: a(:), b(:,:)
real, dimension(:), allocatable :: a
real, dimension(:,:), allocatable :: b
dimension
can be used as an exception if it makes the code less verbose.optional
attribute is used to declare a dummy argument, it should follow the intent
attribute.Fortran allows certain block constructs or scopes to include the name of the program unit in the end statement.
The convention adopted herein is to include procedure names, module
names and program
names in the end
statement,
unless the closing statement can reasonably be expected to be on the same screen or page, within about 25 lines.
Documentation strings should be provided for all public and protected entities and their arguments or parameters. This is currently accomplished using the FORD tool. For help writing FORD style documentation please see the FORD wiki. The following two sections are most relevant for contributing new code:
To write the “spec” (specification) for a new proposal, please place it in the
FORD “pages” directory at
doc/specs/
.
To get help please see the “Writing Pages”
and “Writing Documentation” pages
on the FORD wiki.