

	subroutine clear_ps_data
ccc	Sub-program to clear P or S and amplitude, etc data.
	include 'common_arriv.inc'
	include 'common_stncod.inc'
	common /c_rep_theo/nc_rep,kps_rep(2000),nstn_rep(2000),
     1 pssakai_rep(2000,2),err_max_rep(2000),kstn_rep(2000)
	nc_rep=0
	do k=1,2000
	   kstn_rep(k)=0
	   nstn_rep(k)=0
	   kps_rep(k)=0
	   pssakai_rep(k,1)=999.9
	   pssakai_rep(k,2)=999.9
	   enddo

	   do nst=1,nstobs
	    do m=1,2
	    resava(nst,m)=0.0  !1:P,2:S
	       wp_cor(m,nst)=0.0 !m=1 keq,m=2:meq
	       ws_cor(m,nst)=0.0 
	       enddo
	    enddo
	do kst=1,nw200
         nphase_ps(kst)=0
	 poobs(kst)=-999.9
         soobs(kst)=-999.9
	kps_comp(kst,1)=0
	kps_comp(kst,2)=0
           tp_amax(kst)=-99.9
	   ts_amax(kst)=-99.9
	   tp_amin(kst)=-99.9
	   cont_ppart(kst)=0.0
	   cont_spart(kst)=0.0
	   sn_ppart(kst)=0.0
           sn_spart(kst)=0.0
	   kp_check(kst)=0
           ks_check(kst)=0 
	   korg_check(kst)=0
       do k=1,10
          p_psa(kst,k)=-999.9
          sn_psa(kst,k)=0.0
          cont_psa(kst,k)=0.0
          neq_psa(kst,k)=0
          kps_psa(kst,k)=0
          enddo   
	  enddo

	do k=1,nw200
	   ndata_stna(k)=0
	   so1a(k)=999.9
	   so2a(k)=999.9
	   po1a(k)=999.9
	   po2a(k)=999.9
	po(k)=999.0
	poka(k)=999.0
	soka(k)=999.9
	wp(k)=-9.9
	rankp(k)='  '
	ipola(k)='  '
	aicsa(k,1)=0.0
	aicsn(k,1)=0.0
	ampp(k)=0.0
	kst=k
	fp(kst)=0.0
	po(kst)=-99.9
	wp(kst)=-9.9
	so(kst)=999.9
	sp(kst)=-9.9
	ws(kst)=0.0


	travp(kst)=0.0
	travs(kst)=0.0
	po_bsum(kst)=-99.9
	so_bsum(kst)=-99.9
	ipola(kst)=' '
     
cc            posakai(kst)=-99.9
cc            sosakai(kst)=-99.9
	ranks(k)='  '
	aicsa(k,2)=0.0
	aicsn(k,2)=0.0
	amps(k)=0.0
	enddo
	return
	end
	subroutine clear_first_arriv_data
	include 'common_arriv.inc'
ccc	1. Clear hypocenter parameter.
ccc     2. Clear P and S arrival data.
	t=0.0	
	dt=0.0
	phi=-99.9
	dphi=0.0
	ram=0.0
	dram=0.0
	dep=0.0
	ddep=0.0
	fmag=0.0
	sd=0.0
ccc	set P and S arrival times.
	nobsp=0
	nobss=0
	do k=1,na200
	   po(k)=-99.9
	   so(k)=-99.9
	   sp(k)=-9.9
	   wp(k)=0.0
	   ws(k)=0.0
	rankp(k)=''
	ipola(k)=''
	aicsa(k,1)=0.0
	aicsn(k,1)=0.0
	ampp(k)=0.0
	period(k,1)=0.0
	ranks(k)='  '
	aicsa(k,2)=0.0
	aicsn(k,2)=0.0
	amps(k)=0.0
	  po1a(k)=-99.9
	  po2a(k)=-99.9
          so1a(k)=-99.9
	  so2a(k)=-99.9
	   enddo
	   return
	   end
