I am not a very expert Fortran programmer, but now that I have written many subroutines (in Fortran 90), I have to put them in Modules (employed by “use” statement in other subroutines and program) to avoid writing the interfaces. I have to use these modules with old code written in F77.
I don’t want the compiler to compile these modules again and again. So I created a static library from the “.o” files after compiling these modules:
ar rc libmymath.a module1.o module2.o module3.o
However I still need to keep the “.mod” files of these modules to be able to “use” them in my code.
My question: is it possible to pack these “.mod” files in the static library archive “.a” (as we did with .o files), so that everything is encapsulated in the single file static library?
P.S: by anywhere I mean across my systems, all of them use gfortran 64 bit.
No, it is not possible.
In an analogue to C/C++, a
.modfile is like a header file. It describes the contents of the module and theUSE <module>is similar to the#include <header>.These mod files are compiler (and often even version) specific and are required because modules name-mangle the functions and so there needs to be a lookup table for the resulting function names.