Skip to main content

Dimensional homogeneity checker for Fortran projects, with LSP support.

Project description

DimFort

preview

release License: MIT Python: 3.11+

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 (H001H004) — homogeneity violations: the math doesn't balance dimensionally. Real bugs.
  • U-series (U001, U002, U005U007, 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).

License

See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dimfort-0.1.0.tar.gz (151.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dimfort-0.1.0-py3-none-any.whl (88.4 kB view details)

Uploaded Python 3

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

Hashes for dimfort-0.1.0.tar.gz
Algorithm Hash digest
SHA256 49bdfa981359b47d3a737fe3390355e83ed4d361c022f8d1c1821dc19ab83aa9
MD5 40abd424d8a34f6c0b1355e28842c4d0
BLAKE2b-256 e146ba92ffcc0534f46eb4a9eae82c0e5c7cc867ccf541f6d1339b9f8b7c07af

See more details on using hashes here.

Provenance

The following attestation bundles were made for dimfort-0.1.0.tar.gz:

Publisher: release.yml on ArrialVictor/DimFort

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for dimfort-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c6127cf9f3659f08ea3549ff3308f050cf3b6a6381724a9159c817c22e15b68f
MD5 7ff5458ccd6c2fbf3a58518b665004d8
BLAKE2b-256 c22a356b807e2cbcb191692b9362b86cc5be6d224237ec0cd32c7aedca98273a

See more details on using hashes here.

Provenance

The following attestation bundles were made for dimfort-0.1.0-py3-none-any.whl:

Publisher: release.yml on ArrialVictor/DimFort

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page