      program effpch
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
	infile='extpchcat4.txt'
	OPEN(10,FILE=infile,action='READ')
	read(10,*) txt !extra line
	outfile='effpch.res'
	OPEN(11,FILE=OUTFILE,access='APPEND')
C
 	itsw1=500
	itsw2=700
	tdpc1=100.
	tdpc2=700.
	tpcm1=320.
	tpcm2=1000.
C    itae1=750
      itae1=750
	itae2=1000
	itaa1=50
	itaa2=100
C	itap1=27
C	itap2=62
	itap1=25
	itap2=65
	twp1=4.3
	twp2=5.5
C	twp1=4.0
C	twp2=6.0
	itds1=-35
	itds2=-48
	idst1=-50
	idst2=-100
   33 format(1X,F8.3,2(1X,I2),3(1X,F7.2),5(1X,I2,1X,I5),1X,I2,1X,F4.1
     +,1X,I4)

C
	i0dpc=0
      i1dpc=0
	i2dpc=0
	i0pcm=0
      i1pcm=0
	i2pcm=0
	i0sw=0
      i1sw=0
	i2sw=0
	i0ae=0
      i1ae=0
	i2ae=0
	i0aa=0
      i1aa=0
	i2aa=0
	i0ap=0
      i1ap=0
	i2ap=0
	i0wp=0
      i1wp=0
	i2wp=0
	i0ds=0
      i1ds=0
	i2ds=0
	i0dst=0
      i1dst=0
	i2dst=0
C
	DO 40 ii=1,348
	read(10,33,end=50) ryear,kmn,kdy,pchmin,pchmax,dpch,nswday,nswmax
	+,naeday,naemax,naaday,naamax,napday,napmax,ndsday,ndsmin
	+,nwpday,wpmax,kev
	if (dpch.lt.tdpc1) then
	i0dpc=i0dpc+1
	goto 41
	endif
	if ((dpch.ge.tdpc1).and.(dpch.lt.tdpc2)) then
	i1dpc=i1dpc+1
	                                       else
	i2dpc=i2dpc+1
	endif
   41	continue
	if (pchmax.lt.tpcm1) then
	i0pcm=i0pcm+1
	goto 141
	endif
	if ((pchmax.ge.tpcm1).and.(pchmax.lt.tpcm2)) then
	i1pcm=i1pcm+1
	                                       else
	i2pcm=i2pcm+1
	endif
  141	continue
	if (nswmax.lt.itsw1) then
	i0sw=i0sw+1
	goto 42
	endif
	if ((nswmax.ge.itsw1).and.(nswmax.lt.itsw2)) then
	i1sw=i1sw+1
	                                       else
	i2sw=i2sw+1
	endif
   42	continue
	if (naemax.lt.itae1) then
	i0ae=i0ae+1
	goto 43
	endif
	if ((naemax.ge.itae1).and.(naemax.lt.itae2)) then
	i1ae=i1ae+1
	                                       else
	i2ae=i2ae+1
	endif
   43	continue
	if (naamax.lt.itaa1) then
	i0aa=i0aa+1
	goto 44
	endif
	if ((naamax.ge.itaa1).and.(naamax.lt.itaa2)) then
	i1aa=i1aa+1
	                                       else
	i2aa=i2aa+1
	endif
   44	continue
	if (napmax.lt.itap1) then
	i0ap=i0ap+1
	goto 45
	endif
	if ((napmax.ge.itap1).and.(napmax.lt.itap2)) then
	i1ap=i1ap+1
	                                       else
	i2ap=i2ap+1
	endif
   45	continue
	if (wpmax.lt.twp1) then
	i0wp=i0wp+1
	goto 46
	endif
	if ((wpmax.ge.twp1).and.(wpmax.lt.twp2)) then
	i1wp=i1wp+1
	                                       else
	i2wp=i2wp+1
	endif
   46	continue
	if (ndsmin.gt.itds1) then
	i0ds=i0ds+1
	goto 47
	endif
	if ((ndsmin.gt.itds2).and.(ndsmin.le.itds1)) then
	i1ds=i1ds+1
	                                       else
	i2ds=i2ds+1
	endif
   47	continue
	if (ndsmin.gt.idst1) then
	i0dst=i0dst+1
	goto 147
	endif
	if ((ndsmin.gt.idst2).and.(ndsmin.le.idst1)) then
	i1dst=i1dst+1
	                                       else
	i2dst=i2dst+1
	endif
  147	continue
C
   40	continue ! events cycle
   50 close(unit=10)
C
C Output results
C
        word='dpc:'
      perpc0=i0dpc/348.*100.
	perpc1=i1dpc/348.*100.
	perpc2=i2dpc/348.*100.
      write(*,30) word,i0dpc,i1dpc,i2dpc,perpc0,perpc1,perpc2
      write(11,30) word,i0dpc,i1dpc,i2dpc,perpc0,perpc1,perpc2
C
        word='pcm:'
      perpc0=i0pcm/348.*100.
	perpc1=i1pcm/348.*100.
	perpc2=i2pcm/348.*100.
      write(*,30) word,i0pcm,i1pcm,i2pcm,perpc0,perpc1,perpc2
      write(11,30) word,i0pcm,i1pcm,i2pcm,perpc0,perpc1,perpc2
C
        word='vsw:'
      persw0=i0sw/348.*100.
	persw1=i1sw/348.*100.
	persw2=i2sw/348.*100.
      write(*,30) word,i0sw,i1sw,i2sw,persw0,persw1,persw2
      write(11,30) word,i0sw,i1sw,i2sw,persw0,persw1,persw2
C
        word=' ae:'
      perae0=i0ae/348.*100.
	perae1=i1ae/348.*100.
	perae2=i2ae/348.*100.
      write(*,30) word,i0ae,i1ae,i2ae,perae0,perae1,perae2
      write(11,30) word,i0ae,i1ae,i2ae,perae0,perae1,perae2
C
        word=' aa:'
      peraa0=i0aa/348.*100.
	peraa1=i1aa/348.*100.
	peraa2=i2aa/348.*100.
      write(*,30) word,i0aa,i1aa,i2aa,peraa0,peraa1,peraa2
      write(11,30) word,i0aa,i1aa,i2aa,peraa0,peraa1,peraa2
C
        word=' ap:'
      perap0=i0ap/348.*100.
	perap1=i1ap/348.*100.
	perap2=i2ap/348.*100.
      write(*,30) word,i0ap,i1ap,i2ap,perap0,perap1,perap2
      write(11,30) word,i0ap,i1ap,i2ap,perap0,perap1,perap2
C
        word=' wp:'
      perwp0=i0wp/348.*100.
	perwp1=i1wp/348.*100.
	perwp2=i2wp/348.*100.
      write(*,30) word,i0wp,i1wp,i2wp,perwp0,perwp1,perwp2
      write(11,30) word,i0wp,i1wp,i2wp,perwp0,perwp1,perwp2
C
        word='dsp:'
      perds0=i0ds/348.*100.
	perds1=i1ds/348.*100.
	perds2=i2ds/348.*100.
      write(*,30) word,i0ds,i1ds,i2ds,perds0,perds1,perds2
      write(11,30) word,i0ds,i1ds,i2ds,perds0,perds1,perds2
C
        word='dst:'
      perds0=i0dst/348.*100.
	perds1=i1dst/348.*100.
	perds2=i2dst/348.*100.
      write(*,30) word,i0dst,i1dst,i2dst,perds0,perds1,perds2
      write(11,30) word,i0dst,i1dst,i2dst,perds0,perds1,perds2
   30	FORMAT(1X,A4,3(1X,I3),3(1X,F7.2))
      close(unit=11)
      pause ' '
	STOP
	END