🤖 AI Summary
This work addresses critical defects in the quantum transport code libNEGF, including uninitialized memory reads, out-of-bounds writes, and misuse of boundary condition models, which collectively degrade performance. For the first time in a Fortran-based scientific computing codebase, this study systematically uncovers and validates the widespread presence of C/C++-like undefined behaviors. By integrating modern Research Software Engineering (RSE) practices—such as continuous integration, automated testing, compiler warning remediation, and continuous benchmarking—the project successfully rectifies multiple critical bugs, identifies performance regressions induced by system configuration changes, and establishes a reusable RSE framework. These interventions substantially enhance both code quality and performance stability.
📝 Abstract
This paper presents our research software engineering (RSE) experiences over two years with libNEGF, a quantum transport code. We describe practical approaches to code quality assurance--including continuous integration, automated testing, and compiler warning correction--and performance engineering through continuous benchmarking. Our systematic application of these practices revealed critical defects: uninitialized memory reads, out-of-bounds writes, and notably, a misunderstood mathematical model in our boundary condition handling. We also document how continuous benchmarking exposed performance regressions caused by HPC system configuration changes. Our findings provide data points suggesting that a dangerous class of defects--equivalent to undefined behavior in C/C++ and processor-dependent behavior in Fortran--is as prevalent in Fortran scientific codes as elsewhere. While libNEGF is implemented in Fortran, most recommendations are applicable to scientific software regardless of implementation language, and they can be implemented selectively or in their entirety for both new and existing projects.