      program addeuv3kp0jm
C..Add EUVa; EUVb daily for the day of Kpmax.............................................May 2022
C
      CHARACTER*64 infile,outfile,infileq
C	DIMENSION hp(0:23),kap(0:23)
C
      outfile='addeuvkp3jm.txt'
	infile='wulessw0kp3jm.txt'
	infileq='extEUVssn0.txt'
C
       OPEN(10,file=infile,action='READ')
       OPEN(11,file=outfile,access='APPEND')
C--	OPEN(12,file=infileq,action='READ')
   30 format(1X,F8.3,1X,I3,3(1X,I2),1X,F4.1,4(1X,I3,1X,F6.2),1X,I3
     +,1X,F6.1,1X,I3,1X,I4)
   33 format(1X,I4,1X,F8.3,2(1X,I2),2(2X,1PE12.6))
   31 format(I4,A64)
C
	ndy=0
C
	DO 41 iev=1,563
    	read(10,30,end=50) ryear,lda,imn,idy,itkp,xkpmax,jtwu,wumax
     +,jtwl,wlmin,jtwe,wemax,jtwp,wpmax,jtsw,swmax,isumkp,nn
CTEMP:
       ndy=nn-1
      if (nn.le.125) goto 41 !Temp
C
      iyear=int(ryear)
C
	OPEN(12,file=infileq,action='READ')
   1	read(12,33,end=55) nd,xyear,kmn,kdy,euva,euvb
C
       kyear=int(xyear)
	if ((iyear.eq.kyear).and.(imn.eq.kmn).and.(idy.eq.kdy)) then
	goto 55
	                  else
	goto 1
	                   endif
C
   55	close(12)
C Output
    2  ndy=ndy+1
      write(*,32) ryear,lda,imn,idy,euva,euvb,ndy
	write(11,32) ryear,lda,imn,idy,euva,euvb,ndy
C
   41 continue
   32 format(1X,F8.3,1X,I3,2(1X,I2),2(2X,1PE12.6),1X,I4)
   50	close(unit=10)
	close(unit=11)
	pause ' '
	STOP
	END