请问如何将指标传入副程式内?
例如:
program main
implicit none
integer, pointer :: ptr(:)
call sub(ptr)
write(*,*) ptr
end
subroutine sub(ptr)
implicit none
integer, pointer :: ptr(:)
allocate( ptr(3) )
ptr = (/1,2,3/)
end
我目的是希望能在副程式内,宣告阵列大小并赋予值。
最后并回传到主程式,但无法成功。
尝试了一下发现副程式接收的好像是指标所指的东西,而非指标本身。
请教各位高手,这该如何改写,谢谢