      program addeqhpout2
C..Add time UT of Mmax(EQ) EQ daily Mmax, Dkm, Mav, glat,glon set, for the day of Kpmax<3...........June 2022
C
      CHARACTER*64 infile,outfile,infileq
		CHARACTER*2 AMN,ADY,AUT,AMM
C
      outfile='addeqhpo0.txt'
         infile='addeqssn0.txt'
c-       infile='addeqkpssn0.txt' ! all SSN=0  1994-2020
	infileq='wules0hpojm.txt'  ! Apo>15nT SSN=0
C
	OPEN(10,file=infileq,action='READ')
	 OPEN(11,file=outfile)
 	OPEN(12,file=infile,action='READ')
C
	ndy=0
C
	DO 41 iev=1,533
	 read(10,*,end=51) xyear,klda,kmn,kdy,tkp,hpomax,iapo,twu,wumax,twl
     +,wlmin,twe,wemax,ndy1
     	kyear=int(xyear)
     
C
C    1	read(10,30,end=51) kyear,kmn,kdy,kut,kmm,sec,glat,glon,khei,eqm,kn
    1	read(12,32,end=55) ryear,ilda,imn,idy,aut,amm,glats,glons,kmds
 	+,aeqmax,eqav,kk,knum,nn
            iyear=int(ryear)
c	iyr=iyear-iyear/100*100
        if (iyear.lt.kyear) goto 1
      if ((kyear.eq.iyear).and.(ilda.eq.klda)) then   !>>>>>>>>>>>>>>>>>>>>>>
C
    2  ndy=ndy+1
C +logE - log10(Energy), J
C      aloge=(4.4+1.5*eqav)*kk
      aloge=4.4+1.5*aeqmax
	emax=10.**aloge
      call blet2(imn,AMN)
	call blet2(idy,ADY)
      write(*,33) ryear,ilda,amn,ady,aut,amm,glats,glons,kmds
	+,aeqmax,eqav,aloge,emax,kk,knum,ndy
	write(11,33) ryear,ilda,amn,ady,aut,amm,glats,glons,kmds
	+,aeqmax,eqav,aloge,emax,kk,knum,ndy
	                 else   !>>>>>>>>>>>>>>>>>
	if ((kyear.eq.iyear).and.(ilda.lt.klda)) then
	goto 1
	                 else
	goto 41
	  endif
	                 endif !>>>>>>>>>>>>>>>>>>>
C
   41 continue
   51 close(10)
   32 format(1X,F8.3,1X,I3,2(1X,I2),2(1X,A2),2(1X,F6.2),1X,I4,2(1X,F4.1)
     +,3(1X,I4))
   33 format(1X,F8.3,1X,I3,4(1X,A2),2(1X,F6.2),1X,I4,2(1X,F4.1),1X,F6.2
     +,1X,1PE10.4,3(1X,I4))
   55	close(unit=12)
	close(unit=11)
	pause ' '
	STOP
	END