LLM-Assisted Translation of Legacy FORTRAN Codes to C++: A Cross-Platform Study
Nishath Rajiv Ranasinghe, Shawn M. Jones, Michal Kucer, Ayan Biswas, Daniel O'Malley, Alexander Buschmann Most, Selma Liliane Wanna, Ajay Sreekumar
TL;DR
The paper investigates LLM-assisted translation of legacy Fortran HPC codes to C++ using open-weight models across two platforms (vLLM and SambaNova Cloud). It introduces a cross-platform evaluation workflow that quantifies translation quality via CodeBLEU against human ground truth, measures compilation success, and assesses output fidelity against the original Fortran programs. Findings show larger LLMs generally improve CodeBLEU similarity, compilation accuracy, and output similarity, though variability persists and platform-specific error modes are observed. The work demonstrates the viability of open-weight LLMs for Fortran-to-C++ translation within a reproducible framework, while highlighting the need for human-in-the-loop and further enhancements (data, prompting, and iterative feedback) for mission-critical scientific software. Practical impact lies in providing a standardized, open framework to evaluate and guide LLM-assisted translation workflows across HPC environments.
Abstract
Large Language Models (LLMs) are increasingly being leveraged for generating and translating scientific computer codes by both domain-experts and non-domain experts. Fortran has served as one of the go to programming languages in legacy high-performance computing (HPC) for scientific discoveries. Despite growing adoption, LLM-based code translation of legacy code-bases has not been thoroughly assessed or quantified for its usability. Here, we studied the applicability of LLM-based translation of Fortran to C++ as a step towards building an agentic-workflow using open-weight LLMs on two different computational platforms. We statistically quantified the compilation accuracy of the translated C++ codes, measured the similarity of the LLM translated code to the human translated C++ code, and statistically quantified the output similarity of the Fortran to C++ translation.
