      program extrpch
C.........................................................Jan 2018
C Extract Pch index from pixels data
      CHARACTER*6 YYMMDD,Y1M1D1
      CHARACTER*65 infile,outfile
C
      write(*,*) ' Enter YRMNDY ' !start date of file
	read(*,*) YYMMDD
	infile='d:\data\CH\pchyymmdd.txt'
	infile(15:20)=YYMMDD
	outfile='pchdata.dat'
C
   31 format(F6.2,1X,F4.2)
   32 format(A6,1X,F4.2)
   33 format(1X,A6,1X,F7.2)

	open(10,file=infile,action='READ')
	open(11,file=outfile,access='APPEND')
C
      read(10,31,end=41) y0,z0
	read(10,31,end=41) y1,z1
	dz=z0-z1
    1	read(10,32,end=41)	Y1M1D1,zi
      if (dz.gt.0.) yi=-(zi-z0)/dz*y1
	write(*,33) Y1M1D1,yi
	write(11,33) Y1M1D1,yi
	GOTO 1
   41	close(unit=10)
      close(unit=11)
	pause ' '
	STOP
	END