[Fortran] 纯文本查看 复制代码 Program www_fcode_cn
Implicit None
Integer , parameter :: N = 168
complex :: cmp(N) , ReadComplex
integer i
Open( 12 , File = "t.dat" )
Do i = 1 , N
cmp(i) = ReadComplex( 12 )
write( * , * ) cmp(i)
End Do
Close( 12 )
End Program www_fcode_cn
complex Function ReadComplex( u )
Integer , Intent( IN ) :: u
character( len = 64 ) :: cImag , cTemp
character( len = 1 ) :: cSign
real :: rReal , tImag , tSign
integer :: k
read( u , * ) rReal , cSign , cImag
tSign = 1.0
if ( cSign == '-' ) tSign = -1.0
cTemp = cImag
k = Len_Trim(cTemp)
cTemp(k:k) = ''
read( cTemp , * ) tImag
ReadComplex = cmplx(rReal , tSign * tImag )
End Function ReadComplex |