在 Fortran 95 上,我收到一条错误消息,指出 itemarray(size) 不能是 intent(out),这没有任何意义,因为您正在从文件中读取 itemarray。我该如何解决这个错误?
在这个子例程中,我基本上是在尝试从文件中读取并将值存储在数组中。
下面是我所指的子程序的代码。任何帮助表示赞赏。谢谢你的时间。
SUBROUTINE readItems(size,itemarray,priarray,quarray)
INTEGER:: iost=0, i=0
INTEGER, INTENT(OUT):: quarray(50)
INTEGER, INTENT(OUT):: size
REAL, INTENT(OUT):: priarray(50)
CHARACTER(20),INTENT(OUT)::itemarray(50)
CHARACTER(20)::namefiletoread
PRINT*,"Enter the name of file you would like to read: "
READ*,namefiletoread
OPEN(UNIT=77,FILE = namefiletoread, ACTION = "READ", STATUS="REWIND",IOSTAT=iost)
IF(iost>0)STOP "Problem opening the file!"
DO i=1, size
READ(77,'(A,F6.2,I8)',IOSTAT=iost), itemarray(i), priarray(i),quarray(i)
IF(iost<0)STOP
END DO
END SUBROUTINE