      program extrpcht
C.....................................................May 2020
C Delta dt, hrs, between Pchmax and to=HSSmin
C
	character*128 infile,outfile
	character*51 text
	character*2 AYR,AMN,ADY
      character*4 AYEAR
	infile='catpchhss1t.txt'
	outfile='catpchhss1t.res'
      OPEN(10,file=infile,action='READ')
		OPEN(11,file=outfile)
   30	format(1X,F8.3,1X,I3,2(1X,I2),1X,I3,2X,F5.0,1X,I2,2(2X,F5.0)
     +,1X,I4,2(I2),1X,I2,A51,2X,I3)
   31	format(1X,F8.3,1X,I3,2(1X,I2),1X,I3,2X,F5.0,1X,I2,2(2X,F5.0)
     +,1X,A4,2A2,1X,I2,1X,F6.2,A51,2X,I3)

C
      DO 50 iev=1,163
C
	read(10,30,end=51) ryear1,lda1,mn1,idy1,idt0,vsmin,iut1,vsmax,dvs
     +,iyear0,imn0,idy0,iut0,text,inn         ! lda1~ HSSmax
	 iyr0=iyear0-(iyear0/100)*100
	 call blet2(iyr0,AYR)
	AYEAR='2000'
	AYEAR(3:4)=AYR
	 call blet2(imn0,AMN)
	call blet2(idy0,ADY)
	ldapch=ndoy(iyr0,imn0,idy0)
	iuthss0=iut1+idt0
	if (iuthss0.ge.0) then
	ldat0=lda1
	iutt0=iuthss0
	else
	ldat0=lda1-1
      iutt0=iuthss0+24
	endif
	ldadel=ldat0-ldapch
	if (ldadel.eq.0) then
	idutpch=iutt0-iut0
	endif
	if (ldadel.eq.1) then 
	idutpch=(24-iut0)+iutt0
	             else
	idutpch=(24-iut0)+iutt0+(ldadel-1)*24 
	endif
	dutpch=idutpch/24.
       write(*,31) ryear1,lda1,mn1,idy1,idt0,vsmin,iut1,vsmax,dvs
     +,Ayear,Amn,Ady,iut0,dutpch,text,iev
	write(11,31) ryear1,lda1,mn1,idy1,idt0,vsmin,iut1,vsmax,dvs
     +,Ayear,Amn,Ady,iut0,dutpch,text,iev
  50	continue
  51  close(unit=10)
      close(unit=11)
	pause ' '
	STOP
	END