Jos*_*ost 3 fortran module makefile
我有一个使用模块的 Fortran 程序,即它.mod在编译期间创建-files。我还写了一个Makefile使用所有.f90-files from src/puts all created .o-files in obj/and the binary in the current folder,一切正常。
我现在在不同的文件夹中重新编译我的程序以进行不同的计算(例如calc1/),即我将其复制Makefile到calc1/,输入make all,calc1/它所做的只是链接,因为目标文件已经存在。但是,如果程序包含任何模块,则编译器需要相应的.mod-files 出现在calc1/. 到现在为止,我重新编译了所有内容 ( make clean all),但是随着程序的增长,这需要太多时间!
我想出的一个可能的解决方案是为二进制文件 ( bin/)设置一个特定文件夹。但这不是一个可行的选择,因为我有工作在队列中,这显然需要一个稳定的二进制文件,同时我也在尝试新功能。
因此,我正在寻找一种以某种方式处理.mod类似于.o-files的-files的解决方案,例如将它们放在obj/.
我希望(大多数?)编译器会指定一个选项来更改模块文件路径。用gfortran,则该选项-J或-M (从该名男子页):
-Jdir
-Mdir
This option specifies where to put .mod files for compiled modules. It is also
added to the list of directories to searched by an "USE" statement.
The default is the current directory.
-M is deprecated to avoid conflicts with existing GCC options.
Run Code Online (Sandbox Code Playgroud)
我认为大多数编译器在包含的目录中查找 .mod 文件 -I
编辑
从 gfortran 4.6 开始,-M不再支持。用-J
根据我的配置脚本之一,该标志适用-module于ifort,pgf90尽管这些天我几乎从不使用这些编译器,因此其他人应该确认...