Abstract

Porting a mature ocean model to a new programming environment is usually a multi-year software-engineering effort. We explored how far this process can be accelerated by an agentic large-language-model coding assistant working under the direction of domain experts. Starting from FESOM2, an unstructured-mesh ocean–sea-ice model with roughly 74,000 lines of core Fortran, we produced first a C implementation and then a performance-portable C++/Kokkos version.

Two principles proved essential: separating numerical translation from parallelization, and requiring a deliberately literal translation rather than allowing the assistant to redesign or “improve” the source. The resulting C implementation reproduces the original Fortran over a 62-year hindcast, while the Kokkos version is bit-for-bit identical to C over a simulated year and runs unchanged on NVIDIA and AMD GPUs, achieving node-level speedups of 2.3–6.9 over CPU execution.

The exercise led us to the idea of code shadows: independent implementations of the same model on different technology stacks, kept aligned through systematic numerical verification rather than shared source code. A Kokkos shadow provides a platform for performance experiments, while a JAX shadow adds automatic differentiation and scales from a laptop to 256 GPUs.

We are now turning this logic back onto the original model, using lessons from the shadows to construct a cleaner Fortran re-implementation that remains byte-exact with FESOM2. This suggests a development model in which verified alternative implementations become tools for restructuring and extending established scientific software.

 

Here is the public livestream link (questions via Slido.com #CGDSeminar). Staff members can look for a Google Calendar invitation for the talk or check the "Staff-only Calendar". 

Please reach out to Sam Scalice (sscalice@ucar.edu) with any questions you may have.