[Paper Review] Proof-of-concept: Using ChatGPT to Translate and Modernize an Earth System Model from Fortran to Python/JAX
The paper demonstrates a semi-automated workflow that translates a Fortran Earth System Model component to Python/JAX using GPT-4, achieving GPU-accelerated speedups and enabling automatic differentiation for parameter estimation, with a focus on leaf-level photosynthesis in CESM's CLM.
Earth system models (ESMs) are vital for understanding past, present, and future climate, but they suffer from legacy technical infrastructure. ESMs are primarily implemented in Fortran, a language that poses a high barrier of entry for early career scientists and lacks a GPU runtime, which has become essential for continued advancement as GPU power increases and CPU scaling slows. Fortran also lacks differentiability - the capacity to differentiate through numerical code - which enables hybrid models that integrate machine learning methods. Converting an ESM from Fortran to Python/JAX could resolve these issues. This work presents a semi-automated method for translating individual model components from Fortran to Python/JAX using a large language model (GPT-4). By translating the photosynthesis model from the Community Earth System Model (CESM), we demonstrate that the Python/JAX version results in up to 100x faster runtimes using GPU parallelization, and enables parameter estimation via automatic differentiation. The Python code is also easy to read and run and could be used by instructors in the classroom. This work illustrates a path towards the ultimate goal of making climate models fast, inclusive, and differentiable.
Motivation & Objective
- Motivate the need to modernize Earth System Models (ESMs) to be GPU-friendly and differentiable.
- Propose a divide-and-conquer workflow that translates Fortran code units to Python/JAX using static analysis and GPT-4.
- Demonstrate runtime improvements and parameter estimation capabilities on a leaf-level photosynthesis module from CESM CLM.
- Provide open-source tools and a proof-of-concept pathway toward more inclusive, fast, differentiable climate modeling.
Proposed method
- Split Fortran code into dependency-ordered units via static analysis and a topological sort.
- Translate each unit to Python/JAX using GPT-4 with unit tests to guide iterations.
- Run multiple Python variants (NumPy, Numba, SciPy, JAX) and compare runtimes on GPU vs CPU.
- Showcase differentiable parameter estimation for Vcmax using automatic differentiation and gradient-based optimization.
- Iterate with unit tests to improve translation quality and reliability.

Experimental results
Research questions
- RQ1Can a large-language-model-driven, divide-and-conquer approach reliably translate Fortran climate-model components to Python/JAX?
- RQ2Do Python/JAX translations via GPU acceleration offer substantial runtime improvements over native Fortran for selected model components?
- RQ3Does automatic differentiation enable efficient parameter estimation in the translated Python/JAX code?
- RQ4What are the practical challenges and limitations in scaling this translation to larger Fortran codebases?
Key findings
- JAX-GPU translation achieved the fastest runtimes among tested Python variants, with Fortran being two orders of magnitude slower.
- GPU-parallelized Python/JAX can significantly outperform CPU-based Fortran for the same module.
- jit-compiled Python approaches (JAX, Numba) perform reasonably close to Fortran, suggesting that compilation aids speed substantially.
- Automatic differentiation enables gradient-based parameter estimation for Vcmax, reducing iterations compared to uniform sampling in the leaf model.
- The translation workflow effectively demonstrates a path toward differentiable, GPU-enabled climate models and supports classroom-ready Python code.

Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.