
           Program raintotal
           Integer i,j,nx,ny
           Parameter(nx=50000,ny=5)
           Real day(nx),rain(nx),dmax(nx)
           Integer jday(nx),hr(nx),mn(nx),iyr(nx)

           Character*1 ff
           Character*50 outfile,infile

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


           read(10,31)infile  
 31        format(a38)
           
           open(11,file=infile,status='unknown')


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

            
           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),dbz,dmass,dmax(k1)
           thr=float(hr(k1))+float(mn(k1))/60.
           day(k1)=float(jday(k1))+thr/24.
           rtotal=rtotal+rain(k1)/60.
           k1=k1+1
 999       enddo
           
           k1=k1-1

           do ii=1,ny
           read(10,33)outfile
 33        format(a34)

           open(21,file=outfile,status='unknown')

           if(ii.eq.1)timegap=60./(60.*24.)
           if(ii.eq.2)timegap=2.*60./(60.*24.)
           if(ii.eq.3)timegap=3.*60./(60.*24.)
           if(ii.eq.4)timegap=6.*60./(60.*24.)
           if(ii.eq.5)timegap=12.*60./(60.*24.)

           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)then
           total=total + rain(i)/60.
           ik=ik+1
           if(rain(i).gt.rainmax)rainmax=rain(i)
           if(dmax(i).gt.dmax0)dmax0=dmax(i)
           if(i.eq.k1 .and.ik.ge.2 .and. total.ge.1.)then
           write(21,22)isave,jsave,jhr,ff,jmn,jday(i),hr(i),ff,
     *     mn(i),ik,rainmax,total,dmax0
           endif
           else
           if(ii.eq.1)then
           if(ik.ge.2)then
           write(21,22)isave,jsave,jhr,ff,jmn,jday(i-1),hr(i-1),ff,
     *     mn(i-1),ik,rainmax,total,dmax0
           ikk=ikk+ik
           revent=revent+1.
           raint=raint+total
           endif
           else
           if(ik.ge.2 .and. total.ge.1)then
           write(21,22)isave,jsave,jhr,ff,jmn,jday(i-1),hr(i-1),ff,
     *     mn(i-1),ik,rainmax,total,dmax0
           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
           endif
           rainmax=0.
           dmax0=0.
           ik=1
           total=rain(i)/60.
           jsave=jday(i)
           isave=iyr(i)
           jhr=hr(i)
           jmn=mn(i)
           endif
           enddo

           enddo



           stop
           end
