fortranspire¶
An LLM + MCP pipeline that ports legacy Fortran HPC kernels to GPU (OpenACC) and differentiable JAX.
fortranspire automates the four transformations a senior HPC engineer
would perform by hand when porting a Fortran 90 kernel to GPU and Python:
Parse the source with Loki (ECMWF) — deterministic AST analysis of
INTENT,SAVE,COMMON,POINTER, and inline loops.Extract the kernels into a
MODULEwith explicitINTENT(INOUT)arguments — one LLM call against any OpenAI-compatible endpoint.Annotate purity (
PURE/ELEMENTAL) and insert OpenACC pragmas (!$acc parallel loop collapse(...),!$acc data copyin/copy).Wrap in Cython (NumPy typed memoryviews,
iso_c_bindingheader) and validate withgfortranandnvfortran -acc.
The pipeline is exposed as a CLI and as a Model Context Protocol (MCP) server, so it is callable from any MCP-aware client (Claude Desktop, Cursor, VS Code, Mistral Le Chat connectors) or any CI runner.
Getting started
Concepts
- Architecture
- Fortran patterns & transformation rules
- Summary table
- 1.
INTENT— the key to everything else - 2.
COMMONblocks — the global state to eliminate - 3.
SAVE— hidden state between calls - 4.
POINTER— dangerous aliasing for GPU - 5. Array of Structures → Structure of Arrays (AoS → SoA +
collapse) - 6. Nested dependencies — non-parallelisable loops
- 7.
ELEMENTAL+ OpenACC — the right pattern - 8. Explicit types — no compiler-inferred mixed precision
- 9. Logical flags
USE_xx→ compile-time directives - 10. MPI halo exchange → GHEX (GPU-to-GPU)
- 11. Fortran I/O → xarray / zarr + DLPack
- See also
- LLM endpoints
- Mistral integration
- Le Chat connector (preparation kit)
- Documenting a legacy Fortran codebase
- 4. PyTree State Injection
- 5. XLA Optimizations and
@jax.jit - 6. Performance Verdict
Integrations
Reference