LLM ports FESOM2 ocean model to C++/Kokkos with 100% physics fidelity
74,000 lines of Fortran ocean model ported to C++/Kokkos in weeks by LLM
In a groundbreaking demonstration of LLM-assisted software engineering, researchers at the Alfred Wegener Institute (AWI) have fully ported the FESOM2 unstructured mesh ocean–sea-ice model—originally written in 74,000 lines of Fortran—into a modern, performance-portable C++/Kokkos codebase. Using an agentic LLM coding assistant directed by domain experts, the team completed the translation in a matter of weeks. They employed a two-stage strategy: first converting Fortran to a clean C reference that preserves the original numerics, then introducing parallelism via C++/Kokkos. Crucially, the LLM was instructed to produce a strictly literal translation, forbidding any attempt to “improve” the source code. Each stage was validated against an acceptance criterion—long-term simulation statistics for the C port and bit-for-bit reproducibility on CPU for the Kokkos port.
The results are remarkable: the C port reproduces the original Fortran’s five-year simulation statistics, while the Kokkos version is bit-for-bit identical on CPU and statistically close on GPU over multi-year runs. On eddy-rich meshes with up to 7.4 million surface vertices, a single A100 GPU node runs 1.6–3.7 times faster than a CPU node, meeting the 1–2 simulated-years-per-day required for production integrations. This project proves that LLMs can handle complex, real-world scientific code migration without degrading physics—a milestone for climate modeling and high-performance computing. The authors emphasize that the key success factors were the staged translation, literal instruction, and rigorous validation, providing a blueprint for modernizing legacy scientific codebases.
- Two-stage translation: Fortran → clean C (preserving numerics) → C++/Kokkos for parallelism, done in weeks.
- LLM forbidden from 'improving' source; literal translation ensures bit-for-bit identical output on CPU.
- On A100 GPU, 1.6–3.7× speedup vs CPU on eddy-rich meshes (up to 7.4M vertices), achieving production throughput.
Why It Matters
Demonstrates LLMs can modernize legacy scientific code for GPU acceleration, unlocking faster climate simulations.