是否有办法将由gfortran(GCC)生成的.mod文件放入单独的输出目录?我知道如何使用-o标志放置目标文件或其他输出,如:
gfortran -c test.f03 -o /path/to/output/dir/test.o
但是.mod文件(由上面的调用生成)不受-o标志的影响并放在当前目录中。一些商业编译器有一个像-qmoddir的标志,但我找不到类似的gfortran。
如果没有这样的标志,是否可以在额外的步骤中生成.mod文件以使-o标志起作用?
答案 0 :(得分:11)
GNU gfortran文档表明-M
dir 或其同义词-J
dir 指定{{1}的输出目录文件。
答案 1 :(得分:0)
根据official documentation(-Mdir
给出了gfortran: error: unrecognized command line option ‘-Mobj’
):
-Idir
These affect interpretation of the INCLUDE directive (as well as of the #include directive of the cpp preprocessor).
Also note that the general behavior of -I and INCLUDE is pretty much the same as of -I with #include in the cpp preprocessor, with regard to looking for header.gcc files and other such things.
This path is also used to search for .mod files when previously compiled modules are required by a USE statement.
See Options for Directory Search in Using the GNU Compiler Collection (GCC), for information on the -I option.
-Jdir
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.
-fintrinsic-modules-path dir
This option specifies the location of pre-compiled intrinsic modules, if they are not in the default location expected by the compiler.