Legacy CPU-based scientific codebases in the DOE’s exascale ecosystem represent decades of investment but create a critical interoperability bottleneck for massively threaded GPU accelerators. This paper presents a systematic refactoring framework based on Fowler et al. (1999) principles to port and optimize these codebases for GPU execution while preserving correctness and performance. Targeted refactorings (Extract Method, Introduce Parameter Object, Replace Conditional with Polymorphism) eliminate monolithic structures and data clumps. Applied to mesoscopic materials simulations, the approach achieves >10× speedup on A100/H100 GPUs while maintaining numerical fidelity (relative error < 10^-10). The refactored codebases integrate seamlessly with the NET4EXA BXIv3 European interconnect (scaling to 8M endpoints with native GPU zero-copy support), making them fully actionable for real-time engineering in the Genesis Mission without rewriting from scratch. The framework incorporates automated detection of refactoring opportunities via XGBoost + TF-IDF commit-message classification (100% accuracy, Al-Fraihat et al. , 2024) and includes security and integrity validation based on large-scale empirical analysis (Iannone et al. , 2023). This work provides a practical, low-risk pathway for DOE scientific software teams to modernize legacy Fortran/C++ code for exascale GPU systems while preserving decades of domain knowledge.
Venerable et al. (Sun,) studied this question.