Systematic LLM Translation of Legacy Scientific Code to Differentiable Frameworks: Application to a Land Surface Model
Pith reviewed 2026-06-27 23:55 UTC · model grok-4.3
The pith
An LLM agent pipeline translates a 19,000-line Fortran land surface model into equivalent differentiable JAX code.
A machine-rendered reading of the paper's core claim, the machinery that carries it, and where it could break.
Core claim
The pipeline converts the full CLM-ml-v2 Fortran land surface model to JAX while maintaining numerical equivalence. The translated model computes the complete Jacobian in a single backward pass, recovers physical parameters in eight times fewer steps than gradient-free optimization, and achieves a 24 times wall-clock speedup over sequential Fortran at ensemble size N=2,048. The model and pipeline infrastructure are released as a reusable framework.
What carries the argument
The five-phase LLM-based agentic pipeline that orders modules via static dependency analysis on the call graph, applies iterative compile-repair loops, and uses a Fortran reference oracle to enforce module-level numerical parity before full integration and gradient verification.
If this is right
- Gradient-based parameter estimation and sensitivity analysis become directly available for the land surface model.
- Data assimilation tasks can use exact gradients instead of finite-difference approximations.
- Ensemble simulations at scales of thousands of members complete in a fraction of the original wall-clock time.
- The same pipeline can be applied to translate additional legacy Earth system model components.
Where Pith is reading between the lines
- The method could extend to legacy codes in other domains such as atmospheric or ocean modeling.
- Differentiable versions of physical models may support hybrid physics-ML architectures that require end-to-end gradients.
- The observed ensemble speedup implies practical gains for uncertainty quantification workflows that rely on large sample sizes.
Load-bearing premise
The iterative LLM compile-repair loop with the Fortran oracle will produce modules that remain numerically equivalent after full call-graph integration and during gradient computation.
What would settle it
Execute the translated JAX model on the same input sets as the original Fortran version and observe output values or computed gradients that deviate beyond floating-point tolerance.
Figures
read the original abstract
Differentiable programming offers transformative capabilities for scientific modeling, enabling gradient-based parameter estimation, sensitivity analysis, and data assimilation. Yet, migrating legacy codebases into differentiable frameworks remains a challenge. We present a five-phase LLM-based agentic pipeline that translates legacy Fortran into JAX: static dependency analysis determines module translation order from the full call graph; iterative compile-repair loops correct errors autonomously; and a Fortran reference oracle enforces numerical parity at the module level before integration and gradient verification. We instantiate and evaluate the pipeline on CLM-ml-v2, a 19,000-line Fortran land surface model, and analyze agent behavior across 73 module translation tasks. The resulting differentiable model computes the complete Jacobian in a single backward pass, recovers physical parameters in eight times fewer steps than gradient-free optimization, and achieves a 24 times wall-clock speedup over sequential Fortran at ensemble size N=2,048. Both the translated model and pipeline infrastructure are released as a reusable framework for differentiating other Earth system model components.
Editorial analysis
A structured set of objections, weighed in public.
Referee Report
Summary. The paper presents a five-phase LLM-based agentic pipeline for translating legacy Fortran code to JAX, demonstrated on the 19,000-line CLM-ml-v2 land surface model across 73 modules. The pipeline performs static dependency analysis to order translations, uses iterative compile-repair loops, and applies a Fortran reference oracle for module-level numerical parity before integration and gradient verification. The authors report that the resulting differentiable model computes the full Jacobian in one backward pass, recovers physical parameters in eight times fewer optimization steps than gradient-free methods, and achieves a 24 times wall-clock speedup over sequential Fortran at ensemble size N=2,048, with both the model and pipeline infrastructure released as open artifacts.
Significance. If the numerical equivalence claims hold including for derivatives, this work offers a practical, reusable approach to converting large legacy scientific codes into differentiable form. This could enable gradient-based parameter estimation, sensitivity analysis, and data assimilation in Earth system models at scale. The explicit release of the translated model and pipeline infrastructure is a clear strength, supporting reproducibility and extension by the community.
major comments (2)
- [Pipeline description] Pipeline description (abstract and methods): The iterative compile-repair loop enforces numerical parity only at the per-module level with the Fortran oracle before full call-graph integration. No details are given on the gradient verification step (e.g., whether it checks derivatives via finite differences or JAX autodiff, tolerance thresholds, or handling of control-flow changes), leaving open the risk that repairs preserving scalar outputs alter associativity or evaluation order enough to change computed Jacobians. This directly underpins the single-backward-pass Jacobian, 8× optimization, and 24× speedup claims.
- [Results] Results (evaluation of 73 modules): The manuscript reports aggregate performance numbers but provides no per-module success/failure rates, error distributions, or ablation studies isolating pipeline components. This absence leaves the reliability of the translation process and the robustness of the headline metrics only moderately supported.
minor comments (1)
- [Results] A table or figure summarizing translation outcomes, repair iterations, and any residual discrepancies across the 73 modules would improve clarity and allow readers to assess scalability.
Simulated Author's Rebuttal
We thank the referee for their thorough review and constructive feedback. The two major comments identify areas where the manuscript can be strengthened with additional methodological detail and granular results. We address each point below and will revise accordingly.
read point-by-point responses
-
Referee: [Pipeline description] Pipeline description (abstract and methods): The iterative compile-repair loop enforces numerical parity only at the per-module level with the Fortran oracle before full call-graph integration. No details are given on the gradient verification step (e.g., whether it checks derivatives via finite differences or JAX autodiff, tolerance thresholds, or handling of control-flow changes), leaving open the risk that repairs preserving scalar outputs alter associativity or evaluation order enough to change computed Jacobians. This directly underpins the single-backward-pass Jacobian, 8× optimization, and 24× speedup claims.
Authors: We agree that the gradient verification procedure requires more explicit description. The current text references the step but does not elaborate on its implementation. In the revised manuscript we will add a dedicated paragraph in the Methods section specifying that gradient verification employs JAX autodiff with cross-checks against finite-difference approximations, states the tolerance criteria used, and describes how control-flow and associativity changes are monitored during the integration phase to preserve Jacobian fidelity. revision: yes
-
Referee: [Results] Results (evaluation of 73 modules): The manuscript reports aggregate performance numbers but provides no per-module success/failure rates, error distributions, or ablation studies isolating pipeline components. This absence leaves the reliability of the translation process and the robustness of the headline metrics only moderately supported.
Authors: The manuscript does analyze agent behavior across the 73 tasks, yet presents outcomes in aggregate form. We acknowledge that per-module breakdowns and component ablations would provide stronger support. In revision we will add these elements, either in the main text or as supplementary material, including success/failure counts per module, error distributions for the translated modules, and an ablation isolating the contribution of the dependency-analysis and compile-repair stages. revision: yes
Circularity Check
Empirical engineering demonstration with external Fortran oracle and timing benchmarks; no derivations reduce to inputs
full rationale
The paper describes an LLM-based translation pipeline evaluated on CLM-ml-v2 via module-level numerical parity checks against a Fortran reference oracle, followed by integration, gradient verification, and empirical measurements of Jacobian computation, optimization steps, and wall-clock speedups. These outcomes are obtained by direct execution and benchmarking rather than any mathematical derivation, parameter fitting, or self-referential definition. No equations or claims reduce by construction to prior fitted values or self-citations; the central results rest on observable runtime behavior against independent external references.
Axiom & Free-Parameter Ledger
Reference graph
Works this paper leans on
-
[1]
2026 , month =
Huntley, Geoffrey , title =. 2026 , month =
2026
-
[2]
2025 , eprint=
Towards fully differentiable neural ocean model with Veros , author=. 2025 , eprint=
2025
-
[3]
, title =
Kwa, Albert and Clymer, Jacky and McDougall, Cassidy and Greenblatt, Ryan and Denison, Carson and Roger, Gavin and Bowman, Samuel R. , title =. arXiv preprint , year =
-
[4]
and Cai, Carrie J
Park, Joon Sung and O'Brien, Joseph C. and Cai, Carrie J. and Morris, Meredith Ringel and Liang, Percy and Bernstein, Michael S. , title =. Proceedings of the 36th Annual ACM Symposium on User Interface Software and Technology , series =. 2023 , publisher =
2023
-
[5]
1998 , doi =
Recipes for Adjoint Code Construction , author =. 1998 , doi =
1998
-
[6]
Agricultural and Forest Meteorology , volume =
Moving beyond the incorrect but useful paradigm: reevaluating big-leaf and multilayer plant canopies to model biosphere--atmosphere fluxes -- a review , author =. Agricultural and Forest Meteorology , volume =. 2021 , publisher =
2021
-
[7]
Agricultural and Forest Meteorology , year =
Beyond surface fluxes: Observational and computational needs of multilayer canopy models , author =. Agricultural and Forest Meteorology , year =
-
[8]
arXiv preprint arXiv:1910.00935 , year =
Hu, Yuanming and Anderson, Luke and Li, Tzu-Mao and Sun, Qi and Carr, Nathan and Ragan-Kelley, Jonathan and Durand, Fr. arXiv preprint arXiv:1910.00935 , year =
arXiv 1910
-
[9]
Advances in Neural Information Processing Systems , volume =
Neural Ordinary Differential Equations , author =. Advances in Neural Information Processing Systems , volume =
-
[10]
and Peng, Liran and Lin, Jerry and Bhouri, Mohamed Aziz and Gupta, Ritwik and L
Yu, Sungduk and Hannah, Walter M. and Peng, Liran and Lin, Jerry and Bhouri, Mohamed Aziz and Gupta, Ritwik and L. Advances in Neural Information Processing Systems , volume =
-
[11]
Bradbury, James and Frostig, Roy and Hawkins, Peter and Johnson, Matthew James and Leary, Chris and Maclaurin, Dougal and Necula, George and Paszke, Adam and
-
[12]
Journal of Machine Learning Research , volume =
Automatic differentiation in machine learning: a survey , author =. Journal of Machine Learning Research , volume =
-
[13]
2025 , doi =
Jiang, Peishi and Shen, Chaopeng and others , journal =. 2025 , doi =
2025
-
[14]
Biogeosciences , volume =
A differentiable, physics-informed ecosystem modeling and learning framework for large-scale inverse problems , author =. Biogeosciences , volume =. 2023 , doi =
2023
-
[15]
Cowan, I. R. and Farquhar, G. D. , title =. Symposia of the Society for Experimental Biology , volume =
-
[16]
James Bradbury and Roy Frostig and Peter Hawkins and Matthew James Johnson and Yash Katariya and Chris Leary and Dougal Maclaurin and George Necula and Adam Paszke and Jake Vander
-
[17]
Efficient and Modular Implicit Differentiation , booktitle =
Blondel, Mathieu and Berthet, Quentin and Cuturi, Marco and Frostig, Roy and Hoyer, Stephan and Llinares-. Efficient and Modular Implicit Differentiation , booktitle =. 2022 , url =
2022
-
[18]
Zico and Koltun, Vladlen , title =
Bai, Shaojie and Kolter, J. Zico and Koltun, Vladlen , title =. Advances in Neural Information Processing Systems , volume =. 2019 , publisher =
2019
-
[19]
Veros v0.1 -- a fast and versatile ocean simulator in pure
H. Veros v0.1 -- a fast and versatile ocean simulator in pure. Geoscientific Model Development , volume =. 2018 , doi =
2018
-
[20]
Nature , volume =
Neural general circulation models for weather and climate , author =. Nature , volume =. 2024 , doi =
2024
-
[21]
Tang, Yujia and others , booktitle =
-
[22]
arXiv preprint arXiv:1412.6980 , year =
Adam: A method for stochastic optimization , author =. arXiv preprint arXiv:1412.6980 , year =
-
[23]
and ter Braak, Cajo J
Vrugt, Jasper A. and ter Braak, Cajo J. F. and Diks, Cees G. H. and Robinson, Bruce A. and Hyman, James M. and Higdon, Dave , journal =. 2009 , doi =
2009
-
[24]
The ensemble
Evensen, Geir , journal =. The ensemble. 2003 , doi =
2003
-
[25]
Nature Reviews Earth & Environment , volume =
Differentiable modelling to unify machine learning and physical models for geosciences , author =. Nature Reviews Earth & Environment , volume =. 2023 , doi =
2023
-
[26]
Tellus A: Dynamic Meteorology and Oceanography , volume =
Variational algorithms for analysis and assimilation of meteorological observations: theoretical aspects , author =. Tellus A: Dynamic Meteorology and Oceanography , volume =. 1986 , doi =
1986
-
[27]
Variational assimilation of meteorological observations with the adjoint vorticity equation
Talagrand, Olivier and Courtier, Philippe , journal =. Variational assimilation of meteorological observations with the adjoint vorticity equation. 1987 , doi =
1987
-
[28]
and Jupp, Timothy E
Raoult, Natasha M. and Jupp, Timothy E. and Cox, Peter M. and Luke, Catherine M. , journal =. 2016 , doi =
2016
-
[29]
and von Caemmerer, Susanne and Berry, Joseph A
Farquhar, Graham D. and von Caemmerer, Susanne and Berry, Joseph A. , journal =. A biochemical model of photosynthetic. 1980 , doi =
1980
-
[30]
Global Change Biology , volume =
Reconciling the optimal and empirical approaches to modelling stomatal conductance , author =. Global Change Biology , volume =. 2011 , doi =
2011
-
[31]
Boundary-Layer Meteorology , volume =
A simple unified theory for flow in the canopy and roughness sublayer , author =. Boundary-Layer Meteorology , volume =. 2007 , doi =
2007
-
[32]
Bulletin of the American Meteorological Society , volume =
The Canopy Horizontal Array Turbulence Study , author =. Bulletin of the American Meteorological Society , volume =. 2011 , doi =
2011
-
[33]
Differentiable programming for
Gelbrecht, Maximilian and White, Andrew and Bathiany, Sebastian and Boers, Niklas , journal =. Differentiable programming for. 2023 , doi =
2023
-
[34]
2023 , doi =
Wang, Yujie and Frankenberg, Christian , journal =. 2023 , doi =
2023
-
[35]
2026 , doi =
Tian, Wei and Yu, Hao and Zhao, Shuai and Cao, Yan and Yi, Wanying and Xu, Jian and Nan, Zhuotong , journal =. 2026 , doi =
2026
-
[36]
Bridging the gap:
Pietrini, Marco and others , booktitle =. Bridging the gap:
-
[37]
Ranasinghe, Kasun and others , journal =
-
[38]
Kwa, Anthony and Clymer, Jacob and Mallen, Alex and Nguyen, Minh and Choi, Seraphina and others , booktitle =. Can. 2025 , note =
2025
-
[39]
Journal of Advances in Modeling Earth Systems , year =
Parameter Estimation in Land Surface Models: Challenges and Opportunities With Data Assimilation and Machine Learning , author =. Journal of Advances in Modeling Earth Systems , year =
-
[40]
and Patton, Edward G
Bonan, Gordon B. and Patton, Edward G. and Harman, Ian N. and Oleson, Keith W. and Finnigan, John J. and Lu, Yunyan and Burakowski, Elizabeth A. , journal =. Modeling canopy-induced turbulence in the. 2018 , doi =
2018
-
[41]
Boundary-Layer Meteorology , volume =
Scalar concentration profiles in the canopy and roughness sublayer , author =. Boundary-Layer Meteorology , volume =. 2008 , doi =
2008
-
[42]
and Yang, John and Wettig, Alexander and Yao, Shunyu and Pei, Kexin and Press, Ofir and Narasimhan, Karthik , booktitle =
Jimenez, Carlos E. and Yang, John and Wettig, Alexander and Yao, Shunyu and Pei, Kexin and Press, Ofir and Narasimhan, Karthik , booktitle =. 2024 , note =
2024
-
[43]
and Wettig, Alexander and Lieret, Kilian and Yao, Shunyu and Narasimhan, Karthik and Press, Ofir , booktitle =
Yang, John and Jimenez, Carlos E. and Wettig, Alexander and Lieret, Kilian and Yao, Shunyu and Narasimhan, Karthik and Press, Ofir , booktitle =. 2024 , note =
2024
-
[44]
Platform for Advanced Scientific Computing Conference (PASC) , year =
Leveraging Large Language Models for Code Translation and Software Development in Scientific Computing , author =. Platform for Advanced Scientific Computing Conference (PASC) , year =. doi:10.1145/3732775.3733572 , note =
-
[45]
From Legacy
Gupta, Aditya and others , year =. From Legacy
-
[46]
2024 , note =
Li, Ziqian and others , journal =. 2024 , note =
2024
-
[47]
Global Change Biology , volume =
Inferring carbon fluxes from remote sensing data using data assimilation, model averaging and prediction error statistics: a sensitivity analysis , author =. Global Change Biology , volume =. 2015 , doi =
2015
-
[48]
2025 , note =
Enhancing Parameter Calibration in Land Surface Models Using a Multi-Task Surrogate Model within a Differentiable Parameter Learning Framework , author =. 2025 , note =
2025
-
[49]
Hybrid-Modeling of Land-Atmosphere Fluxes Using Integrated Machine Learning in the
El Ghawi, Rima and others , journal =. Hybrid-Modeling of Land-Atmosphere Fluxes Using Integrated Machine Learning in the. 2025 , doi =
2025
-
[50]
arXiv preprint arXiv:2403.02215 , year=
Joint Parameter and Parameterization Inference with Uncertainty Quantification through Differentiable Programming , author=. arXiv preprint arXiv:2403.02215 , year=
-
[51]
Symposia of the Society for Experimental Biology , volume =
Stomatal function in relation to leaf metabolism and environment , author =. Symposia of the Society for Experimental Biology , volume =
-
[52]
Deniz A. Bezgin and Aaron B. Buhendwa and Nikolaus A. Adams , title =. Computer Physics Communications , volume =. 2023 , issn =. doi:10.1016/j.cpc.2022.108527 , url =
-
[53]
Kucharski, F. and Molteni, F. and King, M. P. and Farneti, R. and Kang, I.-S. and Feudale, L. , title =. Bulletin of the American Meteorological Society , year =. doi:10.1175/BAMS-D-11-00238.1 , url =
-
[54]
Davenport, Ellen H. and Madan, J. Varan and Gjini, Rebecca and Brzenski, Jared and Ho, Nick and Hsu, Tien. JCM v1.0: A Differentiable, Intermediate-Complexity Atmospheric Model , journal =. 2026 , note =. doi:10.5194/egusphere-2025-6266 , url =
-
[55]
JAX-COSMO: An End-to-End Differentiable and GPU Accelerated Cosmology Library , journal =
Jean-Eric Campagne and Fran. JAX-COSMO: An End-to-End Differentiable and GPU Accelerated Cosmology Library , journal =. 2023 , doi =. 2302.05163 , archivePrefix =
arXiv 2023
-
[56]
Journal of the Australian Mathematical Society , author=
On Runge-Kutta processes of high order , volume=. Journal of the Australian Mathematical Society , author=. 1964 , pages=. doi:10.1017/S1446788700023387 , number=
-
[57]
Advances in Neural Information Processing Systems , volume =
Efficient and modular implicit differentiation , author =. Advances in Neural Information Processing Systems , volume =
-
[58]
and Churavy, Valentin and Paehler, Ludger and H
Moses, William S. and Churavy, Valentin and Paehler, Ludger and H. Reverse-mode automatic differentiation and optimization of. Proceedings of the International Conference for High Performance Computing, Networking, Storage and Analysis (SC21) , year =
-
[59]
Kahn, A. B. , title =. Commun. ACM , month = nov, pages =. 1962 , issue_date =. doi:10.1145/368996.369025 , abstract =
-
[60]
Trudy Geofiz
Basic laws of turbulent mixing in the surface layer of the atmosphere , author =. Trudy Geofiz. Inst. Akad. Nauk SSSR , volume =
-
[61]
Norman, J. M. , title =. Modification of the Aerial Environment of Crops , editor =
-
[62]
ACM Transactions on mathematical software (TOMS) , volume=
Algorithm 778: L-BFGS-B: Fortran subroutines for large-scale bound-constrained optimization , author=. ACM Transactions on mathematical software (TOMS) , volume=. 1997 , publisher=
1997
-
[63]
Nelder, J. A. and Mead, R. , year =. A Simplex Method for Function Minimization , volume =. The Computer Journal , publisher =. doi:10.1093/comjnl/7.4.308 , number =
-
[64]
Climate Models: Challenges for
M. Climate Models: Challenges for. 2nd International Workshop on Software Engineering for High Performance Computing in Computational Science and Engineering (SE-HPCCSE) , year =
-
[65]
M. Legacy. Journal of Computer Science & Technology , year =
-
[66]
Modernisation of the Integrated Forecasting System , journal =
-
[67]
Unsupervised Translation of Programming Languages , booktitle =
Rozi. Unsupervised Translation of Programming Languages , booktitle =. 2020 , url =
2020
-
[68]
and Ibrahimzada, A
Pan, R. and Ibrahimzada, A. R. and Krishna, R. and Sankar, D. and Wassi, L. P. and Merler, M. and Sobolev, A. and Pavuluri, M. and Sinha, S. and Jabbarvand, R. , title =. Proceedings of the 46th IEEE/ACM International Conference on Software Engineering (ICSE) , year =
- [69]
-
[70]
Kadosh, T. and others , title =. arXiv preprint arXiv:2504.15424 , year =
-
[71]
Nichols, J. A. and others , title =. arXiv preprint arXiv:2509.12443 , year =
-
[72]
Zhou, A. and Hawkins, L. and Gentine, P. , title =. arXiv preprint arXiv:2405.00018 , year =
-
[73]
and Pritchard, M
Rasp, S. and Pritchard, M. S. and Gentine, P. , title =. Proceedings of the National Academy of Sciences , volume =. 2018 , doi =
2018
-
[74]
Assessing the scales in numerical weather and climate predictions: will exascale be the rescue? , journal =
Philipp Neumann and Peter D. Assessing the scales in numerical weather and climate predictions: will exascale be the rescue? , journal =. 2019 , doi =
2019
-
[75]
and Koven, Charles D
Fisher, Rosie A. and Koven, Charles D. , title =. Journal of Advances in Modeling Earth Systems , volume =. 2020 , doi =
2020
-
[76]
Geoscientific Model Development , volume =
Gelbrecht, Maximilian and White, Amber and Bathiany, Sebastian and Boers, Niklas , title =. Geoscientific Model Development , volume =. 2023 , doi =
2023
-
[77]
Nature Communications , volume =
Irrgang, Christopher and Saynisch-Wagner, Jan and Thomas, Martin , title =. Nature Communications , volume =. 2021 , doi =
2021
-
[78]
Water Resources Research , volume =
Jiang, Peishi and Kidger, Patrick and Bandai, Toshiyuki and Baldocchi, Dennis and Liu, Heping and Xiao, Yi and Zhang, Qianyu and Wang, Carlos Tianxin and Steefel, Carl , title =. Water Resources Research , volume =. 2025 , doi =
2025
discussion (0)
Sign in with ORCID, Apple, or X to comment. Anyone can read and Pith papers without signing in.