      program extpeakmon
C
C............................................................Mar 2022
C Sort Catalogues Kp storms: WNT (mon=1,2,11,12),EQN(3,4,9,10),SMR(5,6,7,8)
C
      CHARACTER*64 infile,outwnt,outeqn,outsmr
      CHARACTER*1 kps
	 CHARACTER*13 txt1
	CHARACTER*62 txt2
	infile='catkpstx.res'
	outwnt='catkpwnx.txt'
	outeqn='catkpeqx.txt'
	outsmr='catkpsmx.txt'
   30 format(A13,1X,I2,A62,1X,I4)
	kps='1'
   1	continue
	infile(8:8)=kps
	outwnt(8:8)=kps
	outeqn(8:8)=kps
	outsmr(8:8)=kps
	OPEN(10,file=infile,action='READ')
	OPEN(11,file=outwnt)
	OPEN(12,file=outeqn)
	OPEN(13,file=outsmr)
	nwnt=0
	neqn=0
	nsmr=0
   2	read(10,30,end=51) txt1,imn,txt2,nn
	if ((imn.eq.1).or.(imn.eq.2).or.(imn.eq.11).or.(imn.eq.12)) then
	nwnt=nwnt+1
	write(*,30) txt1,imn,txt2,nwnt
	write(11,30) txt1,imn,txt2,nwnt
	endif
	if ((imn.eq.3).or.(imn.eq.4).or.(imn.eq.9).or.(imn.eq.10)) then
	neqn=neqn+1
	write(*,30) txt1,imn,txt2,neqn
	write(12,30) txt1,imn,txt2,neqn
	endif
	if ((imn.eq.5).or.(imn.eq.6).or.(imn.eq.7).or.(imn.eq.8)) then
	nsmr=nsmr+1
	write(*,30) txt1,imn,txt2,nsmr
	write(13,30) txt1,imn,txt2,nsmr
	endif
	goto 2
   51 close(10)
      close(11)
	close(12)
	close(13)
C
      if (kps.eq.'1') then
	kps='2'
	goto 1
	endif
	pause ' '
	STOP
	END
