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

发布于 2024-07-13 01:14:08 字数 313 浏览 11 评论 0原文

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

gfortran -c test.f03 -o /path/to/output/dir/test.o

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

如果没有这样的标志,是否可以通过额外的步骤生成 .mod 文件以使 -o 标志起作用?

Is there is a way to put .mod files, generated by gfortran (GCC), into a separate output directory? I know how to place object files or other output with the -o flag as in:

gfortran -c test.f03 -o /path/to/output/dir/test.o

But the .mod files (which are generated by the above call) are not affected by the -o flag and placed in the current directory. Some commercial compilers have a flag like -qmoddir, but I cannot find something similar for gfortran.

If there's no such flag, is it possible to generate the .mod files in an extra step to get the -o flag to work?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

远山浅 2024-07-20 01:14:08

GNU gfortran 文档表明-Mdir 或其同义词 -Jdir 指定 .mod 文件。

The GNU gfortran documentation indicates that -Mdir or its synonym -Jdir specifies the output directory for .mod files.

云胡 2024-07-20 01:14:08

根据官方文档-Mdir给出gfortran:错误:无法识别的命令行选项“-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.

As per official documentation (-Mdir gave 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.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文