如何在Fortran 95中包含来自不同文件的模块?
这个问题很明显,我想,虽然我在谷歌上搜索了一下,但我找不到任何解决办法。我想拆分我的源代码,以使其更易于维护。如何引用另一个文件中的模块?我想您正在寻找如何在Fortran 95中包含来自不同文件的模块?,fortran,fortran95,silverfrost-fortran,Fortran,Fortran95,Silverfrost Fortran,这个问题很明显,我想,虽然我在谷歌上搜索了一下,但我找不到任何解决办法。我想拆分我的源代码,以使其更易于维护。如何引用另一个文件中的模块?我想您正在寻找use语句。例如,您可能有一个包含模块定义的源文件outline: module abstract_types implicit none ! declarations contains ! procedure definitions end module abstract_types program hello_
use
语句。例如,您可能有一个包含模块定义的源文件outline:
module abstract_types
implicit none
! declarations
contains
! procedure definitions
end module abstract_types
program hello_there
use abstract_types
implicit none
! declarations
! executable statements
end program hello_there
然后,在另一个源文件中,使用模块的程序outline:
module abstract_types
implicit none
! declarations
contains
! procedure definitions
end module abstract_types
program hello_there
use abstract_types
implicit none
! declarations
! executable statements
end program hello_there
注:
- 任何
语句都位于use
语句之前implicit
语句按名称引用模块use
mod
文件),以满足use
语句中对模块的引用。mod
文件有点像头文件,但它是由编译器创建的
稍后,当您链接程序时,您将需要模块和程序的目标文件。@High Performance Mar:您如何指明mod文件所在的编译器?