	program histwtec234
c .......................................................Mar 2021
C Histogram of annual occurrence WTEC = +-2, +-3, +-4
C for 1994-2020
C
c
	DIMENSION icn(6),ind(0:71),IM(12),per(6) !
      CHARACTER*4 AYEAR
	CHARACTER*64 infile,outfile
	CHARACTER*2 AYR,AMN,ADY,AUT
      DATA IM/31,28,31,30,31,30,31,31,30,31,30,31/
C
C
		  outfile='histwtec2-3-4.res'
	OPEN(11,FILE=OUTFILE,ACCESS='APPEND')
C
	infile='d:\web\graf\dwc\YR\MN\ut\wcMNDDUT.jYR'				! Wtec
C
   36	format(72(1X,I4))

C	+++++++++++++++++++++++++++++++++
C+
c       
       DO	55 iyear=1994,2020
C-       iyear=2019
       call blet4(iyear,AYEAR)
	AYR=AYEAR(3:4)
	ryear=float(iyear)
	infile(17:18)=AYR
	infile(36:37)=AYR
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
	icnpos=0
	icnneg=0
	do i=1,6
	icn(i)=0
	enddo
C  ===================================
      DO 54 imn=1,12
	call blet2(imn, AMN)
	infile(20:21)=AMN
	infile(28:29)=AMN
	ndmn=im(imn)
C
      DO 53 idy=1,ndmn
	call blet2(idy,ADY)
	infile(30:31)=ADY 

C	read(10,*) txt ! title line
C
	DO 52 iut=0,23
	call blet2(iut,AUT)
	infile(32:33)=AUT 
C
		OPEN(10,FILE=infile,ACTION='READ')
C+	write(*,*) infile
	DO ilat=1,71
C
   	read(10,36,end=155) (ind(k),k=0,71)
C
	DO 51 ii=0,71
	if (ind(ii).lt.-1) then
	icnneg=icnneg+1
	if (ind(ii).eq.-2) icn(1)=icn(1)+1
	if (ind(ii).eq.-3) icn(2)=icn(2)+1
	if (ind(ii).eq.-4) icn(3)=icn(3)+1
	goto 51
	endif
C
	if (ind(ii).gt.1) then
	icnpos=icnpos+1
	if (ind(ii).eq.2) icn(4)=icn(4)+1
	if (ind(ii).eq.3) icn(5)=icn(5)+1
	if (ind(ii).eq.4) icn(6)=icn(6)+1
	goto 51
	endif
   51 CONTINUE
         ENDDO
 155  CLOSE(unit=10)
   52	CONTINUE      
C
   53	CONTINUE      
   54	CONTINUE !===========================     
      do i=1,3
	per(i)=float(icn(i))/icnneg*100.
	enddo
      do i=4,6
	per(i)=float(icn(i))/icnpos*100.
	enddo

       write(*,37) ayear,icnneg,icnpos,(per(k),k=1,6)
	write(11,37) ayear,icnneg,icnpos,(per(k),k=1,6)
   55	CONTINUE !===========================     
C
   37	format(1X,A4,2(1X,I8),6(1X,F6.2))
C  %
c   
	CLOSE(unit=11)
	goto 900
    2 CONTINUE
           write(*,*) 'INPUT FILE IS NOT IN YOUR DIRECTORY '
  900 pause ' '
      STOP
      END

