AI-Assisted Migration of a Legacy Climate Model: NICAM from Fortran to C++
This presentation examines a real-world application-scale code migration using an AI coding agent. The authors migrated NICAM, a mature atmospheric model with over 140,000 lines of Fortran/OpenACC code spanning two decades of development, to C++/Kokkos. The study demonstrates that AI agents can perform substantial translation work within a disciplined workflow combining human oversight, iterative testing, and layered numerical verification, while achieving significant performance improvements on modern GPU architectures.Script
A two-decade-old climate model with 140,000 lines of Fortran needs to run on modern accelerators. The researchers asked whether an AI coding agent could migrate it to C++ and Kokkos without breaking the physics or sacrificing performance.
The workflow is deliberately constrained. The human defines scope, approves dependency plans, and reviews every milestone. The agent translates modules into Kokkos Views and parallel loops, generating both implementation and tests, but acceptance requires three validation tiers: unit tests against reference dumps, short integrated runs, and ensemble consistency checks.
Layered verification caught errors that isolated tests missed. All physics unit tests passed, yet the integrated run revealed that surface temperature reconstruction was omitted during initialization. The final ensemble tier ran 100 perturbed members per implementation for 10 days: 95.3 percent of all comparisons fell within two standard deviations, establishing statistical consistency rather than bitwise identity.
The Kokkos port ran 1.71 times faster than Fortran OpenACC on GH200 and 1.54 times faster on MI300A. Application speedups exceeded kernel speedups because the new implementation reduced data staging and kept state device-resident. The port is performance-portable across architectures but not yet equivalently tuned: HIP inherited CUDA tile sizes and leaves optimization headroom.
The port supports one production configuration, not every NICAM capability. Unsupported branches are explicitly rejected. The ensemble covered 10 days and 59 diagnostics, enough to establish consistency but not to prove correctness for longer climate integrations, alternative resolutions, or systematic boundary cases. Unit tests relied on a limited set of reference dumps, and the initialization error showed that routine-level validation can miss defects in upstream data flow.
The agent consumed 4 billion tokens over 23 days and generated code faster than humans could review it, making review capacity the bottleneck. The study establishes that an AI agent can produce a working scientific port under disciplined supervision, but it leaves open the full human cost and how to balance performance tuning against code readability. If you want to explore AI-assisted research like this or create your own video summaries, visit EmergentMind.com.