[Fortran] 纯文本查看 复制代码
Program www_fcode_cn
Use DFile_Mod
Implicit None
Real , allocatable :: a(:,:)
Character(len=512) :: cStr
Real :: r
integer :: FILE_IN , i , nRow , nCol
Open( NewUnit = FILE_IN , File = "text.txt" )
nRow = GetFileN( FILE_IN ) - 2 !//获得文件行数
Read( FILE_IN , * ) !//跳过第一行
Read( FILE_IN , * ) !//跳过第二行
Read( FILE_IN , '(a512)' ) cStr!//读取第三行
nCol = GetDataN( cStr ) - 1 !//获得第三行有多少列
write( *, '("Row:",g0," Col: ",g0)' ) nRow , nCol
Allocate( a( nCol , nRow ) )
Backspace( FILE_IN ) !//退回到第三行
Do i = 1 , nRow
Read( FILE_IN , * ) r , a( : , i )
write( * , * ) a(:,i)
End Do
Deallocate( a )
Close( FILE_IN )
End Program www_fcode_cn