      program histpcharc
C..............................................................................Oct 2019
C Effective Pch events in Arctic and Antactic
C
      dimension iarn(10),iarp(10),iann(10),ianp(10)
	+,per(10),ithr(10)
	CHARACTER*65 infile,outfile,txt
		CHARACTER*5 word
	DATA ithr/0,100,200,300,400,500,600,700,800,900/
C
	infile='extpcharc4.txt'
	OPEN(10,FILE=infile,action='READ')
	read(10,*) txt !extra line
	outfile='histpch.res'
	OPEN(11,FILE=OUTFILE,access='APPEND')
C
   33 format(1X,F8.3,2(1X,I2),3(1X,F7.2),4(1X,I2,1X,I5),1X,I4)

C
      do i=1,10
	iarn(i)=0
	iarp(i)=0
	iann(i)=0
	ianp(i)=0
	enddo
C
	DO 40 ii=1,348
	read(10,33,end=50) ryear,kmn,kdy,pchmin,pchmax,dpch,nlnday,nlnmax
	+,nunday,nunmax,nlsday,nlsmax,nusday,nusmax,kev
	if (nlnmax.ge.900) then
	iarn(10)=iarn(10)+1
	goto 42
	endif
	do i=1,9
	if ((nlnmax.ge.ithr(i)).and.(nlnmax.lt.ithr(i+1))) then
	iarn(i)=iarn(i)+1
	exit
	endif
	enddo
   42	continue
	if (nunmax.ge.900) then
	iarp(10)=iarp(10)+1
	goto 43
	endif
	do i=1,9
	if ((nunmax.ge.ithr(i)).and.(nunmax.lt.ithr(i+1))) then
	iarp(i)=iarp(i)+1
	exit
	endif
	enddo
   43	continue
	if (nlsmax.ge.900) then
	iann(10)=iann(10)+1
	goto 44
	endif
	do i=1,9
	if ((nlsmax.ge.ithr(i)).and.(nlsmax.lt.ithr(i+1))) then
	iann(i)=iann(i)+1
	exit
	endif
	enddo
   44	continue
	if (nusmax.ge.900) then
	ianp(10)=ianp(10)+1
	goto 45
	endif
	do i=1,9
	if ((nusmax.ge.ithr(i)).and.(nusmax.lt.ithr(i+1))) then
	ianp(i)=ianp(i)+1
	exit
	endif
      enddo
   45	continue
C
   40	continue ! events cycle
   50 close(unit=10)
C
C Output results
C
        word='arn=['
	do i=1,10
      per(i)=iarn(i)/348.*100.
	ithr(i)=ithr(i)/10
	enddo
	write(*,64) (ithr(k),k=1,10)
	write(11,64) (ithr(k),k=1,10)
      write(*,38) word,(iarn(k),k=1,10)
      write(11,38) word,(iarn(k),k=1,10)
      write(*,39) word,(per(k),k=1,10)
      write(11,39) word,(per(k),k=1,10)
C
        word='arp=['
	do i=1,10
      per(i)=iarp(i)/348.*100.
	enddo
      write(*,38) word,(iarp(k),k=1,10)
      write(11,38) word,(iarp(k),k=1,10)
      write(*,39) word,(per(k),k=1,10)
      write(11,39) word,(per(k),k=1,10)
C
        word='ann=['
	do i=1,10
      per(i)=iann(i)/348.*100.
	enddo
      write(*,38) word,(iann(k),k=1,10)
      write(11,38) word,(iann(k),k=1,10)
      write(*,39) word,(per(k),k=1,10)
      write(11,39) word,(per(k),k=1,10)
C
        word='anp=['
	do i=1,10
      per(i)=ianp(i)/348.*100.
	enddo
      write(*,38) word,(ianp(k),k=1,10)
      write(11,38) word,(ianp(k),k=1,10)
      write(*,39) word,(per(k),k=1,10)
      write(11,39) word,(per(k),k=1,10)
   64	FORMAT(1X,'hwp=[',10(1X,I4),']')
   38	FORMAT(1X,A5,10(1X,I4),']')
   39 FORMAT(1X,A5,10(1X,F5.2),']')
C   30	FORMAT(1X,A4,3(1X,I3),3(1X,F7.2))
      close(unit=11)
      pause ' '
	STOP
	END