      program cnteqwulnn2
C..............................................Sep 2022
C Number of EQs with Hpo_pre>=<Hpo(t0), Weq_pre>=<Hpo(t0)
C				   Hpo_nexe>=<Hpo(t0), Weq_nexer>=<Hpo(t0)
C Depth < 30 km, Depth > 30 km
C total number of EQs 1810 (19952020)
	CHARACTER*64 outfile,infile,txt
C
C       infile='addeqhpotot.txt' ! Hpo
	infile='addwcpiaeq.txt' ! all SSN=0  1994-2020
	outfile='cnteqhponn.txt'
	OPEN(11,file=infile,action='READ')
	do i=1,18
	read(11,*) txt
	enddo 

	OPEN(12,file=outfile,access='APPEND')
C
C   35 format(1X,F8.3,1X,I3,4(1X,I2),2(1X,F6.2),1X,I4,2(1X,F4.1)		!Hpo
C     +,2(1X,I4),1X,F5.2,2(1X,I3,1X,F7.3),1X,I4)						!Hpo
   35 format(1X,F8.3,1X,I3,4(1X,I2),2(1X,F6.2),1X,I4,2(1X,F4.1)		!Wpre,Wnex
     +,2(1X,I4),1X,F5.2,2(1X,I3,1X,F5.2),1X,I4)						!Wpre,Wnex
        icntdkm=0
	nn=0
	idlim=30
	icnpre1n=0  !Ipre >Ito
		icnpre1p=0  !Ipre >Ito
	icnpre2=0  !Ipre =Ito
	icnpre3n=0  !Ipre <Ito
	  icnpre3p=0  !Ipre <Ito
	icnnex1n=0  !Inex >Ito
	  icnnex1p=0  !Inex >Ito
	icnnex2=0  !Inex =Ito
	icnnex3n=0  !Inex <Ito
	  icnnex3p=0  !Inex <Ito
	DO 41 iev=1,1954
C
C	read(11,35,end=50) ryear,lda,imn,idy,iuteq,imm,glats,glons,kmds  !Hpo
C 	+,aeqmax,eqav,ndyeq,knum,hpeq,jt_pre,hp_pre,jt_nex,hp_nex,ndy	 !Hpo
	read(11,35,end=50) ryear,lda,imn,idy,iuteq,imm,glats,glons,kmds  !Wpre,Wnex
 	+,aeqmax,eqav,ndyeq,knum,hpeq,jt_pre,hp_pre,jt_nex,hp_nex,ndy	 !Wpre,Wnex
      iyear=int(ryear)
	aweq=abs(hpeq)   ! |weq|
	awpre=abs(hp_pre)  !|wpre|
	awnex=abs(hp_nex)  !|wnex|
	nn=nn+1
C Depth
C        if(kmds.le.idlim) then  ! Depth <=30    +++++++1
	if(kmds.gt.idlim) then	  !DEpth > 30
C
         icntdkm=icntdkm+1
      if (awpre.eq.aweq) then 
	icnpre2=icnpre2+1
	goto 42
	endif
C
C Separate Wpre<0
	if (awpre.gt.aweq) then		!+++++2
	 if(hp_pre.lt.0) then
	icnpre1n=icnpre1n+1
	        else
	icnpre1p=icnpre1p+1
	      endif
	                  else	  !++++++++2
	 if(hp_pre.lt.0) then
	icnpre3n=icnpre3n+1
	        else
	icnpre3p=icnpre3p+1
	      endif
	                 endif    !+++++++2
   42     if (awnex.eq.aweq) then
      icnnex2=icnnex2+1
	goto 41
	endif
C
	if (awnex.gt.aweq) then	  !++++++++3
	  if (hp_nex.lt.0) then
	    icnnex1n=icnnex1n+1
	      else
	   icnnex1p=icnnex1p+1
	    endif
	                 else      !+++++++++3
	  if (hp_nex.lt.0) then
	    icnnex3n=icnnex3n+1
	      else
	   icnnex3p=icnnex3p+1
	    endif
	endif                        !+++++++++++3
	endif						 !++++++1
   41	CONTINUE
   50 close(11)
      write(*,34) idlim,icntdkm,nn,icnpre1n,icnpre1p,icnpre2,icnpre3n
	+,icnpre3p,icnnex1n,icnnex1p,icnnex2,icnnex3n,icnnex3p
	write(12,34) idlim,icntdkm,nn,icnpre1n,icnpre1p,icnpre2,icnpre3n
	+,icnpre3p,icnnex1n,icnnex1p,icnnex2,icnnex3n,icnnex3p
	close(12)
   34 format(1X,I3,2(1X,I4),2(1X,5(1X,I4)))
	pause ' '
		STOP
	END