      program rewritehss5
C...................................................Feb 2020
C exclude kp <3 from Pch/Hss 183 events 
C
      CHARACTER*47 infile,outfile
C
	infile='hsspeak72s.txt'   ! Pch-HSS-cat
	outfile='catpchhss.txt'
	OPEN(10,file=infile,action='READ')
C	
	OPEN(11,file=outfile)
C
  138 format(1X,F8.3,1X,I3,2(1X,I2),1X,I3,1X,F6.0,1X,I2,2(1X,F6.0)
     +,5(1X,I3,1X,I4),1X,I3,1X,I5,1X,I3,1X,I4,3(1X,I3,1X,F5.1),1X,I4)

   30 FORMAT(A47)
C   31 FORMAT(A40)
   32 FORMAT(A47,1X,A8,1X,I2,3(1X,F7.3),1X,I4)
		icch=0
C
		DO 70 ii=1,183
 	read(10,*,end=40) ryear1,ldam,imn1,idy1,iutm,v1,iut2,v2,delv
 	+,iutkp,ikpmax,iutap,iapmax,iutaa,iaamax,iutae,iaemax
     +,iutau,iaumax,iutal,ialmin,iutds,idsmin,iutwp,wpmax
     +,iutwpn,wpnmin,iutwpp,wppmax,nout
	if (ikpmax.lt.30) goto 70
	icch=icch+1
 	write(*,138) ryear1,ldam,imn1,idy1,iutm,v1,iut2,v2,delv
	+,iutkp,ikpmax,iutap,iapmax,iutaa,iaamax,iutae,iaemax
     +,iutau,iaumax,iutal,ialmin,iutds,idsmin,iutwp,wpmax
     +,iutwpn,wpnmin,iutwpp,wppmax,icch
 	write(11,138) ryear1,ldam,imn1,idy1,iutm,v1,iut2,v2,delv
	+,iutkp,ikpmax,iutap,iapmax,iutaa,iaamax,iutae,iaemax
     +,iutau,iaumax,iutal,ialmin,iutds,idsmin,iutwp,wpmax
     +,iutwpn,wpnmin,iutwpp,wppmax,icch
C
   70 CONTINUE
   40	close(unit=11)
   41 close(unit=10)
	pause ' '
	STOP
	end


