【发布时间】:2019-08-28 15:40:22
【问题描述】:
我想在不同的 Fortran 可执行文件中使用在静态库(用 Fortran 编写)中编写的子例程。 这是我的工作示例:
subroutine my(a,b,c)
implicit none
real*8, intent(in) :: a,b
real*8, intent(out) :: c
!
c = a + b
!
end subroutine
这会生成一个我用这个 main 指向的 XXX.lib 文件:
program main
implicit none
!
real*8 :: var1, var2
real*8 :: out1
!
var1 = 15.0
var2 = 10.0
call mysum(var1,var2,out1)
!
write(*,*) out1
!
end program
一切正常,但是当我想在模块中定义我的子例程时出现问题,如下所示:
module mymodule
contains
!
subroutine mysum(a,b,c)
implicit none
real*8, intent(in) :: a,b
real*8, intent(out) :: c
!
c = a + b
!
end subroutine
end module
此时“主”编译器无法找到子例程。有没有办法让编译器“看到”模块内声明的子例程? 谢谢
【问题讨论】: