65.93 KB, 下载次数: 5
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
85.87 KB, 下载次数: 5
Program www_fcode_cn
implicit none
character(len=512) :: c
character(len=1) :: s
integer :: FILE_IN , FILE_OUT , k , i
real :: DepSM
Open( NewUnit = FILE_IN , File = "text.asc" )
Open( NewUnit = FILE_OUT, File = "text.txt" )
Read( FILE_IN , 100 ) c
Write( FILE_OUT , 99 ) trim(c)
Do
Read( FILE_IN , 100 , ioStat = k ) c
if ( k /= 0 ) exit
Read( c , * ) i , i , i , s , DepSM
If ( DepSM > 0.0 ) then
Write( FILE_OUT , 99 ) trim(c)
End If
End Do
Close( FILE_IN )
Close( FILE_OUT )
100 format(a512)
99 format(a)
End Program www_fcode_cn
欢迎光临 Fortran Coder (http://bbs.fcode.cn/) | Powered by Discuz! X3.2 |