主题:[讨论]看一下这段代码为什么能运行?
下面代码形参类型和实参类型不一样
program exam
implicit none
integer:: N,i
real(8):: a
real(8),allocatable:: res(:) !allocatable 属性
N = 5
a = 3.d0
allocate(res(N))
call master(N,a,res)
write(*,*) res
endprogram exam
subroutine master(N,a,re)
implicit none
integer:: N
real(8):: a
real(8):: re(N) !没有allocatable属性
re = a
endsubroutine master
master子程序的实参res有allocatable属性,而形参re没有allocatable属性,代码可以正常运行,why?
program exam
implicit none
integer:: N,i
real(8):: a
real(8),allocatable:: res(:) !allocatable 属性
N = 5
a = 3.d0
allocate(res(N))
call master(N,a,res)
write(*,*) res
endprogram exam
subroutine master(N,a,re)
implicit none
integer:: N
real(8):: a
real(8):: re(N) !没有allocatable属性
re = a
endsubroutine master
master子程序的实参res有allocatable属性,而形参re没有allocatable属性,代码可以正常运行,why?