[Fortran] 纯文本查看 复制代码 Program main
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.asc" )
nRow = GetFileN( FILE_IN ) - 2 !//获得文件行数
Read( FILE_IN , * ) !//跳过第一行
Read( FILE_IN , '(a512)' ) cStr!//读取第三行
nCol = GetDataN( cStr ) - 8 !//获得第三行有多少列
write( *, '("Row:",g0," Col: ",g0)' ) nRow , nCol
Allocate( a( nCol , nRow ) )
Backspace( FILE_IN ) !//退回到第三行
open( 11 , file ="tx1.txt")
write( 11 , * )" depth temp sal turb "
Do i = 1 , nRow
Read( FILE_IN , * ) r ,r, r, r, a( : , i )
write( 11 , * ) a(:,i)
End Do
Deallocate( a )
Close( FILE_IN )
End Program main |