
         Program track

         Parameter(nx=15600000)
         Parameter(ns=80,nu=1)

         Integer ksave(nx),msave(nx)
         integer ipar(nx),irecs(ns+500)
         Real dsave(nx)
         character*60 infile,outfile,infile2
         Character*60 outfile2,outfile3

         Open(unit=10,file='filetrack2022',status='unknown')

         do ll=1,nu
         read(10,30)na,infile
 30      format(i3,1x,a15,1x,a25,1x,a29,1x,a31)

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

        
         do i=1,na
         read(11,32)infile2,outfile
 32      format(a35,1x,a47)

         open(unit=12,file=infile2,status='unknown')
         open(unit=20,file=outfile,status='unknown')

         do k=1,5
         read(12,*)
         enddo
         read(12,*)iyear,mon,iday,ka
         do k=1,3
         read(12,*)
         enddo

         if(mon.eq.10)jday=iday+273
         if(mon.eq.11)jday=iday+304
         if(mon.eq.12)jday=iday+334
         if(mon.eq.1)jday=iday
         if(mon.eq.2)jday=iday+31
         if(mon.eq.3)jday=iday+59
         if(mon.eq.4)jday=iday+90


         k1=1
         k2=0
         do kk=1,nx
         read(12,*,err=999,end=999)irec,ipar(k1),krq,dmm, 
     *   kgrey,wc,wd,ma
         if(kk.eq.1)then
         do ky=1,ns
         irecs(ky)=0
         enddo
         dave=dmm
         isay=1
         irecs(1)=irec
         mb=ma
         endif
         if(kk.gt.1 .and. ipar(k1).eq.ipar(k1-1))then
         isay=isay+1
         irecs(isay)=irec
         dave=dave+dmm
         mb=ma
         else
         dave=dave/float(isay)
         if(k1.gt.1)then
         write(20,39,err=999)ipar(k1-1),iyear,jday,ka,mb,dave,
     *   isay,(irecs(ky),ky=1,ns)
         k2=k2+1
         ksave(k2)=ka
         msave(k2)=mb
         dsave(k2)=dmm+0.001
         do ky=1,ns
         irecs(ky)=0
         enddo
         endif
         isay=1
         irecs(isay)=irec
         dave=dmm
         mb=ma
         endif
         k1=k1+1
 39      format(i10,4i5,f10.2,i3,80i8)
c        backspace(12)
 999     enddo
     
         k1=k1-1

         print*,k1,ll,i

         enddo

         enddo

         stop
         end
