stdlib

Fortran stdlib Style Guide

Adopting 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 diffs considerably more legible. This style guide is a living document and proposed changes may be adopted after discussing them and coming to a consensus.

Use (modern) standard Fortran

File naming conventions

Indentation & whitespace

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.

Variable and procedure naming

Attributes

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.

Document public API code for Sphinx

Documentation strings should be provided for all public and protected entities and their arguments or parameters. The documentation preview is now built with Sphinx using MyST Markdown for the hand-written pages and sphinx-fortran-domain for incremental API auto-documentation from source comments. The current convention is:

To write the “spec” (specification) for a new proposal, please place it in the doc/specs/.