Scott Bachman
Earth system modeling is in the midst of a hardware shift. Over half of the fastest supercomputers use GPU (graphics processing unit) accelerators, and four of the top five run on GPUs. This is a huge shift from 10 years ago, when most supercomputers were dominated by CPU (central processing unit) CPUs, and the vast majority of earth system models were coded to run on those architectures. Models running on GPUs are unlocking amazing leaps in performance and capability: for example, Oceananigans has run the global ocean at about 20x higher throughput than a CPU (central processing unit) model run at similar resolution (Silvestri et al., 2025).
The appeal of GPUs for these applications speaks for itself: ocean models apply the same stencil to millions of grid cells, so there are millions of independent pieces of work to distribute. This is exactly what a GPU is built for. The speed of doing calculations is limited by how fast data can be loaded from memory, not how fast the processor can do arithmetic, and modern data-center GPUs load data roughly 8 to 40 times faster than a 64-core CPU. GPUs also spend less energy per calculation, which is why the most energy-efficient supercomputers are GPU machines. For a modeling group, that translates into more simulated years per day, larger ensembles, higher resolution, and more comprehensive physics and chemistry packages that can be used for the same amount of computing resources.
Those benefits are what motivated us to try porting our in-house ocean model, the [C]Worthy fork of UCLA ROMS coupled to the MARBL biogeochemistry library (ROMS-MARBL), to GPUs using CUDA Fortran. Quantifying ocean-based carbon dioxide removal (CDR) projects requires running regional ocean models that include biogeochemical processes, adding significant computational cost over a physics-only model. Further, it is preferred to run with multiple ensembles (to quantify uncertainty), and with the highest possible resolution. This is exactly the kind of workload where more memory bandwidth and more arithmetic throughput per node pays off.
Using agentic AI for refactoring code
Prior to 2026, porting a mature ocean model to GPUs was a multi-year, multi-person project. This all changed with the new crop of advanced agentic artificial intelligence (AI) and large language model (LLM) coding tools released this year. We were able to complete a port of the ROMS-MARBL code in a matter of a few weeks. Working under our direction, nearly all of the code and documentation was written by Claude Code, Anthropic's AI coding agent. We set the goals, the design choices, and the verification tests the code had to pass; the agent wrote the CUDA Fortran, routine by routine, and our testing framework ensured that the GPU code remained aligned with the CPU code it was translating.
Agentic AI was powerful for this use case not only because of the efficiency with which LLMs can generate code, but also because the AI agent could perform the necessary computing tasks to check its own work. It built the model, ran unit tests on individual kernels, ran short and long simulations, compared output against the previous version and against the CPU model, and chased down differences until they were explained. Most of the debugging loop—from a failed comparison to a located bug to a fix and a rerun—ran without direct input. The same agent was also able to run C-Star, [C]Worthy's tool for setting up and running ocean simulations, to build cases and launch reference runs, which greatly improved the efficiency of testing.
Introducing ROMS-MARBL-GPU
ROMS-MARBL-GPU is a GPU version of [C]Worthy's fork of UCLA ROMS, coupled to the MARBL biogeochemistry library. This model can be used for most regional ocean carbon and biogeochemistry applications, including ocean-based CDR such as ocean alkalinity enhancement, which is a key application of interest for [C]Worthy. It is written in CUDA Fortran for NVIDIA GPUs and is now available as a beta release (v0.1.3-beta).
Core features of the GPU refactor include:
A holistic refactor of time-stepping scheme: Dynamics, K-Profile Parameterization (KPP) vertical mixing, tracer advection and mixing, tides, surface forcing, rivers and open boundaries.
MARBL: Surface fluxes and the interior ecosystem computations now run as GPU kernels, with parameters from the MARBL library, plus alkalinity and dissolved inorganic carbon (DIC) “CDR tracers” with all release types.
One GPU per Message Passing Interface (MPI) rank: Tiles are balanced by evenly distributing the number of ocean cells rather than by total geographic area, and halo exchanges go directly between GPUs.
Output in parallel: Separate I/O-dedicated processors write history and restart files in parallel while the GPUs keep time stepping.
We chose CUDA Fortran over a rewrite in a language like Julia because ROMS and MARBL are written in Fortran: modules, array indexing and loop structure carry over almost line for line, and porting the existing code is what made it possible to check the GPU model against the CPU model routine by routine.
The CPU model links a separately built MARBL library and calls its Fortran interface directly, but for the GPU model we chose to embed MARBL directly inside of ROMS rather than porting it as a separate library. This choice unlocked several efficiencies, such as the ability to use ROMS tracer arrays in MARBL and avoiding unnecessary data copies. Additionally, MARBL's per-column biogeochemistry is naturally parallel and suits GPUs. In total the difference in performance is impressive: on a full mesoscale resolving Pacific domain, the MARBL tendencies (with 178 million grid points) were calculated in 35 ms per call on GPUs compared to 2.30 s on the same number of CPU nodes (65 times faster). The full GPU model, including ROMS physics, ran 21 times faster than the CPU model.
Same equations, same answers
The GPU version of ROMS-MARBL is meant to be semantically identical to the CPU model: each time step follows CPU ROMS routine by routine, it reads the same namelists and input files as [C]Worthy UCLA ROMS (v0.11.0), and it writes the same output files (Figure 1).
Figure 1. The GPU mirrors the CPU step for step, which is what makes a direct comparison meaningful. A line-by-line comparison of the two source codes found that they solve the same discrete equations.
However, it is impossible for the GPU and CPU models to return bit-for-bit identical answers, because their compilers round arithmetic differently. We established a rule for Claude Code that, at each step of the porting process, the new code had to pass a series of numerical tests to ensure that the translation was semantically equivalent to the CPU’s code and that the arithmetic within each loop/kernel (CPU/GPU) differed only at round-off level. Enforcing this rule for each component of the model ensures that the GPU solution is as close as numerically possible to the CPU solution at each timestep. Extrapolating over the course of a full simulation, the GPU runs are statistically indistinguishable from CPU runs—down to the carbon uptake a CDR study reports, for example.
Video 1. A year-long comparison of dye releases from the GPU and CPU versions of ROMS-MARBL on the 4 km California Current System domain, run with MARBL for 2013. Each column follows a dye released at one of the five coastal sites used in the CPU–GPU comparison, from Sitka in the north to Punta Eugenia in the south, shown as daily surface concentration from January to mid-December.
Improvements in speed
Node for node, the GPU model runs* a full time step 21 times faster than the CPU model (using the Pacific domain with MARBL, including time for reading input and writing output):
*These runs were performed on Derecho (NCAR): a CPU node has 128 AMD EPYC cores, a GPU node has 4 NVIDIA A100s.
The tremendous speedup can be explained by two primary factors. First, running MARBL is an almost ideal GPU workload—thousands of independent water columns with lots of arithmetic. Second, the two models differ in how they handle the writing of output files: on the CPU, every process waits while the 59 GB restart file is written; on the GPU, each I/O process is handed to the dedicated I/O processors while the model keeps time stepping on the GPUs.
This table shows a comparison for a 120 day run of the California Current System (at 4km resolution), including start-up and all outputs:
For this configuration, on a node-for-node basis, the GPU runs 11x faster for a ROMS+MARBL run, using less than half of each GPU's memory.
In general, GPUs gain the most for large domains with many tracers. These configurations give each GPU enough work to keep it fully busy, and each added tracer means more data streamed through memory at every grid point, which plays to the GPU's high memory bandwidth. The same problem on CPUs must be split across many processes, often on many nodes, and the time spent exchanging boundary data between them grows as a share of the total, limiting how well the CPU model scales. Conversely, for small problems where the GPUs are not given enough work to stay busy, the gains can be significantly reduced, and it is even possible for the GPU model to run slower than the CPUs. For example, for a smaller domain we developed for an Icelandic fjord, running physics only, the GPU is 5 times faster on one node, but the CPU overtakes it on 8 nodes (Figure 2, bottommost blue dot).
Figure 2. GPU speedup, node for node, for three domains and three workloads on 1–16 Derecho nodes. Speed-up = CPU ÷ GPU time per step on the same number of nodes, excluding startup and output. Small problems spread over many nodes approach the GPU's fixed per-step cost, about 30–40 ms, and the CPU can overtake it.
What's next
The code is still in beta, and we’re still working on a few additional features:
C-Star support. ROMS-MARBL-GPU will be integrated into C-Star so users can set up and run the GPU model using the C-Star blueprints, preprocessing tools, and diagnostic packages (planned for late 2026).
Testing on newer hardware. Compared with running on an A100 GPU, we expect roughly 2× performance per GPU on an H100 and 3–4× on a B200 for large domains after a recompile; these are estimates, not measurements.
The code, build instructions, and full validation write-up are at github.com/CWorthy-ocean/roms-marbl-gpu. It is released under the GPL v3, derived from UCLA ROMS. We thank the CESR-lab at the University of California, Los Angeles for their collaboration.
Give it a try, and please submit any issues or bugs on GitHub. You can also reach out to support@cworthy.org for questions.