40,000 lines of Fortran, migrated to C++ by AI agents
Mistral moved 40,000 of 300,000 lines of Fortran 77 to C++ for a European energy operator. What made it work was a parity harness, not autonomy.
Symbolic image: compute nodes blink through a running job while two people study abstract branching diagrams on large monitors in a simulation room.
Mistral migrated 40,000 of a roughly 300,000-line Fortran 77 reservoir simulator to C++ not by turning agents loose on it, but by building a numerical parity harness first and keeping engineers in the approval loop.
At a glance
- First sprint: 40,000 of 300,000 lines of Fortran 77 moved to C++, starting with core functionality.
- Fortran 77 was standardized in 1977 and caps variable names at six characters.
- More than 100 agents documented the codebase, drawing on existing PDFs through Mistral OCR.
- A reviewer agent ran on a cron schedule, checking new pull requests and queueing fix tasks.
- Mistral treats self-contained subtrees under about 10,000 lines of Fortran as a workable migration unit.
Mistral has published an account of moving 40,000 of roughly 300,000 lines of Fortran 77 to C++ at a European energy operator. The line count is the headline; the ordering is the actual argument. Prove numerical equivalence first, document the code second, migrate third – and the three lessons at the end of the post say exactly that.
What makes this codebase hard
The program is a physics-heavy reservoir simulator. Fortran 77 dates to a 1977 standard, allows variable names of at most six characters, and passes state around through COMMON blocks. The original authors were gone, there was no test suite, and there was no central documentation to work from.
One condition worked in the team's favor: the program was self-contained and it ran. Mistral flags that same condition as a limit at the end – without a runnable baseline, the method gets considerably harder.
The parity harness comes before the agents
Extra subroutines dump the state of the Fortran program, and a test framework loads those checkpoints into the C++ side. Agreement here means numerical equality of outputs, both final results and the intermediate points reservoir engineers had marked as critical. Skill.md files were written to steer the agents into using that harness properly rather than around it.
A hundred agents, writing documentation
A custom parser rendered the whole program as a single caller-callee tree. Vibe CLI then spawned over a hundred agents to describe the codebase, with reference PDFs available through document libraries and Mistral OCR. Work moved from the leaves of the tree upward, in self-contained subtrees empirically kept under about 10,000 lines. A reviewer agent looped on a cron schedule, picking up newly opened pull requests and scheduling fixes where it found problems.
Two failed shapes, then one that held
Attempt one handed each Fortran subroutine to its own agent, translating independently over the course of a week. The output ran, but it was barely modernized: COMMON blocks turned into global structs and the control flow was left untouched.
Attempt two put a planner, coder, tester and reviewer on each module. Quality improved, but agents stalled out on the harder bugs. The shape that worked was supervised: generate a target C++ architecture, have an engineer approve it, break it into a task queue, run plan-implement-test per task, and finish with a human PR review before anything merges.
What the post does not tell you
The customer is not named. There is no figure for how long the first sprint took, what it cost, or how it compares with a hand migration – anyone looking for a productivity multiple will not find one here. Mistral is explicit about the boundaries of the method: migrations that lean on external systems, lack a runnable baseline, or encode physics documented nowhere are harder cases. It is also a vendor writing up its own tooling, and no independent verification of the results has been published.
FAQ
How much Fortran did Mistral's agents actually migrate?
40,000 of roughly 300,000 lines of Fortran 77 in the first sprint, covering the simulator's core functionality. The remainder of the codebase was not yet ported.
What is a parity harness in a code migration?
A test setup that exports the old program's state and loads it into the new one, checking that both produce numerically identical results, including at intermediate checkpoints engineers flag as critical.
Can AI agents modernize legacy code without developers?
Not on Mistral's own account. The fully autonomous run produced working but barely modernized code; the workflow that succeeded required engineer sign-off on the architecture and human PR review before merge.