
           Program raintotal
           Integer i,j,nx,ny
           Parameter(nx=80000,ny=2)
           Real day(nx),rain(nx),dmax(nx)
           Integer jday(nx),hr(nx),mn(nx),iyr(nx)
           Character*1 ff
           Character*55 infile,outfile,outfile2
           Character*55 outfile3,outfile6

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

           do ii=1,ny
           read(10,40)infile,outfile,outfile2,outfile3,
     *     outfile6
 40        format(a35,1x,a27,1x,a34,1xa34,1x,a34)

           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')

           total=0.
           rainmax=0.
           ikk=0
           raint=0.
           rtotal=0.
           revent=0.
           dmx=0.
           ff=':'

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

            
           r022=0.
           i022=0
           r054=0.
           i054=0.
           r063=0.
           i063=0
           r070=0.
           i070=0.
           r073=0.
           i073=0
           r089=0.
           i089=0

           k1=1
           do i=1,nx
           read(11,*,err=999,end=999)iyr(k1),jday(k1),hr(k1),mn(k1),
     *     top,con,wc,rain(k1),zz,dmass,dmax(k1)
           thr=float(hr(k1))+float(mn(k1))/60.
           day(k1)=float(jday(k1))+thr/24.
           rtotal=rtotal+rain(k1)/60.

c          022

           if(jday(k1).eq.22 .and. hr(k1).ge.21)r022=r022+rain(k1)/60.
           if(jday(k1).eq.22 .and. hr(k1).ge.21)i022=i022+1
           if(jday(k1).eq.23 .and. hr(k1).le.16)r022=r022+rain(k1)/60.
           if(jday(k1).eq.23 .and. hr(k1).le.16)i022=i022+1
           if(jday(k1).eq.23 .and. hr(k1).eq.17)then
c          if(mn(k1).lt.10)i022=i022+1
c          if(mn(k1).lt.10)r022=r022+rain(k1)/60.
           if(mn(k1).lt.15)i022=i022+1
           if(mn(k1).lt.15)r022=r022+rain(k1)/60.
           endif

c          054

           if(jday(k1).eq.54 .and. hr(k1).ge.1)r054=r054+rain(k1)/60.
           if(jday(k1).eq.54 .and. hr(k1).ge.1)i054=i054+1
           if(jday(k1).eq.54 .and. hr(k1).eq.0)then
c          if(mn(k1).ge.30)i054=i054+1
c          if(mn(k1).ge.30)r054=r054+rain(k1)/60.
           if(mn(k1).ge.34)i054=i054+1
           if(mn(k1).ge.34)r054=r054+rain(k1)/60.
           endif

c          063

           if(jday(k1).eq.63 .and. hr(k1).ge.7)r063=r063+rain(k1)/60.
           if(jday(k1).eq.63 .and. hr(k1).ge.7)i063=i063+1
           if(jday(k1).eq.63 .and. hr(k1).eq.6)then
           if(mn(k1).ge.5)i063=i063+1
           if(mn(k1).ge.5)r063=r063+rain(k1)/60.
c          if(mn(k1).ge.15)i063=i063+1
c          if(mn(k1).ge.15)r063=r063+rain(k1)/60.
           endif

c          070

c          if(jday(k1).eq.70 .and. hr(k1).le.5)r070=r070+rain(k1)/60.
c          if(jday(k1).eq.70 .and. hr(k1).le.5)i070=i070+1
c          if(jday(k1).eq.70 .and. hr(k1).eq.6)then
           if(jday(k1).eq.70 .and. hr(k1).le.11)r070=r070+rain(k1)/60.
           if(jday(k1).eq.70 .and. hr(k1).le.11)i070=i070+1
c          if(mn(k1).le.15)i070=i070+1
c          if(mn(k1).le.15)r070=r070+rain(k1)/60.
c          endif

c          073

           if(jday(k1).eq.72 .and. hr(k1).ge.17)r073=r073+rain(k1)/60.
           if(jday(k1).eq.72 .and. hr(k1).ge.17)i073=i073+1
           if(jday(k1).eq.73 .and. hr(k1).le.17)r073=r073+rain(k1)/60.
           if(jday(k1).eq.73 .and. hr(k1).le.17)i073=i073+1
           if(jday(k1).eq.73 .and. hr(k1).eq.18)then
           if(mn(k1).le.27)i073=i073+1
           if(mn(k1).le.27)r073=r073+rain(k1)/60.
c          if(mn(k1).le.41)i073=i073+1
c          if(mn(k1).le.41)r073=r073+rain(k1)/60.
           endif

c          089

           if(jday(k1).eq.89 .and. hr(k1).eq.5)then
c          if(mn(k1).le.15)i089=i089+1
c          if(mn(k1).le.15)r089=r089+rain(k1)/60.
           if(mn(k1).le.13)i089=i089+1
           if(mn(k1).le.13)r089=r089+rain(k1)/60.
           endif

           k1=k1+1
 999       enddo
           k1=k1-1

           print*,r022,i022
           print*,r054,i054
           print*,r063,i063
           print*,r070,i070
           print*,r073,i073
           print*,r089,i089

           print*,k1
           ik=1

           isave=iyr(1)
           jsave=jday(1)
           jhr=hr(1)
           jmn=mn(1)
           total=rain(1)/60.
           do i=2,k1
           tday=day(i-1)+timegap
           if(day(i) .le. tday .and. iyr(i).eq.iyr(i-1))then
           total=total + rain(i)/60.
           ik=ik+1
           if(rain(i).gt.rainmax)rainmax=rain(i)
           if(dmax(i).gt.dmx)dmx=dmax(i)
           if(i.eq.k1 .and.ik.ge.3 .and. total .ge.0.1)then
           write(20,22)isave,jsave,jhr,ff,jmn,jday(i),hr(i),ff,
     *     mn(i),ik,rainmax,total,dmx
           endif
           else
           if(ik.ge.3 .and. total.ge.0.1)then
           write(20,22)isave,jsave,jhr,ff,jmn,jday(i-1),hr(i-1),ff,
     *     mn(i-1),ik,rainmax,total,dmx
           ikk=ikk+ik
           revent=revent+1.
           raint=raint+total
 22        format(2i5,i5.2,a1,i2.2,i5,i5.2,a1,i2.2,i5,
     *     f8.1,f8.2,f8.3)
           endif
           rainmax=0.
           dmx=0.
           ik=1
           total=rain(i)/60.
           jsave=jday(i)
           isave=iyr(i)
           jhr=hr(i)
           jmn=mn(i)
           endif
           enddo

c          time gap 2 hours

           isave=iyr(1)
           jsave=jday(1)
           jhr=hr(1)
           jmn=mn(1)
           total=rain(1)/60.
           do i=2,k1
           tday=day(i-1)+timegap2
           if(day(i) .le. tday .and. iyr(i).eq.iyr(i-1))then
           total=total + rain(i)/60.
           ik=ik+1
           if(rain(i).gt.rainmax)rainmax=rain(i)
           if(dmax(i).gt.dmx)dmx=dmax(i)
           if(i.eq.k1 .and.ik.ge.3 .and. total .ge.2.0)then
           write(21,22)isave,jsave,jhr,ff,jmn,jday(i),hr(i),ff,
     *     mn(i),ik,rainmax,total,dmx
           endif
           else
           if(ik.ge.3 .and. total.ge.2.0)then
           write(21,22)isave,jsave,jhr,ff,jmn,jday(i-1),hr(i-1),ff,
     *     mn(i-1),ik,rainmax,total,dmx
           ikk=ikk+ik
           revent=revent+1.
           raint=raint+total
           endif
           rainmax=0.
           dmx=0.
           ik=1
           total=rain(i)/60.
           jsave=jday(i)
           isave=iyr(i)
           jhr=hr(i)
           jmn=mn(i)
           endif
           enddo

c          time gap 3 hours

           isave=iyr(1)
           jsave=jday(1)
           jhr=hr(1)
           jmn=mn(1)
           total=rain(1)/60.
           do i=2,k1
           tday=day(i-1)+timegap3
           if(day(i) .le. tday .and. iyr(i).eq.iyr(i-1))then
           total=total + rain(i)/60.
           ik=ik+1
           if(rain(i).gt.rainmax)rainmax=rain(i)
           if(dmax(i).gt.dmx)dmx=dmax(i)
           if(i.eq.k1 .and.ik.ge.3 .and. total .ge.2.0)then
           write(22,22)isave,jsave,jhr,ff,jmn,jday(i),hr(i),ff,
     *     mn(i),ik,rainmax,total,dmx
           endif
           else
           if(ik.ge.3 .and. total.ge.2.0)then
           write(22,22)isave,jsave,jhr,ff,jmn,jday(i-1),hr(i-1),ff,
     *     mn(i-1),ik,rainmax,total,dmx
           ikk=ikk+ik
           revent=revent+1.
           raint=raint+total
           endif
           rainmax=0.
           dmx=0.
           ik=1
           total=rain(i)/60.
           jsave=jday(i)
           isave=iyr(i)
           jhr=hr(i)
           jmn=mn(i)
           endif
           enddo
   
c          time gap 6 hours

           isave=iyr(1)
           jsave=jday(1)
           jhr=hr(1)
           jmn=mn(1)
           total=rain(1)/60.
           do i=2,k1
           tday=day(i-1)+timegap6
           if(day(i) .le. tday .and. iyr(i).eq.iyr(i-1))then
           total=total + rain(i)/60.
           ik=ik+1
           if(rain(i).gt.rainmax)rainmax=rain(i)
           if(dmax(i).gt.dmx)dmx=dmax(i)
           if(i.eq.k1 .and.ik.ge.3 .and. total .ge.2.0)then
           write(23,22)isave,jsave,jhr,ff,jmn,jday(i),hr(i),ff,
     *     mn(i),ik,rainmax,total,dmx
           endif
           else
           if(ik.ge.3 .and. total.ge.2.0)then
           write(23,22)isave,jsave,jhr,ff,jmn,jday(i-1),hr(i-1),ff,
     *     mn(i-1),ik,rainmax,total,dmx
           ikk=ikk+ik
           revent=revent+1.
           raint=raint+total
           endif
           rainmax=0.
           dmx=0.
           ik=1
           total=rain(i)/60.
           jsave=jday(i)
           isave=iyr(i)
           jhr=hr(i)
           jmn=mn(i)
           endif
           enddo

           enddo

           stop
           end
