[Fortran] 纯文本查看 复制代码
Program main
Integer,parameter :: length=1000
Character(LEN=length) A,B,Filename
Integer(kind=4)::Column, Row, K,L
Column=0;Row=0;K=0;L=1;filename="test.txt"
Open (55,file=Filename)
Read(55,'(A)') A
Do I=1, length
If(A(I:I)==','.or.A(I:I)==' ') then
If(I-1>=L) Column=Column+1
L=I+1
End if
End do
CLOSE(55)
Open (55,file=Filename)
Do
Read(55,*,iostat=k) B
If( k /= 0 ) Exit
Row = Row + 1
End Do
Close(55)
Write(*,"(A5,I6,5X,A7,I2)") "Row=",Row,"Column=",Column
End
[Fortran] 纯文本查看 复制代码
DO WHILE(.TRUE.)
READ(55,*,IOSTAT=IOSTAT)
IF(IOSTAT,NE.0) EXIT
LINES=LINES+1
ENDDO
WRITE(*,*) LINES