C........................................................Feb.2021
C Cnt Annual Occurrence of 3h WU, WL, WE indices 1994-2020
C 
C 
      PROGRAM cntqeqyr
C
C----------------------------------------------------------------
C
	DIMENSION kuq(12),klq(12),keq(12),imon(12),IM(12)
	+,iqu(0:7),iql(0:7),iqe(0:7)
C
	CHARACTER*2 AYR
	CHARACTER*4 AYEAR
      CHARACTER*128 INFILE,outfilkp,txt
	CHARACTER(10) DD
      CHARACTER(10) TT
      CHARACTER(5) ZZ
      DATA IM/31,28,31,30,31,30,31,31,30,31,30,31/
C++
C
      ICALLS=0
	CALL DATE_AND_TIME(DATE=DD,TIME=TT,ZONE=ZZ)
      TT(5:)='      '
      WRITE(*,*) 'PC Date: Year,Month,Day = ',DD,'Time = ',TT
C
	infile='d:/web/graf/datw/qtcYR.txt' !QU,QL,QE
C
	outfilkp='cntqeqyr.txt' ! annual number of 3h WU<2.0, WL>-2.2, WU <4.3 %
	OPEN(11,FILE=OUTFILKP)
C
C
   28 format(3I2,8(1X,I4),8(1X,I5),8(1X,I4))
C Cycle on year ====================================================
C
	DO 177 iyear=1994,2020
       call blet4(iyear,AYEAR)
	ryear=float(iyear)
	iyr=iyear-iyear/100*100
	call blet2(iyr,AYR)
	infile(21:22)=AYR
	open(15,file=infile,action='READ')
	read(15,*) txt  ! title
c
 	z1=iyear/4.0
      jz=int(z1)*4

      IF(jz.EQ.iyear) THEN
               IM(2)=29
	ndnyr=366
        ELSE
                IM(2)=28
	  ndnyr=365
	       ENDIF
C=	dev=1./12.
 	do k=1,12
	imon(k)=0
	kuq(k)=0
      klq(k)=0
      keq(k)=0
	enddo
C
C
      icnyru=0    
	icnyrl=0    
	icnyre=0    
	DO 101 k=1,ndnyr
C-	
C	read(15,137,end=102) jyear,jmn,jdy,jut,jkp,jap,jaa
	read(15,28,end=102) jyr,jmn,jdy,(iqu(k),k=0,7),(iql(k),k=0,7)
	+,(iqe(k),k=0,7)
	imon(jmn)=imon(jmn)+8
	  do i=0,7
	if (iqu(i).lt.220) then
	kuq(jmn)=kuq(jmn)+1
	icnyru=icnyru+1
	endif
	if (iql(i).gt.-220) then
	klq(jmn)=klq(jmn)+1
	icnyrl=icnyrl+1
	endif
	if (iqe(i).lt.430) then
	keq(jmn)=keq(jmn)+1
	icnyre=icnyre+1
	endif
	  enddo
  101	CONTINUE
  102	close(unit=15)
C
       hrs3yr=ndnyr*8.0
C=        do imn=1,12
C=	call blet2(imn,AMN)
C=      pqu=float(kuq(imn))/imon(imn)*100.
      pqu=100.0-float(icnyru)/hrs3yr*100.
C=	pql=float(klq(imn))/imon(imn)*100.
      pql=100.0-float(icnyrl)/hrs3yr*100.
C=	pqe=float(keq(imn))/imon(imn)*100.
      pqe=100.0-float(icnyre)/hrs3yr*100.
C=	xyear=ryear+dev*(imn-1.)
      xyear=ryear+0.5
  138 format(1X,F7.1,3(1X,F7.2))
C Output matrices:
 	write(*,138) xyear,pqu,pql,pqe
	write(11,138) xyear,pqu,pql,pqe
C=	enddo
  177	CONTINUE
   27 close(unit=11)
C
C
   35      write(*,*) infile
      pause ' ' 
      STOP
       END

C***********************************************************
