【发布时间】:2015-01-03 08:48:34
【问题描述】:
我正在学习 Fortran,但我一直在尝试编译一个模块以供以后使用。
在主程序中我有这个,它要求输入两个数字,然后调用模块中的函数:
use exponentiate
integer::a,b
write *, 'A'
read *, 'a
write *, 'B'
read *, 'b
write *,expo(a,b)
(我没有尝试过,因为我需要先编译模块,但这不是问题)
然后,在另一个文件中,我有这段代码,它(如果我理解正确的话)只是一个标准模块,具有对两个数字求幂的函数。
module exponentiate
interface test
module procedure expo
end interface
contains
function expo(a,b)
type(integer), intent(in)::a,b
type(integer) expo
integer::temp
temp=a
do i=1,b
temp=temp*a
end do
expo=temp
end function expo
end module exponentiate
我一直试图根据编译器错误找出语法,因为 Fortran 95 规范不可读且几乎无用。有了这个和一些 Wikipedia/SO 的帮助,我已经能够弄清楚一些事情,但我不知道为什么会弹出这个编译器错误。
我不确定这是因为某些语法问题还是 gfortran 的误用,因此我们将不胜感激。
【问题讨论】: