[Fortran] 纯文本查看 复制代码 program fcode_cn
Implicit None
Real , allocatable :: rMatrix(:,:) , value(:)
Integer , allocatable :: ipodia(:) , indexJ(:)
Integer :: N , M , i , j
Open( 12 , File = "Ipodia.txt")
Open( 13 , File = "Index J.txt")
Open( 14 , File = "Value.txt")
N = GetFileN( 12 )
M = GetFileN( 13 )
Allocate( rMatrix(N,N) , ipodia(0:N) , indexJ(M) , value(M) )
rMatrix = 0
ipodia(0) = 0
Read(12,*) ipodia(1:)
Read(13,*) indexJ
Read(14,*) value
Do i = 1 , N
rMatrix( indexJ( ipodia(i-1)+1 : ipodia(i) ) , i ) = value( ipodia(i-1)+1 : ipodia(i) )
rMatrix( i , :i-1 ) = rMatrix( :i-1 , i )
End Do
Close(12)
Close(13)
Close(14)
contains
Integer Function GetFileN( iFileUnit )
Integer , Intent( IN ) :: iFileUnit
character( Len = 1 ) :: cDummy
integer :: ierr
GetFileN = 0
Rewind( iFileUnit )
Do
Read( iFileUnit , * , ioStat = ierr ) cDummy
If( ierr /= 0 ) Exit
GetFileN = GetFileN + 1
End Do
Rewind( iFileUnit )
End Function GetFileN
end program fcode_cn |