Degenerate Conic

Algorithms • Modern Fortran Programming • Orbital Mechanics

Feb 08, 2022

Packs

packs

There are a lot of classic Fortran libraries from the 1970s to the early 1990s whose names end in "pack" (or, more specifically, "PACK"). I presume this stands for "package", and it seems to have been a common nomenclature for software libraries back in the day. Here is a list:

Name First Released Description Original Source Modernization efforts
EISPACK 1971 Compute the eigenvalues and eigenvectors of matrices Netlib largely superseded by LAPACK
LINPACK 1970s? Analyze and solve linear equations and linear least-squares problems Netlib largely superseded by LAPACK
FISHPACK 1975? Finite differences for elliptic boundary value problems Netlib, NCAR jlokimlin
ITPACK 1978? For solving large sparse linear systems by iterative methods Netlib
HOMPACK 1979? For solving nonlinear systems of equations by homotopy methods Netlib HOMPACK90
MINPACK 1980 Nonlinear equations and nonlinear least squares problems Netlib fortran-lang
QUADPACK 1980? Numerical computation of definite one-dimensional integrals Netlib jacobwilliams
FFTPACK 1982? Fast Fourier transform of periodic and other symmetric sequences Netlib fortran-lang
ODEPACK 1983? Systematized Collection of ODE Solvers LLNL jacobwilliams
ODRPACK 1986? Weighted Orthogonal Distance Regression Netlib HugoMVale
FITPACK 1993? For calculating splines Netlib perazz
NAPACK 1988? Numerical linear algebra and optimization Netlib
MUDPACK 1989? Multigrid Fortran subprograms for solving separable and non-separable elliptic PDEs NCAR
SPHEREPACK 1990s? For modeling geophysical processes NCAR jlokimlin
SVDPACK 1991 For computing the singular value decomposition of large sparse matrices Netlib
LAPACK 1992 For solving systems of simultaneous linear equations, least-squares solutions of linear systems of equations, eigenvalue problems, and singular value problems GitHub Original code remains in active development.
PPPACK 1992 For calculating splines Netlib
REGRIDPACK 1994 For interpolating values between 1D, 2D, 3D, and 4D arrays defined on uniform or nonuniform orthogonal grids. ? jacobwilliams
ARPACK 1996 For solving large scale eigenvalue problems rice.edu arpack-ng

Note that some of these dates are my best guesses for the original release date. I can update the table if I get better information.

LAPACK is the only one of these "packs" that has seen continuous development since it began. But the majority of these codes were abandoned by their original developers and organizations decades ago, and they have been frozen ever since, a symptom of the overall decline in the Fortran ecosystem. Though in a state of benign neglect, they yet remain useful to the present day. For example, SciPy includes wrappers to MINPACK and QUADPACK (and lots of other FORTRAN 77 code). However, the only "upstream" for many of these packages is Netlib, a sourcecode graveyard from another time that has no collaborative component. So, mostly any updates anybody makes are never distributed to anyone else. Frequently, these codes are converted to other languages (e.g, by f2c) and fixes or updates are made in the C code that never get back into the Fortran code. I've mentioned before how Fortran users end up calling Fortran wrappers to C code that was originally converted from FORTRAN 77 code that was never modernized.

The problem is that these classic codes, while great, are not perfect. They are written in the obsolete FORTRAN 77 fixed-form style, which nobody wants anything to do with nowadays, but that continues to poison the Fortran ecosystem. They are littered with now-unnecessary and confusing spaghetti code constructs such as GOTOs and arithmetic IF statements. They are not easy to incorporate into modern codes (there is no package manager for Netlib). Development could have continued up to the present day, and each of these libraries could have state of the art, modern Fortran implementations of both the classic and the latest algorithms. Well it's not too late. We have the internet now, and ways to collaborate on code (e.g, GitHub). We can restart development of some of these libraries:

  • Convert them to free-form source
  • Clean up the formatting
  • Remove obsolete and now-unnecessary clutter
  • Clean up the doc strings so we can use FORD to auto-generate online documentation
  • Put them in a module so there is no chance of calling them with the wrong input types
  • Update them for multiple real kinds
  • Add automated unit testing
  • Add C APIs so that they can be called from C (and, more importantly, any language that is interoperable with C, such as Python)
  • Start adding newer algorithms developed in recent decades

Consider QUADPACK. This library has been used for decades, and translated into numerous other programming languages. The FORTRAN 77 version is still used in SciPy. Note that recently some minor bugs where found in the decades-old code. The edits actually made it back to Netlib through some opaque process, but the comment was made "I do not expect a lots of edits on the package. It feels like a bug here and there." Unfortunately, this has been the perception of these classic libraries: the old Fortran code is used because it works but nobody really wants to maintain it. Well, I've started a complete refactor of QUADPACK, and have already added new features as well as new methods not present in the original library. Also consider FFTPACK and MINPACK, which were recently brought under the fortran-lang group on GitHub and development restarted as community projects. Our (ambitious) goal is to try to get SciPy to use these modernized libraries instead of the old ones. Other libraries can also move in this direction. Note: we don't have forever. SciPy recently replaced FFTPACK with a new library rewritten in C++. It's inevitable that all the old FORTRAN 77 code is going to be replaced. No one wants to work with it, and for good reason.

It's time for the Fortran community to show examples of how modern Fortran upgrades to these libraries are a better option than rewriting them from scratch in another language. With a little spit and polish, these classic libraries can have decades more life left in them. There's no need for our entire scientific programming heritage to be rewritten every few years in yet another new programming language (C, C++, Matlab, Octave, R, Python, Julia, Rust, Go, Dart, Chapel, Zig, etc, etc, etc). These libraries can be used as-is in other languages such as Python, but modernizing also makes them easier to use in actual Fortran applications. We already have the new versions available for use via the Fortran Package Manager (FPM), so adding them to your Fortran project is now a simple addition to your fpm.toml file:

[dependencies]
minpack = { git="https://github.com/fortran-lang/minpack.git" }
quadpack = { git="https://github.com/jacobwilliams/quadpack.git" }

Now isn't that better than manually downloading unversioned source files from an ftp server set up before many of the people reading this were born?

Update: See also this thread at the fortran-lang Discourse.

References