1
我正在弄溼Fortran,並且想將txt文件讀入數組。我覺得我已經嘗試了一切。 txt文件是逗號分隔的11行,每行有1個數字。Fortran 90讀取文件
這裏是我的代碼
program test
real:: obs1,i,jj,count,x_1
real,allocatable:: x(:)
open(1,file='data1.txt',status='old',action='read')
read(1,*) obs1
allocate(x(obs1))
do i=1, obs1
read(1,*) x_1
x(i)=x_1
end do
do jj=1, obs1
print*,x(jj)
end do
end program test
這是我收到的錯誤:
The highest data type rank permitted is INTEGER(KIND=8)
我希望你有認真的理由使用Fortran。這是......糟糕的,史前的,等等。 – i486
@ i486:爲什麼? Fortran仍然積極開發,數值計算非常優雅,編譯器通常比優化C等效率更高。 –
它由相應的「粉絲俱樂部」開發。但我認爲Fortran中沒有任何東西可寫,並且與C中的相同(除了相同的Fortran「粉絲俱樂部」),它會更緊湊,可讀性更好等。 – i486