      program extionolab
C................................Mar 2015 - June 2016
C output in LT=0,1,23
	dimension ritec(0:23),rutout(0:23)
	CHARACTER*54,infile,outfile,outfilehr,txt
		CHARACTER*4 BYEAR
	CHARACTER*2 AYR,AUT,AMM,ASS,BYR,BMN,BDY,ST
C	+,AMN,ADY
	CHARACTER*1 cc
	CHARACTER*8 xxyyzz
	cc='%'
C 
c+	infile='GG140901.txt'
      infile='stYR0322.txt'
   1	write(*,*) 'Enter st, YR :'
	read(*,*) st,ayr
	infile(1:2)=st
	infile(3:4)=ayr
	if (st.eq.'an') glong=32.8
	if (st.eq.'br') glong=321.6
	if (st.eq.'yi') glong=56.1


c	outfile='gg140901.out'
      outfile=infile
	outfile(10:)='out'
c	outfilehr='tc1409t.txt'
	outfilehr='tcYR0322st.txt'
      outfilehr(3:4)=ayr
	outfilehr(9:10)=st
C
		OPEN(13,FILE=OUTFILEHR)
c	AYR='14'
c	AMN='09'
c	do 1234 idy=1,18
c	  call blet2(idy,ADY)
c	infile(7:8)=ADY
c	outfile(7:8)=ADY
	OPEN(11,FILE=INFILE)
		OPEN(12,FILE=OUTFILE)
  101	format(A54)
  102	format(2X,3A2,1X,A8,A8)
c  103	format(1X,3A2,1X,F6.2,1X,A8)
  103 format(1X,3A2,3(1X,F6.2))
  107	format(A1,A54)
	read(11,101) txt ! extra line
	write(12,107) cc,txt
	read(11,101) txt ! extra line
	write(12,107) cc,txt
	rut=0.0
	iut=0
c  100	read(11,102,end=3) BYR,BMN,BDY,xxyyzz,tec
  100	read(11,*,end=3) xxyyzz,iutms,tec
      BDY=xxyyzz(1:2)
	BMN=xxyyzz(3:4)
	BYEAR=xxyyzz(5:8)
	BYR=BYEAR(3:4)
C   	if (sv.eq.' 00') then
c	if (xxyyzz(2:2).eq.':') then
c	AUT(2:2)=xxyyzz(1:1)
c	AUT(1:1)='0'
c	AMM=xxyyzz(3:4)
c	ASS=xxyyzz(6:7)
c	else
c	AUT=xxyyzz(1:2)
c	AMM=xxyyzz(4:5)
c	ASS=xxyyzz(7:8)
c	endif
	iut=iutms/10000
	call blet2(iut,AUT)
	iumm=(iutms-iut*10000)/100
      call blet2(iumm,AMM)
      iuss=iutms-iut*10000-iumm*100
      call blet2(iuss,ASS)
       rut=float(iut)
	 rmm=float(iumm)
	 rss=float(iuss)
c	read(aut,*) rut
c	read(amm,*) rmm
c	read(ass,*) rss
	uth=rut+(rmm+rss/60.)/60.
	hrlt=uth+glong/15.
	if (hrlt.ge.24.) hrlt=hrlt-24.
	ilt=nint(hrlt)
	 dlt=hrlt-float(ilt)
	if (abs(dlt).lt.0.03) then 
	ritec(ilt)=tec
	rutout(ilt)=uth
	endif
	write(*,103) byr,bmn,bdy,uth,hrlt,tec
	write(12,103) byr,bmn,bdy,uth,tec
c	if ((amm.eq.'00').and.(ass.eq.'00')) then
c	if (tec(1:1).eq.' ') tec(1:1)='0'
c	read(tec,*) rtec
c	itec=nint(rtec*10.)
c	iitec(iut)=itec
c	iut=iut+1
c	endif
	goto 100
   3	close(unit=11)
	close(unit=12)

c-	write(*,104) byr,bmn,bdy, (rutout(k),k=0,23)
c-	write(13,104) byr,bmn,bdy, (rutout(k),k=0,23)
c-	write(*,104) byr,bmn,bdy, (ritec(k),k=0,23)
c-	write(13,104) byr,bmn,bdy, (ritec(k),k=0,23)
       	do k=0,23
	write(*,105) k,rutout(k),ritec(k)
	write(13,105) k,rutout(k),ritec(k)
	enddo

1234	CONTINUE 	   ! day-to-day
C104	format(1X,3A2,24(1X,I4))
104	format(1X,3A2,24(1X,F5.2))
105	format(1X,I2,2(1X,F6.2))
      close(unit=13)
	pause ' '
	GOTO 1
	stop
	end