[Fortran] 纯文本查看 复制代码
program ZWD_gamit
implicit none
integer :: stat,stat2,stat3,stat4,yr,dayofyear,hr
character :: filename_ztd*12,filename_zhd*12,filename_zwd*12,first*1
real :: time_all_ztd,time_all_zhd,ztd_m,zhd_mm,ztd_mm,zwd_mm
open(11,file="list.txt")
close(11,status="delete")
open(22,file="list2.txt")
close(22,status="delete")
call system('for %f in (*_all.ztd) do echo %f >> list.txt')
call system('for %f in (*_all.zhd) do echo %f >> list2.txt')
open (11,file="list.txt")
open (22,file="list2.txt")
stat=0
stat2=0
do while (stat==0 .and. stat2==0)
read (11,"(a12)",iostat=stat) filename_ztd
read (22,"(a12)",iostat=stat2) filename_zhd
if (stat/=0 .and. stat2/=0) exit
open (33,file=filename_ztd)
open (44,file=filename_zhd)
filename_zwd=filename_ztd(1:8)//".zwd"
open (55,file=filename_zwd)
stat3=0
do while (stat3==0)
read (33,50,iostat=stat3) time_all_ztd,ztd_m,yr,dayofyear,hr
50 format (f12.7,4x,f6.1,3x,i4,3x,i3.3,3x,i2.2)
if (stat3/=0) exit
stat4=0
do while (stat4==0)
read (44,100,iostat=stat4) time_all_zhd,zhd_mm
100 format (f12.7,4x,f6.1)
if (stat4/=0) exit
if (time_all_ztd==time_all_zhd) then
read (zhd_mm(1:1),"(a1)") first
if( first/="*") then
ztd_mm = ztd_m*1000D0
zwd_mm = ztd_mm - zhd_mm
write (55,150) time_all_ztd,zwd_mm,yr,dayofyear,hr
150 format (f12.7,3x,f12.7,3x,i4,3x,i3.3,3x,i2.2)
end if
end if
end do
rewind(44)
end do
close(33)
close(44)
close(55)
end do
close(11)
close(22)
end program