      program kpssn0
C..Kp 3h indices....at SSN =0.................................Aug 2022
C
C rate-of-change daily for SSN=0,
C 
C
      CHARACTER*64 infile,outfile
	DIMENSION xkp(0:7),kp(0:7)
C
c      infile='exaphs0.txt'
	infile='kpssn0.txt'
	outfile='kpssn0.res'
C
       OPEN(10,file=infile,action='READ')
       OPEN(14,file=outfile,access='APPEND')
C
   29 format(1X,F8.3,1X,I3,2(1X,I2),2(1X,F4.1),1X,F6.2,1X,I4)
   30 format(1X,I4,1X,3I2,8(1X,I3))
   31 format(I4,A64)
   32 format(I4,2(1X,I2),1X,I2,32X,F7.3,1X,F4.0)
   33 format(3I2,24(1X,F4.2))
C
C
	ndy=0	!norm
C+	ndy=432 !TEMPPPPPPPPPPPPP
C+	ndy=598 !TEMPPPPPPPPPPPPP
C+	ndy=756 !TEMPPPPPPPPPPPPP
C+	ndy=908 !TEMPPPPPPPPPPPPP
C+	ndy=1055 !TEMPPPPPPPPPPPPP
C+	ndy=1168 !TEMPPPPPPPPPPPPP
C+	ndy=1262 !TEMPPPPPPPPPPPPP
C+	ndy=1354 !TEMPPPPPPPPPPPPP
C+	ndy=1444 !TEMPPPPPPPPPPPPP
c+	ndy=1533 !TEMPPPPPPPPPPPPP
c+	ndy=1621 !TEMPPPPPPPPPPPPP
C+	ndy=1708 !TEMPPPPPPPPPPPPP
C+	ndy=1794 !TEMPPPPPPPPPPPPP
C+	ndy=1879 !TEMPPPPPPPPPPPPP
	ndy=1962 !TEMPPPPPPPPPPPPP
C
      lda_out=0
C
C SSN=0 Kp>=3 events
        DO 41 iev=1,3082  ! Events
C 
C
C_Apo    	read(10,*,end=50) ryear,lda,imn,idy,thpo,hpomax,iapo,nn
  101	read(10,30,end=59) nn,iyr,imn,idy,kp
CTEMPPPPPPPPPPP
C+       if (nn.le.1512) GOTO 41
C+       if (nn.le.1678) GOTO 41
C+       if (nn.le.1836) GOTO 41
C+       if (nn.le.1988) GOTO 41
C+       if (nn.le.2135) GOTO 41
C+       if (nn.le.2248) GOTO 41
C+       if (nn.le.2342) GOTO 41
C+       if (nn.le.2434) GOTO 41
C+       if (nn.le.2524) GOTO 41
C+       if (nn.le.2613) GOTO 41
C+       if (nn.le.2701) GOTO 41
C+       if (nn.le.2788) GOTO 41
C+       if (nn.le.2874) GOTO 41
C+       if (nn.le.2969) GOTO 41
C+       if (nn.le.3042) GOTO 41
	if (iyr.lt.30) then
	iyear=2000+iyr
	           else
	iyear=1900+iyr
	endif
		z1=iyear/4.0
      jz=int(z1)*4
      IF(jz.EQ.iyear) THEN
	dnr=366.
		  ELSE
                dnr=365.
		       ENDIF
	del=1./dnr
      lda=ndoy(iyr,imn,idy)
        ryear=iyear+(lda-1)*del
C
C Kpmax, Rkp
	xkp(0)=kp(0)/10.
      akpmax=xkp(0)
	itkp3=0
       skp2=0.
	skpav=0.
              DO j=1,7
	if (akpmax.lt.xkp(j)) then
	akpmax=xkp(j)
	itkp3=j*3
	endif
	dkp=(xkp(j)-xkp(j-1))/3.0
	skp2=skp2+dkp*dkp
	skpav=skpav+dkp
	           enddo
	rkp=sqrt(skp2/7.-(skpav/7.)**2)
	tkp3=itkp3+1.5
C
C Output Kp-3h results
        write(*,29) ryear,lda,imn,idy,tkp3,akpmax,rkp,nn
      write(14,29) ryear,lda,imn,idy,tkp3,akpmax,rkp,nn

   41 continue
   59	close(10)
C
   50	close(unit=14)
	pause ' '
	STOP
	END