      program lagapotauapo
C...........................................................June 2023
C
	CHARACTER*128 INFHSS,INFILE,OUTFILE
	CHARACTER*20 start
	CHARACTER*2 AMN,ADY,AUT
	CHARACTER*4 AYEAR
	CHARACTER*3 ALDA
C
       infhss='Apostorm12.txt'
	infile='catapotaust12.txt'
C	outfile='catapotau12.txt'
	outfile='catapotau12s.txt'
	OPEN(11,file=infhss,action='READ')
      OPEN(12,file=infile,action='READ')
	OPEN(10,file=outfile)
   28 format(A20,1X,I4,3(1X,I2),1X,F5.0)
   29 format(1X,3I2,1X,I2,1X,F7.2)
      natau=0
C
	DO 177 iev=1,231
      read(11,28,end=127) start,iyear,imn1,idy1,iut1,apo
	read(12,29,end=128) iyr2,imn2,idy2,iut2,apotau
	iyr1=iyear-iyear/100*100
	lda1=ndoy(iyr1,imn1,idy1)
	lda2=ndoy(iyr2,imn2,idy2)
	call blet4(iyear,AYEAR)
	call blet2(imn2,AMN)
	call blet2(idy2,ADY)
	call blet2(iut2,AUT)
	call blet3(lda2,ALDA)
C
C Prepare lag (t2-t1)
C
        lagt=iut2-iut1
       if (lda1.eq.lda2) then
	 GOTO 23
	endif
C
	if (lda2.gt.lda1) then
	 lagt=iut2+24-iut1
	else
	lagt=iut2-24-iut1
	                 endif
C
  23	if (apotau.ge.100.) then
	natau=natau+1
      write(*,32) ayear,alda,amn,ady,aut,apotau,lagt,natau
	write(10,32) ayear,alda,amn,ady,aut,apotau,lagt,natau
	endif
  177	CONTINUE
  127 close(11)
  128 close(12)
      close(10)
  32	FORMAT(1X,A4,1X,A3,3(1X,A2),1X,F7.2,2(1X,I3))
       pause ' '
	STOP
	END