arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2608.00130cs.PLcs.AIcs.CLcs.MScs.SE

Fortran通用转译器:概念验证

A Fortran General-Purpose Transpiler: Proof of Concept

发表机构索邦大学 · 法国国家科学研究中心 · 巴黎气候与环境科学研究所
查看机构详情
  • Sorbonne University(索邦大学)
  • CNRS(法国国家科学研究中心)
  • IPSL(巴黎气候与环境科学研究所)

机构由 AI 辅助整理,请以论文原文为准。

Shivamshan Sivanesan, Kazem Ardaneh

首次发表
浏览论文内容

中文总结 AI 辅助

研究针对Fortran专业知识断层问题,提出基于Python的FGPT编译器框架,可将Fortran转译为适配GPU或自动微分的代码,经气候建模内核验证,能自动生成正确的Python实现,为遗留Fortran代码现代化提供可靠路径。

中文摘要 AI 辅助

Fortran数十年来一直是高性能计算的基石,在众多领域仍无可匹敌,但该语言存在专业知识断层:新一代科学家几乎不熟悉它,而许多经验丰富的Fortran开发者如今才转向JAX等现代生态系统。这一断层常导致出现“Fython”——即带有Fortran思维编写的Python代码,无法利用现代框架。我们提出FGPT,这是一个基于Python的编译器框架,旨在弥合这一鸿沟。它提供系统化流程,可将Fortran转译为适配GPU的Fortran、通过Tapenade实现自动微分的Fortran,或NumPy与JAX模块。其架构包含三个阶段:(i)前端解析Fortran并提取目标过程及其跨模块依赖;(ii)中端将代码降低为中间表示,再转换为适配GPU或自动微分的Fortran,或NumPy类;(iii)后端重写控制流与表达式,生成可用于GPU加速和自动微分的JAX模块。虽然大语言模型在小段代码上有应用前景,但在社区科学代码规模(通常达数十万行)上存在不足,这类代码要求转换一致性、严格数值保真度及针对生产测试的验证,而FGPT通过在整个翻译过程中保留程序语义解决了这些挑战。我们在代表性气候建模内核上验证了该框架,结果显示它可生成正确、可微分的Python实现,无需人工干预。结合严谨的编译技术与现代加速器支持,FGPT为遗留Fortran代码的现代化提供了可扩展、可靠的路径。

英文摘要

Fortran has been the cornerstone of high-performance computing for decades and remains unmatched in many domains. Yet the language faces an expertise gap: a new generation of scientists is barely familiar with it, while many experienced Fortran developers are only now transitioning to modern ecosystems such as JAX. This gap often results in "Fython" - Python code written with a Fortran mindset - that fails to leverage modern frameworks. We present FGPT, a transpiler framework designed to bridge this gap. It provides a systematic pipeline that transpiles Fortran into GPU-adapted Fortran, auto-differentiable Fortran via Tapenade, or NumPy and JAX scripts. Its architecture comprises three stages: (i) a frontend that parses Fortran and extracts target procedures along with all their dependencies; (ii) a middle-end that lowers the code into an intermediate representation, then into GPU-adapted or auto-differentiable Fortran, or a NumPy class; and (iii) a backend that transforms NumPy scripts into JAX modules optimized for GPU acceleration and automatic differentiation. Large language models fail when applied to the scale of community scientific codes-often spanning hundreds of thousands of lines-where consistent transformations, strict numerical fidelity, and validation against production tests are non-negotiable. FGPT addresses these challenges by preserving program semantics throughout the entire translation. We verified the framework on representative climate modeling kernels and demonstrated that it produces correct, differentiable Python implementations without requiring manual intervention. By combining rigorous compiler techniques with modern accelerator support, FGPT offers a scalable, trustworthy path for modernizing legacy Fortran code.

补充信息

↑