      program effpchthr
C..............................................................................Nov. 2019
C
C..............................................................................Oct 2019
C Effective Pch events
C
C      dimension del(348),isw(348),iae(348),iaa(348),iap(348)
C	+,iwp(348),idst(348)
	CHARACTER*65 infile,outfile,txt
		CHARACTER*4 word
C	infile='extpchcat4.txt'
	infile='catpch2thr.res'
	OPEN(10,FILE=infile,action='READ')
	read(10,*) txt !extra line
	outfile='effpchthr.res'
	OPEN(11,FILE=OUTFILE,access='APPEND')
C
 	itsw0=563
 	itsw1=600
	itsw2=654
	tdpc0=230.
	tdpc1=251.
	tdpc2=294.
      itae0=777
      itae1=963
	itae2=1274
	itaa0=58
	itaa1=83
	itaa2=133
	itap0=30
	itap1=49
	itap2=96
	twp0=4.5
	twp1=5.2
	twp2=6.4
	ids0=-30
	ids1=-50
	ids2=-100
	iarn0=198
	iarn1=285
	iarn2=468
	iarp0=289
	iarp1=330
	iarp2=394
	iann0=277
	iann1=368
	iann2=542
	ianp0=336
	ianp1=399
	ianp2=502
C
	i0dpc=0
      i1dpc=0
	i2dpc=0
	i3dpc=0
	i0sw=0
      i1sw=0
	i2sw=0
	i3sw=0
	i0ae=0
      i1ae=0
	i2ae=0
	i3ae=0
	i0aa=0
      i1aa=0
	i2aa=0
	i3aa=0
	i0ap=0
      i1ap=0
	i2ap=0
	i3ap=0
	i0wp=0
      i1wp=0
	i2wp=0
	i3wp=0
	i0ds=0
      i1ds=0
	i2ds=0
	i3ds=0
	i0arn=0
      i1arn=0
	i2arn=0
	i3arn=0
	i0arp=0
      i1arp=0
	i2arp=0
	i3arp=0
	i0ann=0
      i1ann=0
	i2ann=0
	i3ann=0
	i0anp=0
      i1anp=0
	i2anp=0
	i3anp=0
      icnt=0	
   33 format(1X,F8.3,2(1X,I2),3(1X,F7.2),5(1X,I2,1X,I5),1X,I2,2X,F4.1
     +,4(1X,I2,1X,I5))
   34 format(1X,F8.3,2(1X,I2),3(1X,F7.2),5(1X,I2,1X,I5),1X,I2,2X,F4.1
     +,4(1X,I2,1X,I5),1X,I4)

C
Crem	DO 40 ii=1,272
	DO 40 ii=1,304  ! Pch, plus Pch/ICME
	read(10,33,end=51) ryear,kmn,kdy,pchmin,pchmax,dpch,nswday,nswmax
	+,naeday,naemax,naaday,naamax,napday,napmax,ndsday,ndsmin
	+,nwpday,wpmax,narnday,narnmax,narpday,narpmax,nannday,nannmax
     +,nanpday,nanpmax
	 icnt=icnt+1
C	write(11,34) ryear,kmn,kdy,pchmin,pchmax,dpch,nswday,nswmax
C	+,naeday,naemax,naaday,naamax,napday,napmax,ndsday,ndsmin
C	+,nwpday,wpmax,narnday,narnmax,narpday,narpmax,nannday,nannmax
C     +,nanpday,nanpmax,icnt
	if (dpch.lt.tdpc0) then
	i0dpc=i0dpc+1
	goto 41
	endif
	if ((dpch.ge.tdpc0).and.(dpch.lt.tdpc1)) then
	i1dpc=i1dpc+1
	goto 41
	endif
	if ((dpch.ge.tdpc1).and.(dpch.lt.tdpc2)) then
	i2dpc=i2dpc+1
	                                       else
	i3dpc=i3dpc+1
	endif
   41	continue
	if (nswmax.lt.itsw0) then
	i0sw=i0sw+1
	goto 42
	endif
	if ((nswmax.ge.itsw0).and.(nswmax.lt.itsw1)) then
	i1sw=i1sw+1
	goto 42
	endif
	if ((nswmax.ge.itsw1).and.(nswmax.lt.itsw2)) then
	i2sw=i2sw+1
	                                       else
	i3sw=i3sw+1
	endif
   42	continue
	if (naemax.lt.itae0) then
	i0ae=i0ae+1
	goto 43
	endif
	if ((naemax.ge.itae0).and.(naemax.lt.itae1)) then
	i1ae=i1ae+1
	goto 43
	endif
	if ((naemax.ge.itae1).and.(naemax.lt.itae2)) then
	i2ae=i2ae+1
	                                       else
	i3ae=i3ae+1
	endif
   43	continue
	if (naamax.lt.itaa0) then
	i0aa=i0aa+1
	goto 44
	endif
	if ((naamax.ge.itaa0).and.(naamax.lt.itaa1)) then
	i1aa=i1aa+1
	goto 44
	endif
	if ((naamax.ge.itaa1).and.(naamax.lt.itaa2)) then
	i2aa=i2aa+1
	                                       else
	i3aa=i3aa+1
	endif
   44	continue
	if (napmax.lt.itap0) then
	i0ap=i0ap+1
	goto 45
	endif
	if ((napmax.ge.itap0).and.(napmax.lt.itap1)) then
	i1ap=i1ap+1
	goto 45
	endif
	if ((napmax.ge.itap1).and.(napmax.lt.itap2)) then
	i2ap=i2ap+1
	                                       else
	i3ap=i3ap+1
	endif
   45	continue
	if (wpmax.lt.twp0) then
	i0wp=i0wp+1
	goto 46
	endif
	if ((wpmax.ge.twp0).and.(wpmax.lt.twp1)) then
	i1wp=i1wp+1
	goto 46
	endif
	if ((wpmax.ge.twp1).and.(wpmax.lt.twp2)) then
	i2wp=i2wp+1
	                                       else
	i3wp=i3wp+1
	endif
   46	continue
	if (narnmax.lt.iarn0) then
	i0arn=i0arn+1
	goto 47
	endif
	if ((narnmax.ge.iarn0).and.(narnmax.lt.iarn1)) then
	i1arn=i1arn+1
	goto 47
	endif
	if ((narnmax.ge.iarn1).and.(narnmax.lt.iarn2)) then
	i2arn=i2arn+1
	                                       else
	i3arn=i3arn+1
	endif
   47	continue
	if (narpmax.lt.iarp0) then
	i0arp=i0arp+1
	goto 48
	endif
	if ((narpmax.ge.iarp0).and.(narpmax.lt.iarp1)) then
	i1arp=i1arp+1
	goto 48
	endif
	if ((narpmax.ge.iarp1).and.(narpmax.lt.iarp2)) then
	i2arp=i2arp+1
	                                       else
	i3arp=i3arp+1
	endif
   48	continue
	if (nannmax.lt.iann0) then
	i0ann=i0ann+1
	goto 49
	endif
	if ((nannmax.ge.iann0).and.(nannmax.lt.iann1)) then
	i1ann=i1ann+1
	goto 49
	endif
	if ((nannmax.ge.iann1).and.(nannmax.lt.iann2)) then
	i2ann=i2ann+1
	                                       else
	i3ann=i3ann+1
	endif
   49	continue
	if (nanpmax.lt.ianp0) then
	i0anp=i0anp+1
	goto 50
	endif
	if ((nanpmax.ge.ianp0).and.(nanpmax.lt.ianp1)) then
	i1anp=i1anp+1
	goto 50
	endif
	if ((nanpmax.ge.ianp1).and.(nanpmax.lt.ianp2)) then
	i2anp=i2anp+1
	                                       else
	i3anp=i3anp+1
	endif
  50	continue
     	if (ndsmin.gt.ids0) then
	i0ds=i0ds+1
	goto 40
	endif
	if ((ndsmin.gt.ids1).and.(ndsmin.le.ids0)) then
	i1ds=i1ds+1
	goto 40
	endif
	if ((ndsmin.gt.ids2).and.(ndsmin.le.ids1)) then
	i2ds=i2ds+1
	          else
	i3ds=i3ds+1
			endif
C
   40	continue ! events cycle
   51 close(unit=10)
C
C Output results
C
        word='dpc:'
	cnt=float(icnt)
      perpc0=i0dpc/cnt*100.
	perpc1=i1dpc/cnt*100.
	perpc2=i2dpc/cnt*100.
	perpc3=i3dpc/cnt*100.
      write(*,30) word,i0dpc,i1dpc,i2dpc,i3dpc,perpc0,perpc1,perpc2
	+,perpc3
      write(11,30) word,i0dpc,i1dpc,i2dpc,i3dpc,perpc0,perpc1,perpc2
	+,perpc3
C
C
        word='vsw:'
      persw0=i0sw/cnt*100.
	persw1=i1sw/cnt*100.
	persw2=i2sw/cnt*100.
	persw3=i3sw/cnt*100.
      write(*,30) word,i0sw,i1sw,i2sw,i3sw,persw0,persw1,persw2,persw3
      write(11,30) word,i0sw,i1sw,i2sw,i3sw,persw0,persw1,persw2,persw3
C
        word=' ae:'
      perae0=i0ae/cnt*100.
	perae1=i1ae/cnt*100.
	perae2=i2ae/cnt*100.
	perae3=i3ae/cnt*100.
      write(*,30) word,i0ae,i1ae,i2ae,i3ae,perae0,perae1,perae2,perae3
      write(11,30) word,i0ae,i1ae,i2ae,i3ae,perae0,perae1,perae2,perae3
C
        word=' aa:'
      peraa0=i0aa/cnt*100.
	peraa1=i1aa/cnt*100.
	peraa2=i2aa/cnt*100.
	peraa3=i3aa/cnt*100.
      write(*,30) word,i0aa,i1aa,i2aa,i3aa,peraa0,peraa1,peraa2,peraa3
      write(11,30) word,i0aa,i1aa,i2aa,i3aa,peraa0,peraa1,peraa2,peraa3
C
        word=' ap:'
      perap0=i0ap/cnt*100.
	perap1=i1ap/cnt*100.
	perap2=i2ap/cnt*100.
	perap3=i2ap/cnt*100.
      write(*,30) word,i0ap,i1ap,i2ap,i3ap,perap0,perap1,perap2,perap3
      write(11,30) word,i0ap,i1ap,i2ap,i3ap,perap0,perap1,perap2,perap3
C
        word=' wp:'
      perwp0=i0wp/cnt*100.
	perwp1=i1wp/cnt*100.
	perwp2=i2wp/cnt*100.
	perwp3=i3wp/cnt*100.
      write(*,30) word,i0wp,i1wp,i2wp,i3wp,perwp0,perwp1,perwp2,perwp3
      write(11,30)word,i0wp,i1wp,i2wp,i3wp,perwp0,perwp1,perwp2,perwp3
C
        word='dst:'
      perds0=i0ds/cnt*100.
	perds1=i1ds/cnt*100.
	perds2=i2ds/cnt*100.
	perds3=i3ds/cnt*100.
      write(*,30) word,i0ds,i1ds,i2ds,i3ds,perds0,perds1,perds2,perds3
      write(11,30) word,i0ds,i1ds,i2ds,i3ds,perds0,perds1,perds2,perds3
C
        word='arn:'
      parn0=i0arn/cnt*100.
	parn1=i1arn/cnt*100.
	parn2=i2arn/cnt*100.
	parn3=i3arn/cnt*100.
      write(*,30) word,i0arn,i1arn,i2arn,i3arn,parn0,parn1,parn2,parn3
      write(11,30) word,i0arn,i1arn,i2arn,i3arn,parn0,parn1,parn2,parn3
C
        word='arp:'
      parp0=i0arp/cnt*100.
	parp1=i1arp/cnt*100.
	parp2=i2arp/cnt*100.
	parp3=i3arp/cnt*100.
      write(*,30) word,i0arp,i1arp,i2arp,i3arp,parp0,parp1,parp2,parp3
      write(11,30) word,i0arp,i1arp,i2arp,i3arp,parp0,parp1,parp2,parp3
C
        word='ann:'
      pann0=i0ann/cnt*100.
	pann1=i1ann/cnt*100.
	pann2=i2ann/cnt*100.
	pann3=i3ann/cnt*100.
      write(*,30) word,i0ann,i1ann,i2ann,i3ann,pann0,pann1,pann2,pann3
      write(11,30) word,i0ann,i1ann,i2ann,i3ann,pann0,pann1,pann2,pann3
C
        word='anp:'
      panp0=i0anp/cnt*100.
	panp1=i1anp/cnt*100.
	panp2=i2anp/cnt*100.
	panp3=i3anp/cnt*100.
      write(*,30) word,i0anp,i1anp,i2anp,i3anp,panp0,panp1,panp2,panp3
      write(11,30) word,i0anp,i1anp,i2anp,i3anp,panp0,panp1,panp2,panp3
C
   30	FORMAT(1X,A4,4(1X,I3),4(1X,F7.2))
      close(unit=11)
      pause ' '
	STOP
	END