我提前道歉,因爲已經有這類問題的帖子,但我是Fortran新手,我不理解他們。 我想使輸入文件名的子程序。用任何隨機名打開文件的子程序
我已經寫了下面的代碼,但它不能按需要工作。
PROGRAM reading
implicit none
integer::dati,n
character::namefile
namefile=file.txt
call read(n,dati,namefile)
print*,'Number of data:',dati
END PROGRAM reading
SUBROUTINE read(n,num,namefile)
character::namefile
Integer::n
integer, intent(out)::num
open(40,file='namefile')
n=0
do
n=n+1
read(40,*,end=999)
enddo
999 continue
num=n-1
END SUBROUTINE read
感謝
我知道有些東西沒有道理。 –