[Fortran] 纯文本查看 复制代码
program baseline
implicit none
integer :: stat,k,stat2,m,stat3,stat4
character :: filename_1*13,gps1*4,filename_2*13,gps2*4,filename_new*13
real*8 :: x1,y1,z1,x2,y2,z2,dis,time_all_1,time_all_2
open (11,file='list.txt')
close (11,status='delete')
open (22,file='list2.txt')
close (22,status='delete')
call system ('for %f in (ts_*_b.dat) do echo %f >> list.txt')
call system ('for %f in (ts_*_b.dat) do echo %f >> list2.txt')
open (11,file='list.txt')
open (22,file='list2.txt')
stat=0
k=0
do while (stat==0)
read (11,'(a13)',iostat=stat) filename_1
read (filename_1(4:7),'(a4)') gps1
if (stat/=0) exit
k=k+1
stat2=0
m=0
do while (stat2==0)
m=m+1
read (22,'(a13)',iostat=stat2) filename_2
read (filename_2(4:7),'(a4)') gps2
if (stat2/=0) exit
if (gps1 /= gps2 .and. k < m) then
filename_new = gps1//'_'//gps2//'.dat'
open (33,file=filename_1)
open (44,file=filename_2)
open (55,file=filename_new)
stat3=0
do while(stat3==0)
read (33,50,iostat=stat3) time_all_1,x1,y1,z1
50 format (f10.5,2x,f13.4,11x,f12.4,11x,f12.4)
if (stat3/=0) exit
stat4=0
do while (stat4==0)
read (44,100,iostat=stat4) time_all_2,x2,y2,z2
100 format (f10.5,2x,f13.4,11x,f12.4,11x,f12.4)
if (stat4/=0) exit
if ( DABS (time_all_1 - time_all_2 ) < 0.00001D0 ) then
dis = DSQRT ( (x1*1D0-x2*1D0)**2+(y1*1D0-y2*1D0)**2+(z1*1D0-z2*1D0)**2 )
write (55,'(f10.5,3x,f12.7)') time_all_1,dis
end if
exit
end do
rewind(44)
end do
end if
close(33)
close(44)
close(55)
end do
rewind(22)
end do
close(11)
close(22)
end program