      program readwulekp
C.........................................................Aug. 2021
C Arbitrary dates 3h WU,WL,WE
	DIMENSION IM(12),wneg(0:7),wpos(0:7),wran(0:7),xkp(0:7)
	CHARACTER*2 AYR,AMN,ADY
	CHARACTER*64 infile,infilekp,outfile,txt 
		CHARACTER*4 AYEAR
            DATA IM/31,28,31,30,31,30,31,31,30,31,30,31/

      infile='d:\web\graf\datw\qtcYR.txt'   ! 3hUT WU,WL,We
	infilekp='d:\Apkp\kpap\kpYEAR'
      outfile='d:\web\graf\datw\wuleYRkp3.txt' 
	WRITE(*,*)' ENTER AYEAR OF INPUT FILE=	'
	read(*,*) AYEAR
	AYR=AYEAR(3:4)
	read(AYR,*) ryr
	IYR=int(ryr)   ! current yr
	z1=iyr/4.0
      jz=int(z1)*4

      IF(jz.EQ.iyr) THEN
               IM(2)=29
	dnr=366.
        ELSE
                IM(2)=28
	  	dnr=365.
	       ENDIF
	infile(21:22)=ayr
	infilekp(16:19)=Ayear
	outfile(22:23)=AYR
	OPEN(12,file=outfile,access='APPEND')
C
   1      WRITE(*,*)' ENTER AMN OF INPUT FILE=	'
	read(*,*) AMN
	read(AMN,*) rmn
	if (rmn.eq.0.) GOTO 2
	IMN=int(rmn)   ! current mn
	mndy=im(imn)
C
      WRITE(*,*)' ENTER IDY1, IDY2=	'
	read(*,*) idy1,idy2
      lda1=ndoy(iyr,imn,idy1)
	lda2=ndoy(iyr,imn,idy2)
   31 format(3A2,6X,8(F2.1))
   32 format(3A2,8(1X,F4.2),8(1X,F5.2),8(1X,F4.2))
   33 format(3A2,1X,I2,3(1X,F6.2),2X,F3.1)
C  Day-to-day cycle
C
C++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       idy=idy1-1
      DO 52 lda=lda1,lda2
	idy=idy+1
	call blet2(idy,ADY)
	OPEN(10,file=infile,action='READ')
	read(10,*) txt ! title line
	OPEN(11,file=infilekp,action='READ')
	do jj=1,lda
      read(10,32) AYR,AMN,ADY,(wpos(k),k=0,7),(wneg(k),k=0,7)
	+,(wran(k),k=0,7)
      read(11,31) AYR,AMN,ADY,(xkp(k),k=0,7)
	enddo
      close(unit=10)
	close(unit=11)
C
C Output:
C
	do kk=0,7
	kut=kk*3
	write(*,33) AYR,AMN,ADY,kut,wpos(kk),wneg(kk),wran(kk),xkp(kk)
	write(12,33) AYR,AMN,ADY,kut,wpos(kk),wneg(kk),wran(kk),xkp(kk)
	enddo
   52 CONTINUE
	GOTO 1
    2      close(unit=12)
	pause ' '
	STOP
	END