AI Agents

What a 40k-Line Fortran Migration Teaches About Agent Workflows

Mistral's Fortran-to-C++ migration shows parity harnesses and human-gated agent workflows beat full autonomy for legacy code.

What a 40k-Line Fortran Migration Teaches About Agent Workflows — article cover

Migrating legacy code with AI agents isn’t just about translating syntax. Mistral’s Applied AI team helped a European energy operator move 40,000 lines of Fortran 77 to C++ for a physics-intensive reservoir simulator. The real challenge was architectural: Fortran 77 has no modules, no namespaces, and state lives in global COMMON blocks. Variables are implicitly typed by first letter, so a misspelled name silently creates a new variable.

Why a parity harness comes first

Before letting agents loose, the team built a way to prove the two codebases agreed numerically. They added subroutines to export Fortran state snapshots, a C++ test framework to load those checkpoints, and Skill.md files to steer agents. Agents then instrumented the Fortran code to dump state and verified migrated C++ modules against those values.

This harness was a net-positive investment. It made long agent runs safer and gave an easy-to-verify proof of correctness. As the Mistral team puts it, numerical parity is the cheapest, most convincing argument that a module is done.

Documenting before migrating

Documentation was scattered across old PDFs and buried comments. The team parsed the Fortran codebase into a caller-callee tree, then used Vibe CLI to spawn over a hundred agents to document it. Each agent pulled relevant PDFs via document libraries and Mistral OCR, working from the leaves upward. A reviewer agent on a cron schedule checked newly opened PRs and scheduled fixes.

This step mattered because you can’t migrate code nobody can read. Getting documentation in order before leaning on agents was one of the project’s key lessons.

The autonomy sweet spot

The first attempt gave agents full autonomy: one agent per Fortran subroutine, translating independently for a week. The result was functional but not modernized—COMMON blocks became global structs one-to-one, and GOTO-driven control flow stayed intact. It looked like Fortran retyped in C++.

The second attempt added structure: a planner, coder, tester, and code quality reviewer per module. Quality improved, but agents would hit a bug, attempt a few fixes, and stall with no one to intervene.

The team landed on a middle ground: a human operating a workflow of coder, tester, and reviewer agents, migrating module by module. This preserved code quality while adding a human checkpoint to unblock stuck agents.

What this means for your migration

For builders facing legacy modernization, the Mistral project offers three principles. Build the parity harness before writing migration code. Get documentation in order before leaning on agents. And at scale, structured workflows with human review gates beat both full autonomy and hand-driven manual sessions.

The first sprint covered 40,000 of 300,000 lines. The Fortran codebase was self-contained and runnable—a favorable starting condition. Migrations that depend on external systems, lack a runnable baseline, or encode physics documented nowhere would bring additional challenges.

This aligns with a broader pattern in agentic software development: the goal isn’t to replace human judgment but to build workflows where agents do the heavy lifting and humans make the calls that matter.

Sources

AI-assisted summary compiled from the sources above, reviewed by a human before publishing.

FOUND_THIS_USEFUL?

Support more practical AI articles, tutorials, and build notes.

BUY_ME_A_COFFEE
SHAREXEMAIL