An Ocean Model Ported by a Large Language Model: Experience and Lessons from FESOM2 (Fortran to C to C++/Kokkos)

📅 2026-06-09
📈 Citations: 0
Influential: 0
📄 PDF
🤖 AI Summary
This study addresses the challenge of efficiently porting a production-grade Fortran ocean model to a modern, portable framework supporting both CPUs and GPUs while preserving physical accuracy. We propose a three-stage methodology: first, domain experts guide a large language model (LLM) to perform a strict literal translation of the FESOM2 ocean–sea ice model into C, ensuring numerical fidelity; second, the code is refactored into C++/Kokkos to enable parallel performance; and third, each stage undergoes targeted validation with explicit prohibitions against LLM-driven “optimizations.” Results demonstrate statistical equivalence between the C version and the original Fortran over five-year climate simulations. The Kokkos implementation achieves bit-for-bit reproducibility on CPUs and statistical equivalence on GPUs, delivering 1–2 simulated years per day on a single A100 node—1.6–3.7× faster than CPU-only execution—thus meeting production-level requirements.
📝 Abstract
Large language models (LLMs) can translate and modify source code, and have been shown to do so for codes of different complexity. Whether they can port a complete, production geophysical model to a different language without degrading its physics has not been established. We demonstrate that LLM-assisted code translation can preserve the physics of a complete production ocean model while moving it into a modern performance-portable form. We report our experience using an agentic LLM coding assistant, directed by domain experts, to port the FESOM2 unstructured mesh ocean--sea-ice model (about 74000 lines of core Fortran) first to C and then to C++/Kokkos for performance portability across CPUs and GPUs. We describe the practices that proved necessary, what worked and what did not, and the failure modes that we encountered. Three practices mattered most: translating in two stages that separate reproducing the numerics (Fortran to a clean C reference) from introducing parallelism (C to Kokkos); requiring a strictly literal translation in which the assistant was not permitted to ``improve'' the source; and validating each stage against an acceptance criterion suited to it. The C port reproduces the original Fortran at the level of long-term simulation statistics over five years. The Kokkos port is bit-for-bit identical to the C reference on CPU and statistically close on GPU over multi-year runs. On eddy-rich meshes up to 7.4 million surface vertices a single A100 GPU node runs 1.6--3.7 times faster than a CPU node, reaching the 1-2 simulated-years-per-day required for production integrations. The result is more than a single GPU port: by following a clear validation procedure, an LLM moved a full Fortran ocean model into another language and onto accelerators while preserving its physics in a matter of weeks.
Problem

Research questions and friction points this paper is trying to address.

ocean model
code porting
physics preservation
performance portability
large language models
Innovation

Methods, ideas, or system contributions that make the work stand out.

large language model
code translation
performance portability
ocean modeling
Kokkos
🔎 Similar Papers
2024-02-19Neural Information Processing SystemsCitations: 8
N
Nikolay V. Koldunov
Alfred Wegener Institute, Helmholtz Centre for Polar and Marine Research, Bremerhaven, Germany
S
Suvarchal K. Cheedela
Alfred Wegener Institute, Helmholtz Centre for Polar and Marine Research, Bremerhaven, Germany
Sergey Danilov
Sergey Danilov
Senior scientist, Alfred Wegener Institute, Helmholtz Centre for Polar and Marine Research
geophysical fluid dynamicsnumerical ocean modeling on unstructured meshes
D
Dmitry Sidorenko
Alfred Wegener Institute, Helmholtz Centre for Polar and Marine Research, Bremerhaven, Germany
S
Sebastian Beyer
Alfred Wegener Institute, Helmholtz Centre for Polar and Marine Research, Bremerhaven, Germany
Thomas Jung
Thomas Jung
Head of Climate Dynamics at Alfred Wegener Institute (AWI); Professor at the University of Bremen
Physics of the climate system and climate modelling