
         Program readaio

         Parameter(nx=344700,nn=4,na=14)

         Real den(nx),eden(nx),rr(nx),xrr(nx)

         Integer jyr(nx),kday(nx),ka(nx),ma(nx)
         Integer kyr(nx),js(nx),ks(nx),ms(nx)
         Integer imrr(nx),ipip(nx,nn)
         Integer kpip(nn)
 
         Character*60 infile,outfile,outfile2
         Character*60 infile0,outfile01,infile01
         Character*60 eksi,infile1

         open(10,file='filedopplervelevent',status='unknown')

         read(10,32)infile,infile0
 32      format(a26,1x,a40)


         open(11,file=infile,status='unknown')
         open(12,file=infile0,status='unknown')


         k2=1
         do i=1,nx
         read(12,*,err=998,end=998)jyr(k2),kday(k2),ka(k2),
     *   ma(k2),tt,wbt,imrr(k2),(ipip(k2,k),k=1,nn)
         k2=k2+1
 998     enddo
         k2=k2-1
        
         print*,k2
         

         do i=1,na
         read(11,20)infile01,outfile01
 20      format(a38,41x,a42)

         open(14,file=infile01,status='unknown')
         open(20,file=outfile01,status='unknown')

         k1=1
         k0=0
         m0=0
         do kk=1,nx
         read(14,*,err=999,end=999)iyr,jday,kr,
     *   mn,wd,ws,tc,wetb,rh,pres,
     *   iphase,prob,probnew,kphase
         kmrr=-99
         do kl=1,nn
         kpip(kl)=-99
         enddo
         m0=m0+1
         do k=1,k2
         if(iyr.eq.jyr(k) .and. jday.eq.kday(k) .and.
     *   kr.eq.ka(k) .and. mn.eq.ma(k))then
         k0=k0+1
         kmrr=imrr(k)
         do kl=1,nn
         kpip(kl)=ipip(k,kl)
         enddo
         endif
         enddo
         write(20,22,err=999)iyr,jday,kr,
     *   mn,wd,ws,tc,wetb,rh,pres,
     *   iphase,prob,probnew,kphase,
     *   kmrr,(kpip(kl),kl=1,nn)
 22      format(4i5,f10.0,5f10.3,i5,2f10.3,i5,
     *   4i5)
         k1=k1+1
 999     enddo
         k1=k1-1

         print*,k1,k0,m0

         enddo


         stop
         end
