Clicky

Packaging and Distribution of Fortran Libraries

November 25, 2008

What are the best practices for building and distributing modern Fortran libraries, say as a Debian package? Assuming that the library consists of a number of modules, a primary problem for distributing a compiled library for a specific platform is that module files are compiler-specific. For Debian it might make sense to simply distribute GFortran .mod files but what about other cases? The -dev packages for such libraries might need to be compiler-specific, for example, libname-dev-gfortran. Might there be issues with distributing .mod files for commercial compilers?

Furthermore, what is the proper place to install the .mod files? The FHS states that /usr/include is for C include files. A strict reading would prevent Fortran mod files from being placed there for two reasons: they are not related to C and they are not include files. Wherever they are installed, a common location for all packages like /usr/lib/gfortran/modules opens up the potential for namespace issues. Modules with the same name from different libraries would cause conflicts. Perhaps a better location might be /usr/lib/<package>/mod/ or even /usr/lib/<package>/mod/<compiler>/? The unfortunate thing with this setup is that the specific path will need to be given for each library one needs to link to. Contrast this with simplicity of the usual -I/usr/include arguments given to C and C++ compilers.

libmpich1.0-dev is an example of a Debian package of a Fortran library. The .mod files for this are installed in /usr/lib/mpich/include/f90base/ and /usr/lib/mpich/include/f90choice/. This package assumes the use of GFortran which is reasonable for a Debian package.

There seems to be no consensus on these issues but I’ve found a few instances where they have been discussed: