You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
Disclaimer: This is an experimental work-in-progress programme that is only partially implemented and where interfaces at all levels could undergo substantial changes.
lazy fortran solves the two-language problem in Fortran by providing the experience and tooling of modern languages while maintaining, performance and long-term stability of Fortran. It is inspired by the best features of Python, Rust, Julia and Go, builds on thefpm ecosystem, and integrates with standard Fortran compilers and tools.
Toolchain Overview
Thelazy fortran toolchain splits work across several packages: fortfront, fluff, ffc, fad, fortrun, and fnb — each focused on a clear purpose. This keeps code organized, dependencies minimal, and interfaces straightforward.
fortrun
Purpose: Code runner and package manager.
Features:
Executeslazy fortran or Standard Fortran applications
Global source and object cache for rapid incremental builds and runs
Manages dependencies, project layout, and environments (inspired by Go, Rust, Julia, Python)
Provides caching API for other packages
Interfaces: Provides high-level run and build commands for development workflows, plus API for cache management.
Inspired by: go, julia, lfortran
Dependencies:
fortfront for parsing and analysis
FPM for package resolution and build metadata
Any supported Fortran compiler
fluff
Purpose: Source-to-source transformations and static checks.
Features:
Source code formatter forlazy fortran and Standard Fortran
Advanced linting with diagnostics (inspired by Rust analyzer)
Static analysis checks and code quality enforcement
Code transformations and refactoring suggestions
Interfaces: Provides CLI subcommands for formatting, linting, and static analysis.
Inspired by: ruff (code formatting and static analysis)
Dependencies:
fortfront only
fortnb
Purpose: Notebook interface for Standard Fortran andlazy fortran.
Features:
Implements .f and .md files as notebooks similar to jupytext
Supports both Standard Fortran andlazy fortran syntax
Provides export to Markdown and PDF
Interfaces: Offers API and CLI to convert notebooks to Markdown or PDF
fortrun for running notebook cells and managing cache
fluff CLI for formatting and standardization (optional)
Thelazy fortran toolchain splits work across several packages: fortfront, fluff, ffc, fad, fortrun, and fnb — each focused on a clear purpose. This keeps code organized, dependencies minimal, and interfaces straightforward.
fortfc
Purpose: Full compilation backend.
Features:
Lower typed AST to HLFIR (an MLIR dialect)
Continue lowering to LLVM IR and produce object code
Includes the MLIR backend implementation
Interfaces: Offers a compiler CLI to produce object code.
Inspired by: flang (HLFIR -> FIR -> LLVM IR or SPIR-V for GPU -> OMP target), lfortran (typed AST -> LLVM IR)
Dependencies:
fortfront for typed AST
LLVM/MLIR libraries
fortad
Purpose: Automatic differentiation.
Features:
Supports!$ad annotations to mark functions/subroutines for differentiation
Integrates with Enzyme at the IR level during compilation
Works with any Enzyme-enabled compiler (ffc, Flang, etc.)
Details of IR integration to be defined
Interfaces: Exposes compiler flags or annotations to enable AD on marked routines.
Inspired by: tapenade (decorators, e.g. !$ad mode=reverse)
Dependencies:
fortfront for AST and semantic info
Any Enzyme-enabled Fortran compiler (ffc, Flang, LFortran, etc.)
fortfront
Purpose: Core analysis.
Includes:
AST types for untyped and typed trees
Lexer and parser to build the untyped AST
Semantic analyzer to resolve names, infer and check types, and produce a typed AST
Outputs:
Untyped AST
Typed AST
Standard Fortran (F90) code emission
JSON export of tokens, ASTs
API & CLI:
Programmatic API for lexing, parsing, and semantic analysis
API and minimal CLI (fortfront) with subcommands to dump tokens, AST, typed AST in JSON, or emit Standard Fortran
Inspired by: go, julia, rust, python, lfortran
Dependencies: None
Packages for Scientific Computing
fortarray
Purpose: Multi-dimensional array operations and data analysis.
Features:
xarray/ndarray-inspired interface: load, aggregate, plot data with ds%plot(), ds%var%mean()
Labeled arrays with coordinate indexing and alignment
Broadcasting, reduction, and transformation operations
Integration with fortio for data loading
Interfaces: Exposes array API with method chaining for data manipulation and analysis.
Inspired by: xarray/ndarray (load, aggregate, plot data with ds%plot(), ds%var%mean())
Dependencies:
fortio for data I/O
fortframe
Purpose: Table-oriented data manipulation and analysis.
Features:
pandas/excel-inspired interface using fortarray as backend
SQL integration through fortsql for database operations
Table joins, grouping, and aggregation operations
Import/export from various tabular formats
Interfaces: Provides DataFrame-like API with SQL query capabilities and statistical methods.
Inspired by: pandas (as fortarray backend but with SQL and table oriented)
Dependencies:
fortarray for underlying array operations
fortsql for database connectivity
fortfem
Purpose: Finite element method computations.
Features:
FreeFEM-inspired finite element framework
Mesh generation and adaptive refinement
Variational formulation and solver integration
Post-processing and visualization of FEM results
Interfaces: Offers high-level FEM API with mesh management and solver integration.