Fortran linter
This linter works on a line-by-line basis to enforce some rules regarding the format of Fortran files.
The linter does not ship with any grammar and is solely based on regular expressions. This allows to easily add new rules, but this implies some limitations.
Installation
There are 2 ways of installing the linter. The recommended one is through pip
pip install fortran-linter
The other way is to clone this repository and install it from the local copy:
git clone https://github.com/cphyc/fortran-syntax.git
cd fortran-syntax
pip install .
Please note that depending on your installation, you may have to add sudo to the pip install line. This is due to the fact that the package is shipped with a script fortran-linter. For some installation, the creation of this file may require root access.
Usage
This tool checks for fortran syntax against a few rules. To print a list of all the warnings for a file, run:
fortran-linter myfile.f90 --syntax-only
To autofix (most) warnings in place, do:
fortran-linter myfile.f90 -i
The original file will be backup'ed into myfile.f90.orig. All the safe fixes will be done and stored in the file myfile.f90.
For more help, you can type
fortran-linter -h
Rules
Here is a non-comprehensive set of rules that are enforced:
- Punctuation should be followed by a space, this includes
,,;and). - Binary operators (
==,+, ...) should be surrounded by spaces - The following special characters are surrounded by at least one space:
::,=. - A line should not exceed 120 characters (this is somehow already extreme). The maximum line length can be controlled from the CLI.
- One should use
use mpiinstead ofinclude "mpif.h". Note that this is not fixed by default as it may break codes whereinclude "mpif.h"follows andimplicit nonestatement. - Spaces are preferred over tabs, trailing whitespaces are cleaned.
- Warnings are raised if you use
real(8) :: foo. One should rather useinteger, parameter :: dp = selected_real_kind(15); real(dp) :: foooruse iso_fortran_env; real(real64) :: foo printstatements should look likeprint *, "something"writestatements should look likewrite(*, *) "something"- Lines should be indented consistently (by default, using an indentation of 4 spaces)
- FORD Compatibility:
!!and!>are preserved and treated as comments like!with one space after and at least one space before.
TODO list
- ship on pip
- add more rules (this one will never end)
Metadata
Release files for fortran-linter 1.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| fortran_linter-1.1.3.tar.gz | 3.5 MB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fortran_linter-1.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 3.6 MB
Release files / fortran_linter-1.1.3.tar.gz
| Download URL | fortran_linter-1.1.3.tar.gz |
|---|---|
| Size | 3.5 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a5337e19ec13243011760dda6ed4c3c41eb9b9ad2983cf34179b4829c23ed5f2
|
|
BLAKE2b-256 checksum How to use checksums |
44706377bd3337e2cd9984b648c076772958e59e99be2b0ada10b1953f4cf418
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.3
|
Release files / fortran_linter-1.1.3-py3-none-any.whl
| Download URL | fortran_linter-1.1.3-py3-none-any.whl |
|---|---|
| Size | 15.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d7c0560b84029ad8226e5d67725fcc426dfd99f849d81bf54bcba24c6f143670
|
|
BLAKE2b-256 checksum How to use checksums |
c415355dd25b830d4a2d59c72fc12652aa48a49e90dfb8ab92e681ffe1278ce4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.3
|
Security for fortran-linter 1.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.