Dimensional homogeneity checker for Fortran projects, with LSP support.
Project description
DimFort
Static unit-consistency checker for Fortran. You annotate declarations with the dimension they should carry, and DimFort verifies that assignments, arithmetic, intrinsics, and procedure calls all line up. Annotations are written as a custom Doxygen command, so a single source of truth feeds both the checker and your generated documentation.
real :: velocity !< @unit{m/s}
real :: mass !< @unit{kg}
real :: force !< @unit{kg*m/s^2}
force = mass * velocity ! diagnosed: force unit is kg, expected kg*m/s^2
Status: pre-alpha. End-to-end, these work today: the annotation scanner, attachment pass, the full H-series checker (H001–H004), intrinsics, user-defined function and subroutine calls, derived-type field access, rational
**exponents, multi-file worksets, a workspace-aware LSP server with live-edit diagnostics, hover, inlay hints, go-to-definition, code lens, code actions, completion, and a CLI that accepts files or directories.
Install
git clone https://github.com/ArrialVictor/DimFort.git
cd DimFort
pip install -e ".[dev,lsp]"
Requires Python ≥ 3.11. The Fortran parser
(tree-sitter-fortran)
is installed automatically as a runtime dependency — no external
compiler or subprocess required for parsing. For .F90 files using
CPP #-directives DimFort shells out to the system cpp if
[parser] cpp_defines or [parser] include_paths are set in
.dimfort.toml.
Usage
dimfort check path/to/file.f90 # check a single file
dimfort check path/to/project/ # walk a directory recursively
dimfort check path/... --summary # also print a per-file H/U count table
dimfort lsp # start the language server (stdio)
Exit code is 0 if no errors, 1 if any error-severity diagnostic was
produced, 2 for usage / file / config errors. Warnings alone do not
fail the run.
Diagnostic codes split into two families:
- H-series (
H001–H004) — homogeneity violations: the math doesn't balance dimensionally. Real bugs. - U-series (
U001,U002,U005–U007,U010,U-conflict) — annotation / metadata problems: something's wrong with the annotations themselves, not the math.
Full reference: docs/usage.md.
Doxygen integration
Annotations are read from Doxygen comments (!> / !! preceding a
declaration, or !< trailing it) and apply to every variable in a
declaration list. To make Doxygen render them natively, add one line to
your Doxyfile:
ALIASES += "unit{1}=\par Unit:^^\1"
Module-level constants follow the same notation:
!> @brief Gravitational acceleration.
!> @unit{m/s^2}
real, parameter :: g = 9.81
See docs/annotations.md for the full reference: unit-expression grammar, continuation-line forms, declaration lists, and the diagnostic codes the scanner can emit.
Documentation
Editor integrations
Thin LSP clients that wire dimfort lsp into common editors. Each
lives in its own repository, releases on its own cadence, and shares
the same feature surface (diagnostics, hover, inlay hints,
go-to-definition, code actions, completion).
- DimFort-VSCompanion — VSCode extension.
- DimFort-NvimCompanion — Neovim plugin (Neovim ≥ 0.11).
- DimFort-EmacsCompanion — Emacs package (eglot + lsp-mode).
License
See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dimfort-0.1.0.tar.gz.
File metadata
- Download URL: dimfort-0.1.0.tar.gz
- Upload date:
- Size: 151.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
49bdfa981359b47d3a737fe3390355e83ed4d361c022f8d1c1821dc19ab83aa9
|
|
| MD5 |
40abd424d8a34f6c0b1355e28842c4d0
|
|
| BLAKE2b-256 |
e146ba92ffcc0534f46eb4a9eae82c0e5c7cc867ccf541f6d1339b9f8b7c07af
|
Provenance
The following attestation bundles were made for dimfort-0.1.0.tar.gz:
Publisher:
release.yml on ArrialVictor/DimFort
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dimfort-0.1.0.tar.gz -
Subject digest:
49bdfa981359b47d3a737fe3390355e83ed4d361c022f8d1c1821dc19ab83aa9 - Sigstore transparency entry: 1573476167
- Sigstore integration time:
-
Permalink:
ArrialVictor/DimFort@28f332dfbfc403f3fb77b470889048cadfe006c7 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/ArrialVictor
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@28f332dfbfc403f3fb77b470889048cadfe006c7 -
Trigger Event:
push
-
Statement type:
File details
Details for the file dimfort-0.1.0-py3-none-any.whl.
File metadata
- Download URL: dimfort-0.1.0-py3-none-any.whl
- Upload date:
- Size: 88.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6127cf9f3659f08ea3549ff3308f050cf3b6a6381724a9159c817c22e15b68f
|
|
| MD5 |
7ff5458ccd6c2fbf3a58518b665004d8
|
|
| BLAKE2b-256 |
c22a356b807e2cbcb191692b9362b86cc5be6d224237ec0cd32c7aedca98273a
|
Provenance
The following attestation bundles were made for dimfort-0.1.0-py3-none-any.whl:
Publisher:
release.yml on ArrialVictor/DimFort
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dimfort-0.1.0-py3-none-any.whl -
Subject digest:
c6127cf9f3659f08ea3549ff3308f050cf3b6a6381724a9159c817c22e15b68f - Sigstore transparency entry: 1573476182
- Sigstore integration time:
-
Permalink:
ArrialVictor/DimFort@28f332dfbfc403f3fb77b470889048cadfe006c7 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/ArrialVictor
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@28f332dfbfc403f3fb77b470889048cadfe006c7 -
Trigger Event:
push
-
Statement type: