[Fortran] 纯文本查看 复制代码 Program main
Implicit None
Character (160) :: filename
Character (160) :: fn1, fn2, fn3, tmp
Integer :: i, j, num
Real :: a(4), b(4), c(4)
Integer ios
fn1 = 'c6c8_ID_'
fn2 = 'c6_'
fn3 = 'c8_'
num = 160 ! total number of result files
Print *, 'Running'
Do j = 1, num
Write (tmp, *) j
!c print*, j
Open (j, File='D:\c6c8\'//trim(adjustl(fn1))//trim(adjustl(tmp))//'.dat', Status='unknown') ! save result here
Write (j, '(3f8.3)') 0.0, 0.0, 1.0
End Do
Open (20, File='IDlist.dat', Status='old') ! 里面存放的是10的倍数,共计9200个。
Do i = 1, 9200
Read (20, *, Iostat=ios) filename
If (ios/=0) Exit
! print*, filename
Open (200, File='D:\C6\'//trim(adjustl(fn2))//trim(adjustl(filename))//'.dat')
Open (300, File='D:\C8\'//trim(adjustl(fn3))//trim(adjustl(filename))//'.dat')
Do j = 1, num
Read (200, *) a(:) ! first row=ID number, then x,y,z
Read (300, *) b(:) ! first row=ID number
c(:) = b(:) - a(:)
!c print*, c(:)
Write ( j , '(3f8.3)') c(2:4) ! write( j ,
End Do
Close (300)!// Close 在循环外面
Close (200)
End Do
Close (20)
Do j = 1, num
Close (j)
End Do
End Program main |