The emergence of foundational models and generative artificial intelligence (GenAI) is poised to transform productivity in scientific computing, especially in code development, refactoring, and translating from one programming language to another. However, because the output of GenAI cannot be guaranteed to be correct, manual intervention remains necessary. Some of this intervention can be automated through task-specific tools, alongside additional methodologies for correctness verification and effective prompt development. We explored the application of GenAI in assisting with code translation, language interoperability, and codebase inspection within a legacy Fortran codebase used to simulate particle interactions at the Large Hadron Collider (LHC). In the process, we developed a tool, CodeScribe, which combines prompt engineering with user supervision to establish an efficient process for code conversion. In this paper, we demonstrate how CodeScribe assists in converting Fortran code to C++, generating Fortran-C APIs for integrating legacy systems with modern C++ libraries, and providing developer support for code organization and algorithm implementation. We also address the challenges of AI-driven code translation and highlight its benefits for enhancing productivity in scientific computing workflows.
翻译:基础模型与生成式人工智能(GenAI)的出现有望显著提升科学计算领域的生产力,特别是在代码开发、重构以及跨编程语言翻译方面。然而,由于GenAI的输出无法保证完全正确,人工干预仍然必不可少。部分干预可通过特定任务工具实现自动化,同时结合正确性验证与高效提示开发等补充方法。本研究探索了GenAI在辅助代码翻译、语言互操作性以及代码库检查方面的应用,具体针对用于模拟大型强子对撞机(LHC)粒子相互作用的遗留Fortran代码库。在此过程中,我们开发了一款名为CodeScribe的工具,该工具将提示工程与用户监督相结合,建立了一套高效的代码转换流程。本文展示了CodeScribe如何协助将Fortran代码转换为C++、生成用于遗留系统与现代C++库集成的Fortran-C API,并为开发人员提供代码组织与算法实现支持。同时,我们探讨了AI驱动代码翻译面临的挑战,并强调了其对提升科学计算工作流生产力的积极意义。