
           Program raintotal
           Integer i,j,nx,ny
           Parameter(nx=800000,ny=8)
           Real timea(nx),rain(nx),timeb(nx)
           Integer jday(nx),kr(nx),mn(nx),iyr(nx)
           Integer kday(nx),ka(nx),ma(nx),kyr(nx)
           Character*1 ff
           Character*55 infile,outfile,outfile2
           Character*55 outfile00,outfile02
           Character*55 outfile03,outfile06
           Character*55 outfile3,outfile6

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

           do ii=1,ny
           read(10,40)infile,outfile,outfile00,outfile2,
     *     outfile02,outfile3,outfile03,outfile6,outfile06
 40        format(a12,1x,a28,1x,a28,6(1x,a31))

           open(11,file=infile,status='unknown')
           open(20,file=outfile,status='unknown')
           open(21,file=outfile2,status='unknown')
           open(22,file=outfile3,status='unknown')
           open(23,file=outfile6,status='unknown')
           open(24,file=outfile00,status='unknown')
           open(25,file=outfile02,status='unknown')
           open(26,file=outfile03,status='unknown')
           open(27,file=outfile06,status='unknown')

           total=0.
           ikk=0
           raint=0.
           rtotal=0.
           ff=':'

           timegap=60./(60.*24.)
           timegap2=60.*2./(60.*24.)
           timegap3=60.*3./(60.*24.)
           timegap6=60.*6./(60.*24.)

            

           k1=0
           k2=0
           do i=1,nx
           read(11,*,err=999,end=999)iyr0,jday0,kr0,mn0,
     *     isec0,tb01,tb02
           if(tb01.gt.0.)then
           k1=k1+1
           tmin=float(isec0)/60.+float(mn0)
           thr=float(kr0)+tmin/60.
           timea(k1)=float(jday0)+thr/24.
           rtotal=rtotal+0.254
           iyr(k1)=iyr0
           jday(k1)=jday0
           kr(k1)=kr0
           mn(k1)=mn0
           endif
           if(tb02.gt.0.)then
           k2=k2+1
           tmin=float(isec0)/60.+float(mn0)
           thr=float(kr0)+tmin/60.
           timeb(k2)=float(jday0)+thr/24.
           kyr(k2)=iyr0
           kday(k2)=jday0
           ka(k2)=kr0
           ma(k2)=mn0
           endif
 999       enddo


           print*,k1,k2

           ik=1

           isave=iyr(1)
           jsave=jday(1)
           jhr=kr(1)
           jmn=mn(1)
           total=0.254
           do i=2,k1
           tday=timea(i-1)+timegap
           if(timea(i) .le. tday .and. iyr(i).eq.iyr(i-1))then
           total=total + 0.254
           ik=ik+1
           if(i.eq.k1 .and.ik.ge.3 .and. total .ge.0.1)then
           write(20,22)isave,jsave,jhr,ff,jmn,jday(i),kr(i),ff,
     *     mn(i),ik,total
           endif
           else
           if(ik.ge.3 .and. total.ge.0.1)then
           write(20,22)isave,jsave,jhr,ff,jmn,jday(i-1),kr(i-1),ff,
     *     mn(i-1),ik,total
           ikk=ikk+ik
 22        format(2i5,i5.2,a1,i2.2,i5,i5.2,a1,i2.2,i5,f8.2)
           endif
           ik=1
           total=0.254
           jsave=jday(i)
           isave=iyr(i)
           jhr=kr(i)
           jmn=mn(i)
           endif
           enddo

           ik=1

           isave=kyr(1)
           jsave=kday(1)
           jhr=ka(1)
           jmn=ma(1)
           total=0.254
           do i=2,k2
           tday=timeb(i-1)+timegap
           if(timeb(i) .le. tday .and. iyr(i).eq.iyr(i-1))then
           total=total + 0.254
           ik=ik+1
           if(i.eq.k1 .and.ik.ge.3 .and. total .ge.0.1)then
           write(24,22)isave,jsave,jhr,ff,jmn,kday(i),ka(i),ff,
     *     ma(i),ik,total
           endif
           else
           if(ik.ge.3 .and. total.ge.0.1)then
           write(24,22)isave,jsave,jhr,ff,jmn,kday(i-1),ka(i-1),ff,
     *     ma(i-1),ik,total
           ikk=ikk+ik
           endif
           ik=1
           total=0.254
           jsave=kday(i)
           isave=kyr(i)
           jhr=ka(i)
           jmn=ma(i)
           endif
           enddo

c          time gap 2 hours

           ik=1

           isave=iyr(1)
           jsave=jday(1)
           jhr=kr(1)
           jmn=mn(1)
           total=0.254
           do i=2,k1
           tday=timea(i-1)+timegap2
           if(timea(i) .le. tday .and. iyr(i).eq.iyr(i-1))then
           total=total + 0.254
           ik=ik+1
           if(i.eq.k1 .and.ik.ge.3 .and. total .ge.1.0)then
           write(21,22)isave,jsave,jhr,ff,jmn,jday(i),kr(i),ff,
     *     mn(i),ik,total
           endif
           else
           if(ik.ge.3 .and. total.ge.1.0)then
           write(21,22)isave,jsave,jhr,ff,jmn,jday(i-1),kr(i-1),ff,
     *     mn(i-1),ik,total
           ikk=ikk+ik
           endif
           ik=1
           total=0.254
           jsave=jday(i)
           isave=iyr(i)
           jhr=kr(i)
           jmn=mn(i)
           endif
           enddo

           ik=1

           isave=kyr(1)
           jsave=kday(1)
           jhr=ka(1)
           jmn=ma(1)
           total=0.254
           do i=2,k2
           tday=timeb(i-1)+timegap2
           if(timeb(i) .le. tday .and. iyr(i).eq.iyr(i-1))then
           total=total + 0.254
           ik=ik+1
           if(i.eq.k1 .and.ik.ge.3 .and. total .ge.1.0)then
           write(25,22)isave,jsave,jhr,ff,jmn,kday(i),ka(i),ff,
     *     ma(i),ik,total
           endif
           else
           if(ik.ge.3 .and. total.ge.1.0)then
           write(25,22)isave,jsave,jhr,ff,jmn,kday(i-1),ka(i-1),ff,
     *     ma(i-1),ik,total
           ikk=ikk+ik
           endif
           ik=1
           total=0.254
           jsave=kday(i)
           isave=kyr(i)
           jhr=ka(i)
           jmn=ma(i)
           endif
           enddo

c          time gap 3 hours

           ik=1

           isave=iyr(1)
           jsave=jday(1)
           jhr=kr(1)
           jmn=mn(1)
           total=0.254
           do i=2,k1
           tday=timea(i-1)+timegap3
           if(timea(i) .le. tday .and. iyr(i).eq.iyr(i-1))then
           total=total + 0.254
           ik=ik+1
           if(i.eq.k1 .and.ik.ge.3 .and. total .ge.1.0)then
           write(22,22)isave,jsave,jhr,ff,jmn,jday(i),kr(i),ff,
     *     mn(i),ik,total
           endif
           else
           if(ik.ge.3 .and. total.ge.1.0)then
           write(22,22)isave,jsave,jhr,ff,jmn,jday(i-1),kr(i-1),ff,
     *     mn(i-1),ik,total
           ikk=ikk+ik
           endif
           ik=1
           total=0.254
           jsave=jday(i)
           isave=iyr(i)
           jhr=kr(i)
           jmn=mn(i)
           endif
           enddo
   
           ik=1

           isave=kyr(1)
           jsave=kday(1)
           jhr=ka(1)
           jmn=ma(1)
           total=0.254
           do i=2,k2
           tday=timeb(i-1)+timegap3
           if(timeb(i) .le. tday .and. iyr(i).eq.iyr(i-1))then
           total=total + 0.254
           ik=ik+1
           if(i.eq.k1 .and.ik.ge.3 .and. total .ge.1.0)then
           write(26,22)isave,jsave,jhr,ff,jmn,kday(i),ka(i),ff,
     *     ma(i),ik,total
           endif
           else
           if(ik.ge.3 .and. total.ge.1.0)then
           write(26,22)isave,jsave,jhr,ff,jmn,kday(i-1),ka(i-1),ff,
     *     ma(i-1),ik,total
           ikk=ikk+ik
           endif
           ik=1
           total=0.254
           jsave=kday(i)
           isave=kyr(i)
           jhr=ka(i)
           jmn=ma(i)
           endif
           enddo

c          time gap 6 hours

           ik=1

           isave=iyr(1)
           jsave=jday(1)
           jhr=kr(1)
           jmn=mn(1)
           total=0.254
           do i=2,k1
           tday=timea(i-1)+timegap6
           if(timea(i) .le. tday .and. iyr(i).eq.iyr(i-1))then
           total=total + 0.254
           ik=ik+1
           if(i.eq.k1 .and.ik.ge.3 .and. total .ge.1.0)then
           write(23,22)isave,jsave,jhr,ff,jmn,jday(i),kr(i),ff,
     *     mn(i),ik,total
           endif
           else
           if(ik.ge.3 .and. total.ge.1.0)then
           write(23,22)isave,jsave,jhr,ff,jmn,jday(i-1),kr(i-1),ff,
     *     mn(i-1),ik,total
           ikk=ikk+ik
           endif
           ik=1
           total=0.254
           jsave=jday(i)
           isave=iyr(i)
           jhr=kr(i)
           jmn=mn(i)
           endif
           enddo

           ik=1

           isave=kyr(1)
           jsave=kday(1)
           jhr=ka(1)
           jmn=ma(1)
           total=0.254
           do i=2,k2
           tday=timeb(i-1)+timegap6
           if(timeb(i) .le. tday .and. iyr(i).eq.iyr(i-1))then
           total=total + 0.254
           ik=ik+1
           if(i.eq.k1 .and.ik.ge.3 .and. total .ge.1.0)then
           write(27,22)isave,jsave,jhr,ff,jmn,kday(i),ka(i),ff,
     *     ma(i),ik,total
           endif
           else
           if(ik.ge.3 .and. total.ge.1.0)then
           write(27,22)isave,jsave,jhr,ff,jmn,kday(i-1),ka(i-1),ff,
     *     ma(i-1),ik,total
           ikk=ikk+ik
           endif
           ik=1
           total=0.254
           jsave=kday(i)
           isave=kyr(i)
           jhr=ka(i)
           jmn=ma(i)
           endif
           enddo

           enddo

           stop
           end
