	program delpch1
c .......................................................Nov 2019
C Combine Pch+ 10 kinds of indices
C
C
C Select peaks of delPch=Pchmax(3d)-Pchmin(-3d) for del > 100 i.u.
C movind 3day window, 
C Select all Del >0: output => 'delpchpos.res'
C for 2011-2018
C
c
	DIMENSION ryears(317),IAE(317),IDST(317)
C	+,pmin(317),pmax(317),del(317)
	CHARACTER(10) DD
      CHARACTER(10) TT
      CHARACTER(5) ZZ
	CHARACTER*94,infile1,infile2,outfile,txt
	CHARACTER*2 AMD(317,2)
	CHARACTER*38 txt1(317)
	CHARACTER*23 txt2(317)
	CHARACTER*8 txt3(317)
	CHARACTER*36 txt4(317)
C
	CALL DATE_AND_TIME(DATE=DD,TIME=TT,ZONE=ZZ)
      TT(5:)='      '
      WRITE(*,*) 'PC Date: Year,Month,Day = ',DD,'Time = ',TT
C
  791 FORMAT(A10,1X,I4)
      outfile='delpch2.res' ! 
	OPEN(12,FILE=OUTFILE)
C
   36	format(1X,F8.3,2(1X,A2),A38,I4,A23,I4,A8)
   37	format(40X,A36)
   38	format(1X,F8.3,2(1X,A2),A38,I4,A23,I4,A8,A36,1X,I3)
   30	format(A94)

C
C+	infile1='catpchind5d-.txt'
	infile1='catpchICME5d.txt'
		OPEN(10,FILE=infile1,ACTION='READ')
	read(10,30) txt !~ title line
	write(12,30) txt
	infile2='catpcharcICME4.txt'
	OPEN(11,FILE=infile2,ACTION='READ')
	read(11,30) txt !~ title line
	write(12,30) txt
C
 	icntot=0 ! count of dPch
	do 100 ii=1,317
	read(10,36,end=102) RYEARS(ii),AMD(ii,1),AMD(ii,2),txt1(ii)
	+,IAE(ii),txt2(ii),idst(ii),txt3(ii)
      read(11,37,end=103)	txt4(ii)
      icntot=icntot+1
C
	write(*,38) RYEARS(ii),AMD(ii,1),AMD(ii,2),txt1(ii)
C+	+,IAE(ii),txt2(ii),-idst(ii),txt3(ii),txt4(ii),icntot
	+,IAE(ii),txt2(ii),idst(ii),txt3(ii),txt4(ii),icntot
	write(12,38) RYEARS(ii),AMD(ii,1),AMD(ii,2),txt1(ii)
C	+,IAE(ii),txt2(ii),-idst(ii),txt3(ii),txt4(ii),icntot
	+,IAE(ii),txt2(ii),idst(ii),txt3(ii),txt4(ii),icntot
C
  100	CONTINUE

  102  CLOSE(unit=10)
  103  CLOSE(unit=12)
  900 pause ' '
      STOP
      END

