File gfortran:如何控制.mod文件的输出目录

File gfortran:如何控制.mod文件的输出目录,file,gcc,gfortran,File,Gcc,Gfortran,有没有办法将gfortran(GCC)生成的.mod文件放入单独的输出目录?我知道如何使用-o标志放置对象文件或其他输出,如中所示: gfortran -c test.f03 -o /path/to/output/dir/test.o 但是.mod文件(由上述调用生成)不受-o标志的影响,而是放在当前目录中。一些商业编译器有一个类似-qmoddir的标志,但我找不到gfortran的类似标志 如果没有这样的标志,是否可以在额外的步骤中生成.mod文件以使-o标志生效?GNU文档指出-Mdir或

有没有办法将gfortran(GCC)生成的.mod文件放入单独的输出目录?我知道如何使用-o标志放置对象文件或其他输出,如中所示:

gfortran -c test.f03 -o /path/to/output/dir/test.o
但是.mod文件(由上述调用生成)不受-o标志的影响,而是放在当前目录中。一些商业编译器有一个类似-qmoddir的标志,但我找不到gfortran的类似标志

如果没有这样的标志,是否可以在额外的步骤中生成.mod文件以使-o标志生效?

GNU文档指出
-M
dir或其同义词
-J
dir指定
.mod
文件的输出目录。

根据(
-Mdir
给出了
gfortran:error:无法识别的命令行选项'-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.