Refactoring Actively Developed Legacy Code

Refactoring Actively Developed Legacy Code

Tuesday, June 10, 2025 3:00 PM to Thursday, June 12, 2025 4:00 PM · 2 days 1 hr. (Europe/Berlin)
Foyer D-G - 2nd floor
Project Poster
Computational PhysicsDevelopment of HPC SkillsParallel Programming Languages

Information

Poster is on display.
Legacy code, is usually described as outdated coding practices and or poor documentation, poses significant challenges to future development and onboarding new programmers. When it comes to scientific code, these descriptions can be all too common. The top 10 Fortran codes used on the HPC Archer2 are on average, 27 years old. This longevity is both a strength and liability as the decades of accrued technical debt inhibit the adaption of developing and new technologies like GPU acceleration and in-house development of new functionality.

This project aims to safely refactor a specific Fortran code base, RMT (R-matrix with time-dependence), adding unit tests and removing excessive use of global variables. The goal is not to change the functionality but to apply modern Fortran coding standards and improve documentation. Over the course of 3 years, we hope to make significant progress in the systematic refactoring of RMT.

To do this RMT was profiled and the areas with the most global variable usage was identified. We could not just refactor the subroutines in these areas as no unit tests existed to ensure we were safely refactoring them. To address this, we took the functionality from these subroutines and moved them to new subroutines in new modules, passing the global variables needed as arguments to be called from the original subroutines. This allowed for unit tests to be created based on the new subroutines and they could be safely refactored, protecting the rest of the code from noticing any difference.

The inclusion of unit tests has allowed for easier refactoring and has already caught errors in development. File dependency graphs show a much cleaner less spaghetti-ified code and there is a reduced reliance on global variables, meaning the process of modernising this code base has begun and improving the code quality has made it easier to maintain and improve the quality of the code. This project highlights the benefits of systematically refactoring legacy code without losing functionality.
Format
On DemandOn Site

Log in

See all the content and easy-to-use features by logging in or registering!