[Fortran] 纯文本查看 复制代码
program ZWD_gamit
implicit none
integer :: stat,stat2,stat3,stat4,yr,dayofyear,hr
character :: filename_ztd*12,filename_zhd*12,filename_zwd*12
character :: c_time_all_ztd*12,c_time_all_zhd*12,c_zhd_mm*12
real*8 :: time_all_ztd,ztd_m,Tsr_deg,Ps_hpa,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) c_time_all_ztd,ztd_m,yr,dayofyear,hr
50 format (a12,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) c_time_all_zhd,c_zhd_mm,Tsr_deg,Ps_hpa
100 format (a12,3x,a12,3x,f6.1,3x,f6.1)
if (stat4/=0) exit
if (c_time_all_ztd==c_time_all_zhd) then
if( c_zhd_mm(1:1) /= "*") then
read (c_time_all_ztd,"(f12.7)") time_all_ztd
read (c_zhd_mm,"(f12.7)") zhd_mm
ztd_mm = ztd_m * 1D3
zwd_mm = ztd_mm - zhd_mm
write (55,150) time_all_ztd,zwd_mm,Tsr_deg,Ps_hpa,yr,dayofyear,hr
150 format (f12.7,3x,f12.7,3x,f6.1,3x,f6.1,3x,i4,3x,i3.3,3x,i2.2)
exit
end if
end if
end do
rewind(44)
end do
close(33)
close(44)
close(55)
end do
close(11)
close(22)
end program