[Fortran] 纯文本查看 复制代码
Subroutine NUM_LINE(Num)
Integer::Numline=0,value=0,Num
Character line
OPEN(UNIT=11,FILE='material.txt',STATUS='OLD')
Do While(value==0)
Read(11,*,iostat=value) line
If(value/=0)cycle
Numline=Numline+1
End Do
Num=Numline
Close(11)
End
[Fortran] 纯文本查看 复制代码
Integer Function Num_Line() result( Num )
Integer :: k
Character :: line
Num = 0 !//这个很重要
OPEN(11,FILE='material.txt',STATUS='OLD')
Do
Read(11,*,iostat=k) line
If( k /= 0 ) exit
Num = Num + 1
End Do
Close(11)
End Function Num_Line