arXiv(opens in a new tab)cs.AIAug 2026Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2608.12249

An Agentic Workflow for Legacy HPC Modernization: Converting the Two-Electron-Integral Core of GAMESS

Yuzhong Shen, Masha Sosonkina, Peng Xu, Mark S. Gordon

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Yuzhong Shen

Dept. of Electrical and

Computer Engineering

Old Dominion University

Norfolk, VA, USA

yshen@odu.edu

Masha Sosonkina

Dept. of Electrical and

Computer Engineering

Old Dominion University

Norfolk, VA, USA

msosonki@odu.edu

Peng Xu

Dept. of Chemistry

Iowa State University

and Ames National Laboratory

Ames, IA, USA

pxu@iastate.edu

Mark S. Gordon

Dept. of Chemistry

Iowa State University

and Ames National Laboratory

Ames, IA, USA

mgordon@iastate.edu

Abstract—Modernizing legacy Fortran is a problem of volume: the transformations are individually routine, but the codebases can be enormous, and across much of computational science the work simply goes undone. We propose an agentic workflow that takes this work on at production scale, and we set out to measure how far such delegation can reach. In this work, three prompt-specialized agent roles operate under a version-controlled specification that the agents themselves authored and revised, while humans hold a small number of gates. The arrangement is kept safe by an exact verification oracle inherited from the domain, and the boundary of safe delegation lies exactly where that oracle stops seeing.

We apply the proposed workflow in a case study, converting the two-electron-integral routines of GAMESS (General Atomic and Molecular Electronic Structure System), a mature quantum-chemistry package with a 48-year development history, from fixed-form Fortran 77 to free-form Fortran 2008. The scope of this work was twelve source files, 56,448 lines, and 225 subroutines for computing electron repulsion integrals. The agents ran as three Claude Code roles in isolated worktrees, and the work spanned four Claude model generations. Because the GAMESS group ships a standard test suite whose printed energies its user community treats as canonical, we could adopt bit-for-bit reproduction of those energies as the merge criterion, where a deviation in the twelfth decimal place counts as a failure rather than drift. All twelve source files pass a 51-test validation battery comprising the 49 standard GAMESS tests and two additional calculations, and across 612 test runs the number of chemistry-relevant differences is zero, and every file also passes the Jenkins tests that are used for continuous integration.

Keywords—GAMESS, Agentic AI, legacy code modernization, large language model agents, Fortran, software verification, high-performance computing, quantum chemistry software

I. INTRODUCTION

Fortran has been the working language of computational science since its introduction in the 1950s, and it remains so today. Climate and weather models, computational chemistry and materials codes, and the dense linear-algebra libraries beneath much of scientific computing are still written and actively developed in Fortra [1, 2]. The language has grown across a long line of standards, from FORTRAN 66 and 77 through Fortran 90, 95, 2003, 2008, and 2018, each adding what the previous generation lacked: free-form source, modules, array operations, object orientation, and parallelism. Yet the standards remain largely backward-compatible, and much of the deployed code never moved forward with them. A great deal of it is still fixed-form FORTRAN 77, a style many scientific packages kept long after Fortran 90 made it optional. These legacy codes carry numerical methods that current science depends on while obstructing the tooling, threading, and accelerator work that future science requires. Rewriting them in a modern standard is conceptually unremarkable and practically unbounded: the transformations are individually routine, the codebases are enormous, and the work has therefore gone undone across much of computational science.

Modernizing legacy Fortran, then, is a problem of volume rather than difficulty, and it is exactly the kind of volume that agentic AI, capable frontier models driven through automated loops, can now absorb. An agent that reads a file, rewrites it, compiles it, runs a test, and iterates until the test passes drives down the per-file human cost that left the work undone. That makes agentic modernization an attractive answer, and it raises the central question of this paper: the extent to which such work can actually be delegated, and the factors that bound it. But converting tens of thousands of lines of dense integral code does not so much remove the bottleneck as relocate it: no one will read the machine-written result to check it by hand. The question is how anyone would know the rewrite was wrong. For a quantum-chemistry kernel, being wrong need not mean crashing. It can mean a silently different digit in the twelfth decimal place of a self-consistent-field energy, propagating into a published result years later. The limit on delegation, then, is set not by how much an agent can write but by how much can be checked. In the present setting that constraint is a benign one, because legacy scientific codes are unusually well supplied with exactly the kind of checking that is required.

The code we modernized is one such package. GAMESS [3–6], the General Atomic and Molecular Electronic Structure System, computes molecular electronic structure from first principles, covering Hartree-Fock, density-functional theory, perturbation theory, coupled-cluster theory and multireference methods, as well as fragment approaches including the effective fragment potential [7]. The development of GAMESS began on 1 October 1977 under the National Resource for Computation in Chemistry, supported by the National Science Foundation; the codebase split into US and UK branches in 1981, and the US branch has since been maintained by the Gordon group, first at North Dakota State University and since 1992 at Iowa State University. It exceeds a million lines of Fortran, the overwhelming majority fixed-form F77 written between 1985 and the present.

Two of its properties make GAMESS especially well suited to this study. The first is its distribution model: GAMESS is source-available freeware rather than open source, free to download under mild license restrictions. A code that cannot accept drive-by community contributions accumulates exactly the sort of maintenance debt of interest here, so the licensing is part of what makes it representative, though it also means we cannot ship the modernized source as an artifact. The second property is the one that makes this study possible. GAMESS provides forty-nine standard test inputs, and its user community treats the outputs as canonical reference values, reproduced to the last digit. We supplement these with two additional calculations to broaden the validation coverage. This convention is more than documentation: It supplies a ready-made, exact, community-sanctioned definition of correct behavior.

Within the GAMESS codebase, we selected the electron-repulsion-integral (ERI) machinery that evaluates four-center integrals, (μν∣λσ)(\mu\nu \mid \lambda\sigma), in shell quartets. The eight int2 files span four ERI implementations: rotated-axis packages for (s,p,L) and (s,p,d,L) shell quartets that combine Pople–Hehre axis rotation with McMurchie–Davidson quadrature [8–10]; the Electron Repulsion Integral Calculator (ERIC) for selected (s)- through (g)-shell quartets [11]; and the general Rys-quadrature implementation [12–14]. Together with four related files: eftei, eftei_eric, eftei_genr03, and eftei_genr70, which we refer to collectively as the four-file ‘eftei’ family these constitute the twelve-file conversion scope. Every SCF iteration, every direct-MP2 amplitude, every coupled-cluster contraction, every gradient and Hessian, and every coupling term to the effective fragment potential passes through the ERI section of the code. It is simultaneously the most valuable part of the package to modernize, since COMMON blocks and fixed-form layout there obstruct threading and GPU offload, and the most unforgiving, since its outputs are physical observables that everything downstream consumes. Modernizing peripheral utility code would have established little; we deliberately targeted the component a careful maintainer would be most reluctant to touch.

With the target chosen and an exact check for correctness in hand, we state the central claim of the paper: a supervised agentic workflow can carry out legacy scientific-code modernization at production scale, with the specification rather than any model as its durable artifact; the reach of that delegation is set by the verification the domain affords, and scientific software affords more of it than is usually recognized. We support this claim with four contributions. 1) We design the workflow itself: three prompt-specialized roles operating under a version-controlled specification that the agents wrote and revised. 2) We distinguish what conversion mechanically requires from what it requires comprehension to do, and we locate the agentic contribution in the latter. 3) We show verification performed largely by the agents rather than merely on them, and report the outcome across all twelve files under two independent checks: an exact, bit-for-bit battery against baselines the agents captured, and the maintainers' own tolerance-based continuous-integration suite. 4) We characterize the resulting automation boundary empirically: what the agents did unaided, the one defect class that escaped them, the escape their verification could not structurally detect, and where human effort remained.

The remainder of the paper is organized as follows. Section II positions the work against modernization in comparable packages, rule-based Fortran tooling, and agentic code transformation. Section III describes the agentic workflow: its roles and specification, the demands a conversion places on the agents, and their self-verification. Section IV reports the results across all twelve source files. Section V discusses the workflow failures, the implications for the boundary of safe delegation, and the limits of the evidence. Section VI concludes the paper.

References (30)