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.