Introducing the Acorvid Legacy Fortran Compatibility Library

A common problem when revitalizing old scientific software is the need to recreate a working build environment. With standards-conforming code, this is usually straightforward, often a matter of setting a few compiler flags to initialize variables, persistently save local variables, adjust floating point exception-handling, etc. Occasionally one is faced with code that made use of library routines which are not available under the current build environment or which require a software license incompatible with the legacy code’s license. This is especially true of the routines provided with the book Numerical Recipes; back when the book was used as a primary text for numerical analysis, less attention was paid to software licenses and most students (now practicing engineers and developers) were unaware the code from the book was proprietary and could not be redistributed without a commercial license.

The Acorvid Legacy Fortran Compatibility (ALFC) library was created to assist in revitalizing legacy code by providing an open API to a number of proprietary and vendor-specific libraries. At present it contains compatibility interfaces for Numerical Recipes functions (FORTRAN 77 version) and the Sperry-Rand UNIVAC large scale systems libraries, MATH-PACK and STAT-PACK. The ALFC library is licensed under the MIT License which should be permissive enough for almost any application.

Routines in the library are graded by ‘level’ of implementation:

  • Level 0 means the routine name is known and it is scheduled for inclusion in the library
  • Level 1 means the routine is available as an argumentless ‘stub’; documentation is limited
  • Level 2 means the routine is available as a stub with arguments, with documentation provided for each argument
  • Level 3 means the compatibility routine provides the function of the original routine

Level 1 routines allow compilation testing of the original legacy code with minor editing to remove arguments from the calls to library routines. Level 2 routines allow compilation testing, ideally with no modification to the original application source code. Level 3 routines allow both compilation and runtime testing of the original application code.

At the time of writing, most routines in the ALFC library are at Level 1. The Sperry-Rand libraries have a more complete list of functions represented than the Numerical Recipes Fortran 77 (NR77) library, though the functions in that library are typically at Level 3. A number of the functions implemented in the NR77 compatibility library are simple wrappers around Fortran 2008 standard functions (Bessel functions of the first and second kind of orders 0 and 1 – J0, J1, Y0, Y1). Routines implementing matrix operations are typically wrappers around LAPACK and BLAS routines from netlib.

Part of the motivation for creating the ALFC library was a Stack Overflow question regarding a 1974 paper by Roland Jeppson, author of several books on pipe flow analysis. Code from that paper makes use of the Sperry MATH-PACK routine GJR for Gauss-Jordan elimination and solution of matrices. While refactoring the code to make use of LAPACK routines should not be terribly difficult, it can be daunting if one is more familiar with pipe flow analysis than legacy Fortran and numerical methods. Providing compatibility libraries extends the usefulness of Jeppson’s work and avoids completely rewriting abandoned code from scratch. But even if a rewrite is possible and desirable, verifying new code produces correct results is simplified if the older code can be revitalized enough to generate test data.

We at Acorvid believe valuable work is locked away in legacy code; anything that simplifies revitalization reduces the cost of reimplementation or maintenance and preserves the investment made in scientific software of any era.

Leave a Comment