程序报错Interface mismatch in global procedure
本帖最后由 306908677 于 2014-12-7 20:55 编辑不知道这是什么错误诶
program main
implicit none
interface
subroutine random_arr(a)
implicit none
integer(4),intent(out)::a(:)
end
end interface
integer , allocatable :: A(:)
integer , allocatable :: B(:)
call random_arr(A)
call random_arr(B)
print *,A
print *,B
end program
subroutine random_arr(a) 1警告: Interface mismatch in global procedure 'random_arr' at (1): ALLOCATABLE mismatch in argument 'a' /Users/StarkLee/Desktop/EQU.F90:4.22:
subroutine random_arr(a) 1警告: Interface mismatch in global procedure 'random_arr' at (1): ALLOCATABLE mismatch in argument 'a' Jarvis:~ StarkLee$
本帖最后由 Villain 于 2014-12-5 08:26 编辑
无法重现你的错误,修改了下面的部分,可以build了。可能是你用的是gfortran吧。
integer(4), allocatable :: A(:)
integer(4), allocatable :: B(:)
第 6 行改为
integer(4),intent(out),allocatable::a(:)
就可以了。
另外,不建议传递未分配的可分配数组。
根据经验,这样的做法不容易出错:谁定义,谁分配,谁释放。所以,主程序中定义的数组,就在主程序分配,并在主程序释放。 明白啦,非常感谢
页:
[1]