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
DimFort is published on PyPI as dimfort. It's a CLI tool with an
entry point — install it isolated with pipx:
pipx install 'dimfort[lsp]' # includes the LSP server extra
dimfort --version
The [lsp] extra pulls in pygls; omit it if you only want the
CLI and never the language server.
On macOS with Homebrew Python: PEP 668 makes plain
pip installrefuse to touch Homebrew's site-packages. Usepipxas shown above, or install into a virtual environment. Ifpipx installsays "command not found", runbrew install pipx && pipx ensurepathfirst.
From source (contributors)
git clone https://github.com/ArrialVictor/DimFort.git
cd DimFort
python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev,lsp]"
Requirements
Python ≥ 3.11. The Fortran parser
(tree-sitter-fortran)
is a runtime dependency installed automatically — no external
compiler or subprocess needed 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.1.tar.gz.
File metadata
- Download URL: dimfort-0.1.1.tar.gz
- Upload date:
- Size: 152.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a7619815dac3eecd3d3203220afae6a6379314dd728a9b57c49e40d2ce13bde
|
|
| MD5 |
ba7dcc273f790a8d3f01f1f4fdc61ce9
|
|
| BLAKE2b-256 |
573c02c507a2c3edc2055388e7156f0ea49063d2e4d1fb11b3b7372f1120b499
|
Provenance
The following attestation bundles were made for dimfort-0.1.1.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.1.tar.gz -
Subject digest:
8a7619815dac3eecd3d3203220afae6a6379314dd728a9b57c49e40d2ce13bde - Sigstore transparency entry: 1573572130
- Sigstore integration time:
-
Permalink:
ArrialVictor/DimFort@98f564c2e049bbc7f33c54538a17dd58abd28ae3 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/ArrialVictor
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@98f564c2e049bbc7f33c54538a17dd58abd28ae3 -
Trigger Event:
push
-
Statement type:
File details
Details for the file dimfort-0.1.1-py3-none-any.whl.
File metadata
- Download URL: dimfort-0.1.1-py3-none-any.whl
- Upload date:
- Size: 89.1 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 |
4888224c5783299ba29c062f4e9ab921e7408c8a2f97b79d6f54d26acca9180b
|
|
| MD5 |
739fd3d99fad3d62e8fca56cb1961a17
|
|
| BLAKE2b-256 |
973c305b875c1469463fbd6e223714b90b035d2b76c09fedd887d9c05c7da7e2
|
Provenance
The following attestation bundles were made for dimfort-0.1.1-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.1-py3-none-any.whl -
Subject digest:
4888224c5783299ba29c062f4e9ab921e7408c8a2f97b79d6f54d26acca9180b - Sigstore transparency entry: 1573572156
- Sigstore integration time:
-
Permalink:
ArrialVictor/DimFort@98f564c2e049bbc7f33c54538a17dd58abd28ae3 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/ArrialVictor
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@98f564c2e049bbc7f33c54538a17dd58abd28ae3 -
Trigger Event:
push
-
Statement type: