
             Program rainsnow

             Parameter(nx=300000)

             Integer iyrain(nx),jdrain(nx),khrain(nx)
             Integer mnrain(nx)

             Integer iysnow(nx),jdsnow(nx),khsnow(nx)
             Integer mnsnow(nx)

             Character*80 infile,infile0,outfile

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

             read(10,22)infile,infile0,outfile
 22          format(a26,1x,a31,1x,a27)

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

             k1=1
             do i=1,nx
             read(11,*,err=999,end=999)iyrain(k1),
     *       jdrain(k1),khrain(k1),mnrain(k1)
             k1=k1+1
 999         enddo
             k1=k1-1

             k2=1
             do i=1,nx
             read(12,*,err=998,end=998)iysnow(k2),
     *       jdsnow(k2),khsnow(k2),mnsnow(k2)
             do ii=1,7
             read(12,*)
             enddo
             k2=k2+1
 998         enddo
             k2=k2-1

             print*,k1,k2

             kyr=2021
             jd=335
             do k=1,31
             ka=0
             do kk=1,24
             ma=0
             do kl=1,60
             is=0
             do i=1,k1
             if(iyrain(i).eq.kyr .and.
     *       jdrain(i).eq.jd .and. khrain(i).eq.ka
     *       .and. mnrain(i).eq.ma)is=1
             enddo
             do i=1,k2
             if(iysnow(i).eq.kyr .and.
     *       jdsnow(i).eq.jd .and. khsnow(i).eq.ka
     *       .and. mnsnow(i).eq.ma)is=1
             enddo
             if(is.eq.1)then
             write(20,40)kyr,jd,ka,ma
 40          format(4i5)
             endif
             ma=ma+1
             enddo
             ka=ka+1
             enddo
             jd=jd+1
             enddo

             kyr=2022
             jd=1
             do k=1,120
             ka=0
             do kk=1,24
             ma=0
             do kl=1,60
             is=0
             do i=1,k1
             if(iyrain(i).eq.kyr .and.
     *       jdrain(i).eq.jd .and. khrain(i).eq.ka
     *       .and. mnrain(i).eq.ma)is=1
             enddo
             do i=1,k2
             if(iysnow(i).eq.kyr .and.
     *       jdsnow(i).eq.jd .and. khsnow(i).eq.ka
     *       .and. mnsnow(i).eq.ma)is=1
             enddo
             if(is.eq.1)then
             write(20,40)kyr,jd,ka,ma
             endif
             ma=ma+1
             enddo
             ka=ka+1
             enddo
             jd=jd+1
             enddo

             stop

             end

              

             
