【问题标题】:Compile multiple modules in separate files into one obj file in Intel Fortran ifort in Windows 7在 Windows 7 的 Intel Fortran ifort 中将多个单独文件中的模块编译为一个 obj 文件
【发布时间】:2015-03-08 02:46:33
【问题描述】:

我曾经这样做,在一个名为 umat.f90 的文件中,

!!! umat.f90
module1
!! Content of module1
end module1


module2
!! Content of module2
end module2


!! This has to be a subroutine to interface with some legacy code in a software called ABAQUS
subroutine umat (argument-list)
use module1
use module2
!! Content of umat
end subroutine umat

这行得通。我可以使用ifort -c umat.f90,然后它会生成一个umat.obj 链接到一个名为ABAQUS 的软件(我无法修改)。现在,因为 module1module2 可能会被重复使用,我想将它们保存在单独的 .f90 文件中以符合 DRY 原则。所以,这变成了三个独立的文件:

文件#1:

!!! module1.f90
module1
!! Content of module1
end module1

文件 #2:

!!! module2.f90
module2
!! Content of module2
end module2

文件#3:

!!! umat.f90
!! This has to be a subroutine to interface with some legacy code in a software called ABAQUS
subroutine umat (argument-list)
use module1
use module2
!! Content of umat
end subroutine umat

但是,现在如果我运行ifort /c module1.f90 module2.f90 umat.f90,它将生成 3 个 obj 文件。 umat.obj 似乎不再包含来自module1module2 的模块信息。

鉴于我只能提供一个.obj 文件与ABAQUS 接口,我可以将它们编译成一个大.obj 文件吗?

PS:我知道我可以使用 python 脚本每次自动将三个文件复制并粘贴到一个文件中,但这似乎是一种非常肮脏和不雅的方式。

【问题讨论】:

    标签: fortran fortran90 intel-fortran


    【解决方案1】:

    我没有对此进行测试,但我阅读了 ifort 文档,/Qipo[n] 选项可能有效。来自this

    /奇波[n] 此选项启用文件之间的过程间优化。 n 是一个可选的整数,它指定编译器应该创建的目标文件的数量。整数必须大于等于0。如果n大于0,编译器生成n个目标文件,除非n超过源文件的个数(m),这种情况下编译器只生成m个目标文件。

    例如:ifort /Qipo[1] /c module1.f90 module2.f90 umat.f90

    希望它有效!

    【讨论】:

    • Qipo-c(单个命令)呢,即 ifort /Qipo-c module1.f90 module2.f90 umat.f90?
    猜你喜欢
    • 1970-01-01
    • 2018-07-13
    • 2014-02-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-25
    • 2022-12-21
    • 1970-01-01
    相关资源
    最近更新 更多