arXiv:2610.41313cs.DCOct 2026

Manuscript Offprint

arXiv:2610.41313

Migrating a Legacy Scientific Application with an AI Coding Agent: NICAM from Fortran to Kokkos

Xuanzhengbo Ren, Takashi Shimokawabe, Hisashi Yashiro

XUANZHENGBO REN ±^{\pm}, Information Technology Center, The University of Tokyo, Japan

TAKASHI SHIMOKAWABE, Information Technology Center, The University of Tokyo, Japan

HISASHI YASHIRO, National Institute for Environmental Studies, Japan

Migrating from Fortran to C++/Kokkos broadens access to hardware accelerators through backends such as CUDA and HIP while offering greater flexibility in software design. However, legacy Fortran applications often have large codebases, making manual porting time-consuming and costly. Recent advances in large language models (LLMs) and AI coding agents have made large-scale code migration increasingly feasible. In this study, we ported NICAM (Nonhydrostatic ICosahedral Atmospheric Model), a legacy Fortran climate model accelerated with OpenACC, to C++/Kokkos with the assistance of Claude Code. The agent translated the code directly from Fortran to C++/Kokkos under human review. Approximately 140,000 lines of Fortran were analyzed and ported into 35,000 lines of C++/Kokkos, covering the dynamical core and seven physics packages. A 100-member ensemble comparison with the original Fortran model showed that the port is statistically consistent with the original. Performance was evaluated on Miyabi-G, an NVIDIA GH200 cluster, and Sirius, an AMD MI300A cluster. Compared with the Fortran/OpenACC baseline on GH200, the port achieved application speedups of 1.71×1.71\times on GH200 and 1.54×1.54\times on MI300A. The CUDA build achieved a GPU kernel-time speedup of 1.38×1.38\times on GH200. After normalization by peak memory bandwidth, the HIP build on MI300A achieved 0.96×0.96\times the kernel performance of the Fortran/OpenACC baseline.

Additional Key Words and Phrases: NICAM, Kokkos, agentic workflow, performance portability

1 Introduction

High-performance computing (HPC) systems span a diverse range of processor and accelerator architectures, with different requirements for parallel execution and memory access. Scientific applications must adapt to this diversity while remaining maintainable over development lifetimes that often outlast individual hardware generations. Performance portability is therefore an important goal. A shared implementation should run efficiently across target architectures without requiring a separate application codebase for each platform. Kokkos addresses this goal through C++ abstractions for parallel execution, memory spaces, and multidimensional data layouts [9]. Its CUDA and HIP backends provide a route to NVIDIA and AMD GPUs from a common source codebase [22].

Adopting such a framework is a substantial undertaking for mature scientific applications because many have accumulated large Fortran codebases over decades. These codebases combine numerical algorithms, physical parameterizations, communication routines, and input/output infrastructure. Migrating these applications to C++/Kokkos requires both language translation and careful mapping of data structures and parallel execution while preserving numerical behavior. The HOMMEXX atmospheric dynamical core illustrates the feasibility of this approach and the verification and performance engineering involved [3]. The expertise and time required for manual migration remain a barrier to porting a complete application.

Recent advances in large language models (LLMs) and coding agents offer a way to assist this work. With access to development tools, these agents can combine source-code translation with compilation, testing, and iterative correction. Fortran-to-Kokkos studies have demonstrated this approach on scientific kernels [12]. Application-scale studies have

Authors' Contact Information: Xuanzhengbo Ren, xuanzhengbo.ren@cc.u-tokyo.ac.jp, Information Technology Center, The University of Tokyo, Kashiwanoha, Chiba, Japan; Takashi Shimokawabe, Information Technology Center, The University of Tokyo, Kashiwanoha, Chiba, Japan; Hisashi Yashiro, National Institute for Environmental Studies, Onogawa, City of Tsukuba, Ibarak, Japan.

also reported agent-assisted migration of FESOM2 and ORB5 to C++/Kokkos under expert supervision [15, 19]. Together, these studies demonstrate the potential of coding agents for scientific software migration. For a production atmospheric model, the resulting implementation must preserve the behavior of coupled dynamical and physical processes while executing efficiently across target architectures. We therefore investigate whether human-directed, agent-assisted migration can meet these requirements in an application-scale C++/Kokkos port.

We address this question using the Nonhydrostatic ICosahedral Atmospheric Model (NICAM), whose original dynamical framework was developed by Tomita and Satoh [21]. NICAM uses an icosahedral grid and nonhydrostatic equations to support global atmospheric simulations. At sufficiently fine resolution, it explicitly represents deep convective circulations [20]. Its development over more than two decades has included substantial adaptation to successive supercomputers. Yashiro et al. applied OpenACC to its dynamical core on TSUBAME2.5 [23], and subsequent work demonstrated large-scale NICAM-based ensemble data assimilation on Fugaku [24]. Building on these efforts, we aim to make a production configuration of NICAM available on both NVIDIA and AMD GPUs through C++/Kokkos. The C++ implementation also provides a basis for future tuning through Kokkos and, where needed, native CUDA or HIP interfaces.

In this study, we use Claude Code [1], primarily with the Fable 5 model, to translate NICAM directly from Fortran to C++/Kokkos under human direction. The human defines the scope and constraints, reviews plans and structural decisions, and assesses progress at defined checkpoints. The migration proceeds module by module, using the Fortran implementation as the numerical reference and retaining its organization to support comparison and maintenance. Our scope covers the dynamical core and seven physics packages used in the selected production configuration. Component-level checks support development, while ensemble consistency testing evaluates the completed port outside the agent loop. This paper makes three contributions.

  • An application-scale port of NICAM's selected production configuration, translating approximately 140,000 lines of Fortran into about 35,000 lines of C++/Kokkos model source and covering the dynamical core and seven physics packages.
  • A layered validation approach combining component-level reference comparisons and an ensemble-inspired consistency test for coupled atmospheric simulations.
  • An experimental evaluation of performance on Miyabi-G (NVIDIA GH200) and Sirius (AMD MI300A), together with comparisons of 100-member ensembles from each implementation to assess agreement in simulated means and variability.

The remainder of this paper is organized as follows. Section 2 reviews related work on performance-portable scientific applications, agent-assisted code migration, and ensemble consistency testing. Section 3 presents our workflow, porting strategies, and verification protocol. Section 4 reports correctness, performance, and cost results and discusses their limitations. Section 5 concludes the paper and outlines future work.

References (8)