我需要通过引用将数组传递给子程序。而不是这个解释器复制矩阵。MAIN 中的静态矩阵仍然像{{0,0}{0,0}{0,0}}
. 我知道在fortran中所有的变量都是通过引用传递的。我做错了什么?
PROGRAM LAB1
IMPLICIT NONE
Real pointsOfTriangle(2,3)
call newTriangle(pointsOfTriangle)
call getTriangle(pointsOfTriangle)
pause
END
SUBROUTINE newTriangle(pointsOfTrinagle)
IMPLICIT NONE
Real pointsOfTriangle(2,3)
Integer i
do i=1,3
print *,'enter x,y:'
read *,pointsOfTriangle(1,i),pointsOfTriangle(2,i)
end do
do i=1,3
print *,'x[', i,']=',pointsOfTriangle(1,i)
print *,'y[', i,']=',pointsOfTriangle(2,i)
print *,' '
end do
END
SUBROUTINE getTriangle(pointsOfTriangle)
IMPLICIT NONE
Real pointsOfTriangle(2,3)
Integer i
do i=1,3
print *,'x[', i,']=',pointsOfTriangle(1,i)
print *,'y[', i,']=',pointsOfTriangle(2,i)
print *,' '
end do
END