我是Fortran的新手,所以也许这是一个直截了当的问题,但我还没有找到任何通过查看SO上的类似帖子来工作的解决方案。Fortran模块链接失败
我的问题是,当我试图编译我的主要程序,通过执行
gfortran -c dfft.f
gfortran -c srft.f95
gfortran -c testsrft.f95
- 使用在srft.f95定义的模块srftModule testsrft.f95
gfortran dfft.o srft.o testsrft.o -o testsrft
(子程序S IN srftModule需要dfft.f中的Fortran77代码),我得到的链接错误
testsrftF.o: In function `MAIN__':
testsrftF.f95:(.text+0x98): undefined reference to `fftofmat_'
collect2: ld returned 1 exit status
该模块的定义如下
module srftModule
implicit none
contains
... (some subroutines)
subroutine fftofmat(A)
implicit none
real*8, dimension(:, :), intent(inout) :: A
...
end subroutine fftofmat
... (some more subroutines)
end module srftModule
而在我的主文件,我有
program testsrft
use srftModule
implicit none
...(code to initialize a 10x10 matrix A)
call fftofmat(A)
end program testsrft
为什么连接器抱怨?
链接器找不到'.mod'文件,请参阅http:// stackoverflow。com/questions/8855896/specify-directory-where-gfortran-should-look-for-modules –