Google Antigravity Turned a 40-Year-Old Fortran Ocean Model Into Memory-Safe Rust in 59 Minutes

Using Gemini 4 Argon inside Google Antigravity, a team migrated the core of FVCOM, a 174,000-line Fortran coastal ocean model, into 100% memory-safe Rust in under an hour — catching six decades-old bugs, cutting memory use by 54%, and running simulations 1.88 times faster.

Some codebases are so old and so load-bearing that nobody dares touch them. FVCOM, the Finite-Volume Community Ocean Model, is one of them: 174,774 lines of Fortran 90 and C spread across 264 files, written over four decades to simulate coastal oceans. It works, it matters, and it carries the kind of hidden defects that only decades of quiet use can accumulate. In a new demonstration from the Google Antigravity team, that entire core was rewritten in Rust — not over months, but in 59 minutes, driven by a single prompt and Gemini 4 Argon.

The prompt itself was the specification. It demanded four things and left no room for shortcuts: every line of Rust had to be memory-safe, enforced with #![forbid(unsafe_code)] and zero unsafe blocks; hot loops could not allocate on the heap, using Struct-of-Arrays layouts instead; no Rust file could exceed 400 lines, and each had to carry runnable doc-tests; and the port had to reach at least 95% branch coverage with zero numerical difference across 100 randomized seeds. Those constraints are what made the result trustworthy rather than merely fast to produce.

The run unfolded in three stages. First came an 11-minute baseline capture, compiling the Fortran with gfortran -O3 and building a benchmark harness so every later claim could be measured against the original. Then, in just 3 minutes, the agent audited the full repository and produced a six-part migration blueprint. The final 45 minutes were the port itself: 13 Rust modules, each under 240 lines, with self-healing test cycles and LLVM profile-guided optimization layered on top.

What the agent found along the way is the part that should make any maintainer pause. Six bugs had survived for decades in production code: buffer and integer overflows, out-of-bounds and uninitialized reads, and an unguarded square root of salinity. The self-healing loop caught its own mistakes too — 36 of 37 unit tests passed on the first attempt, the agent fixed a single-layer vertical flux bounds failure, and then all 42 tests passed with 96.8% branch coverage. Across 100 randomized seeds, the Rust output matched the Fortran to 12 decimal places, a difference of just 3.91e-13.

The performance story came in layers, each one earned. Idiomatic safe Rust alone ran 1.29 times faster than the original. Struct-of-Arrays layouts with zero loop allocations pushed that to 1.61x. LLVM profile-guided optimization finished the job at 1.88x — 469 milliseconds against the original 883 — while memory use fell 54%, from 11.84 MB to 5.48 MB. The whole workflow is now released as an open-source skill in the Google Skills repository on GitHub, runnable inside Antigravity with /migrate-to-rust <github-repo-url>. The message is hard to miss: the hardest part of modernizing legacy scientific code may no longer be the rewrite itself.

Read the original · antigravity.google

Share