Quickstart¶
This page walks you through porting a small Fortran 90 kernel to GPU and calling it from Python in about five minutes.
1. Configure the LLM endpoint¶
Edit .env to point at your endpoint:
MISTRAL_ENDPOINT="https://api.mistral.ai/v1"
MISTRAL_API_KEY="<your-key>"
MISTRAL_MODEL="mistral-large-latest"
See LLM endpoints for self-hosted alternatives.
2. Run Phase 1 — Fortran → GPU + Cython¶
Pick a Fortran source — for example a 2-D finite-difference stencil:
fortranspire gpu path/to/kernel.f90
The pipeline writes its results under output/:
output/
├── fortran_gpu/
│ ├── kernel_pure.f90 # PURE/ELEMENTAL annotated
│ └── kernel_gpu.f90 # OpenACC pragmas
└── cython/
├── kernel_wrapper.pyx # NumPy-typed wrapper
├── kernel_c.h # iso_c_binding header
└── setup.py # scikit-build entry point
A typical run consumes four LLM calls and about two minutes of wall-clock.
3. Run Phase 2 — Fortran → JAX (optional)¶
fortranspire translate path/to/kernel.f90 --to jax
This produces a JAX translation under output/jax/ that is JIT-compilable
and differentiable through jax.grad / jax.vjp.
4. Analyze-only mode (no LLM, CI hook)¶
If you just want to know whether a Fortran file is GPU-ready — without
spending tokens or rewriting anything — use fortranspire analyze:
fortranspire analyze src/kernel.f90
fortranspire analyze --format sarif --output report.sarif src/
fortranspire analyze --fail-on warning src/ # CI-friendly exit code
The analyzer runs only the deterministic Loki parser stage, detects nine recurring patterns (COMMON, SAVE, I/O in kernels, missing IMPLICIT NONE, POINTER, derived types, suspected loop-carried deps, missing KIND, parse errors), and emits human-readable text, JSON, or SARIF 2.1.0 that GitHub Code Scanning consumes for inline PR annotations.
A ready-to-use workflow lives at
.github/workflows/analyze.yml;
a lightweight HPC container (no CUDA, no NVIDIA HPC SDK) lives at
Apptainer.analyze.
5. Use the MCP server from an IDE¶
fortranspire mcp
The server listens on http://localhost:8000/sse and exposes the
translate_kernel_gpu, translate_kernel, profile_kernels, and
ask_agent tools. Connect any MCP-aware client (Claude Desktop, Cursor,
VS Code agent, Mistral Le Chat) to drive the pipeline from your editor.
Set API_KEY in your environment to require a bearer token on every
request.
Next steps¶
Read the Architecture page to understand the six pipeline stages and where the LLM is — and is not — involved.
Skim the Fortran patterns page to see the nine recurring patterns the pipeline handles automatically.
Browse the API reference for the Python entry points.