C........................................................Dec.2020
C Count monthly % of Dst-index >-30 nT quiet
C 
C 
      PROGRAM cntzerodst
C
C----------------------------------------------------------------
C
	DIMENSION IM(12),icdst(12),icmon(12)
	+,ind24(0:23)	 ! 1h indices)
	CHARACTER*2 AYR,AMN
	CHARACTER*4 AYEAR
      CHARACTER*128 INFILE
	+,outfile  !
	CHARACTER(10) DD
      CHARACTER(10) TT
      CHARACTER(5) ZZ
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:/apkp/dst/dstYEAR' !Dst
C
	outfile='cntzerodst.txt' !total file for 1994-2020
	OPEN(10,FILE=OUTFILE)
C
C
   28 format(1X,F8.3,3(1X,I2),3(1X,F6.0))
   29 format(1X,F8.3,1X,I3,2(1X,I2),1X,I3,1X,F6.0,1X,I2,2(1X,F6.0))
C Yearly cycle
C
      DO 40 iyear=1994,2020
	call blet4(iyear,AYEAR)
      AYR=AYEAR(3:4)
	read(AYR,*) ryr
	iyr=int(ryr)
	if(int(ryr/4.)*4.eq.iyr) THEN 
 	im(2)=29
	ndyr=366
	                          ELSE
	im(2)=28
	ndyr=365
	ENDIF
	del=1./12.
C
   37 format(3X,2I2,1X,I2,10X,24(I4))	 ! Dst
C
	infile(16:19)=AYEAR
	open(15,file=infile,action='READ')
      do ii=1,12
	icmon(ii)=0  ! number of hours/month
      icdst(ii)=0
	enddo
C
       DO 41 lda=1,ndyr
C
	read(15,37,end=103) jyr,jmn,jdy,(ind24(ii),ii=0,23)
	icmon(jmn)=icmon(jmn)+24
	do k=0,23
	if (ind24(k).gt.-30) then
	icdst(jmn)=icdst(jmn)+1
	endif
	enddo
  41	CONTINUE
  103	close(unit=15)
C
C Output:
      do imn=1,12
	call blet2(imn,AMN)
       ryear=float(iyear)+del*float(imn-1)
      pdst=float(icdst(imn))/icmon(imn)*100.
	write(*,34) ryear,pdst
	write(10,34) ryear,pdst
	enddo 
   34 format(1X,F8.3,1X,F6.2)
  40	CONTINUE
   27 close(unit=10)
C
C
   35      write(*,*) infile
      pause ' ' 
      STOP
       END

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