Connect with us

NEWS

Mistral Moves 40,000 Fortran Lines With Human-Gated Agents

Mistral’s Applied AI team moved 40,000 of 300,000 Fortran 77 lines to C++ for a European energy operator after full autonomy produced Fortran-shaped code.

Published

on

Mistral’s Applied AI team moved 40,000 lines of Fortran 77 into C++ for a European energy operator. The code is a physics-heavy reservoir simulator with no test suite and no central docs.

Those 40,000 lines are the first sprint of a 300,000-line codebase. The agents did not finish it on their own.

The First Pass Just Retyped Fortran

On the first attempt, the team gave agents full run of the job: one agent per Fortran subroutine, each translating its function into C++ over the course of a week. The output ran. It was still Fortran.

COMMON blocks became global structs, one for one. GOTO-driven control flow stayed in place instead of becoming loops or early returns. The Applied AI write-up is blunt about what that pass produced.

It looked like Fortran retyped in C++ syntax rather than modernized code.

Mistral Applied AI team, technical write-up

A second pass added structure. A planner, a coder, a tester, and a code-quality reviewer worked each module together, and the C++ got cleaner. Then the source complexity caught up. Agents hit a bug, tried a few fixes, and stalled with no one there to unblock them.

The team landed in the middle: a person running coder, tester, and reviewer agents, module by module, with a human checkpoint when a run froze. That is also how the open-source Vibe CLI on GitHub is built to be used when a session is not set to auto-approve. The scientific core of this job never got the walk-away setting.

Why a 1977 Language Still Runs Reservoir Physics

Fortran 77 still sits under a lot of oil and gas simulation because the physics was written there and the original authors left. Mistral’s client had a self-contained, runnable tree, which is a kind starting point. The language itself is the other problem.

The standard that named the dialect has no modules, no namespaces, and no structured types. State lives in COMMON blocks, global memory shared across the whole program. Variables are typed by their first letter, so a misspelled name quietly creates a new variable instead of failing the compile. Names are capped at six characters, which is why a density routine in this codebase is called GASDEN and a cell index is called IC.

In the Fortran original, GASDEN writes gas density into a global RHOG array from a COMMON include, looping IC from 1 to NCELL. IC is an integer only because the name starts with I. The C++ rewrite is a function that takes a GasProperties object and a pressure and returns a double, with the grid loop moved to the caller. There is no line-for-line map to check, which is what makes a syntax-only port unverifiable.

FORTRAN 77 CONSTRAINTS THAT BROKE A LINE-BY-LINE PORT

Constraint Fortran 77 C++ target
Shared state COMMON blocks, global memory Typed objects passed as arguments
Names Capped at 6 characters Full identifiers
Types Implicit; I through N are integers Explicit types on every name
Program shape No modules, no namespaces Classes, namespaces, return values
Control flow GOTO and numbered DO loops Loops and early returns

The port also had to meet modern scientific libraries, named in the write-up as PetSc. PETSc scientific computing toolkit still offers Fortran bindings, so the point was not that Fortran cannot call it. The point was to stop storing the reservoir in COMMON arrays and to put the solver stack on the C++ side of an active toolkit.

They Built the Test Before the Port

Before agents were allowed to rewrite production physics, the team needed a way to prove the two codebases agreed. Agreement here meant the same numbers, both on final results and on intermediate points the client’s reservoir engineers had flagged.

They added Fortran subroutines that export program state, a C++ test framework that loads those checkpoints, and Skill.md files that steer agents into using both. In later runs, agents instrumented the Fortran side to dump snapshots and then used the C++ tests to check each migrated module.

Building that harness first made long agent runs safer, because a failed number is cheaper than a silent physics change. Mistral calls numerical parity an easy check and a convincing argument that a module is done, and says this should be one of the first steps on any modernization job of this kind. Syntax translation, the write-up notes, is largely solved. Proving a procedural program and an object-oriented one still compute the same reservoir is not.

A Hundred Agents Wrote the Missing Manual

Project docs were scattered across old PDFs and comments buried in the Fortran. One of the larger side wins was pulling that material next to the code. Procedural Fortran helps here: the whole program can be drawn as a single caller-callee tree.

The team parsed the tree with a custom parser, then used Vibe CLI to spawn over a hundred agents to document it. Each agent could pull the relevant PDFs through document libraries and Mistral OCR. Work started at the leaves and moved up. Each node spawned a subagent, wrote its note, and opened a pull request on the original repo. A reviewer agent on a cron loop watched new PRs, reviewed them, and filed fix tasks when a write-up was wrong.

That is the unglamorous half of agent labor on a 1970s scientific tree: reading, filing, and arguing with old PDFs until a later coding agent has something to read. The May 2026 Vibe post describes how Skills turn repeatable workflows into commands, which is the same idea as the Skill.md files that pointed these agents at dumps, tests, and docs instead of letting them improvise.

Reservoir Engineers Still Own the Merge

With the tree documented and the harness in place, the remaining work was how much freedom to give the agents while still getting mergeable C++. The team tried both extremes, from fully unattended runs to closely watched manual sessions, and kept the structured loop below for this codebase.

Working with the client’s reservoir engineers, they used the caller-callee tree to cut independent modules, self-contained subtrees of manageable size, empirically less than about 10,000 lines of Fortran. Each module went through the same sequence.

THE MODULE WORKFLOW THAT ACTUALLY MERGED

  1. Target design: Generate the C++ shape for the module before anyone translates a line.
  2. Engineer review: A reservoir engineer signs off on that design, or sends it back.
  3. Task queue: On approval, split the module into a list of implementation tasks.
  4. Inner loop: For each task, plan, implement, and test, then repeat until the harness agrees.
  5. Human merge: A person reviews the pull requests and requests changes until they land.

The mechanical rewrite is the cheap part. Undocumented physics, a stalled fix, and a wrong COMMON layout are not, and those are the points where an unattended agent stops being useful. Other labs translating Fortran kernels have been running into the same wall: models can emit plausible C++, and still need a number-for-number check plus a person who knows the science.

What the Product Page Promises

Mistral’s coding product tells teams they can translate entire codebases to modern stacks while keeping functionality and domain knowledge. The same page lists legacy migration, code modernization, async agents, and a CLI that explores, edits, and runs commands from natural language. Enterprise add-ons on the Vibe line include end-to-end code modernization as a delivered service, which is the bucket this Applied AI job sits in.

Vibe CLI, launched with Devstral 2 on December 9, 2025 and folded into the unified Vibe agent on May 28, 2026, does ship plan, accept-edits, and auto-approve modes. This reservoir job used the plan-and-review side of that harness, plus extra dump-and-check tools the product page does not advertise, plus a reservoir engineer on the design gate. Whole-codebase translation is the brochure line. The shipped method is a module under about 10,000 lines, a parity test, and a person with a merge button.

Most of the Simulator Is Still Fortran

The first sprint covered core functionality: 40,000 of 300,000 lines. That leaves 260,000 lines still in Fortran 77. The old tree was self-contained and runnable, which Mistral flags as a favorable starting condition.

CASES THIS METHOD DOES NOT YET COVER

  • External systems: Migrations that depend on other live systems were out of scope for the post.
  • No runnable baseline: If the old program cannot be executed, the parity harness has nothing to dump.
  • Undocumented physics: Code that encodes science written down nowhere adds a class of errors a compiler will not catch.

The three lessons they want carried to other large ports are the ones this job actually tested. Build the parity harness before you write migration code. Get the docs in order before you lean on the agents. At this scale, structured workflows with human review gates beat both full autonomy and hand-driven sessions. The remaining 260,000 lines will meet that same harness, those same reviewers, and that same merge button.

Frequently Asked Questions

Why Is Fortran 77 Hard to Port to C++?

The 1978 ANSI X3.9 standard, later filed as ISO 1539:1980, lets two subroutines share memory by COMMON layout rather than by a typed interface, and it types names by their first letter unless a programmer says otherwise. A C++ class port has to reconstruct that layout by hand, which is why a clean syntax rewrite cannot, on its own, prove the physics still match.

What Is a Numerical Parity Harness?

In this project it meant Fortran dump subroutines, a C++ test loader, and Skill.md files that forced agents to use both, checking final outputs and intermediate values the client’s reservoir engineers had flagged. One sample check reused a live Fortran gas-density value of 42.71834 as the C++ reference.

Did Fully Autonomous Agents Finish the Migration?

No. Vibe CLI ships an auto-approve mode that runs tools without asking, and that is not how the scientific core of this job was migrated. Mergeable C++ came from a human operating coder, tester, and reviewer agents after a week-long one-agent-per-subroutine pass had kept GOTO flow intact.

What Is PETSc and Why Did the Port Need It?

PETSc, pronounced PET-see, is Argonne National Laboratory’s toolkit for parallel PDE solvers. Its public 3.25.5 manual lists bindings for C, Fortran, and Python, and still names PFLOTRAN, a subsurface flow code, among Fortran-era users. Fortran can already call it; the C++ port was about reshaping COMMON data into objects the modern C++ APIs expect.

How Did Mistral Document the Fortran Call Tree?

A custom parser drew the program as one caller-callee tree, then agents started at the leaves, pulled old PDFs through Mistral OCR, and opened a pull request per node. A reviewer agent on a cron schedule scored those PRs and filed fix tasks when a write-up was wrong, so later coding agents were not guessing from six-character names alone.

Harry is the editor and lead writer of WEBWIZARD 360, which he owns and runs independently for readers around the world. Ten years in journalism, the early ones reporting and the later ones editing, shaped a simple rule about technology coverage: a vendor's claim stays a claim until it has been tested or documented. Benchmarks are run on the device itself, changelogs and filings are read in full, and a launch announcement is checked against what actually ships. He carries the same caution into the other nine sections, so business stories start with the accounts, science stories with the paper, and sports, entertainment, lifestyle, travel, auto, gaming and general news with whatever official record exists. Numbers are verified before publication, without exception. If an article turns out to be wrong, it is corrected on the page with a note that says what changed, in line with the corrections policy the site publishes. Reader mail reaches him at support@webwizard360.com, and he replies to it himself.

Continue Reading
Click to comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Trending