      program extparmedt
C.......................................................Apr 2020
C
C Compile 8st x month x 24UT TEC file
C monthly median data or model
C
      character*120 infile,outfile,txt
		character*2 AYR,st,stat(8)
	character*4 AYEAR,tite
      dimension tec(8,288)
	DATA stat/'du','ho','dw','pg','gg','kk','yk','ti'/
C
C+      infile='stYEAR_1.out' ! CCIR	model
c+         iflag=1
c+	tite='ccir'
c	infile='stYEARfh_2.out' ! GMF2	model
        iflag=2
      tite='gmf2'
c+	iflag=3
c+      tite=' jpl'
C
c	AYEAR='2014' 
      AYEAR='2019' 
c      AYR='14'
      AYR='19'
	read(ayr,*) ryr
	iyr=int(ryr)
c
   31 format(2(1X,A25))
   32 format(1X,A4,A2)
C
C
      outfile='tecYEARt.txt'
	outfile(4:7)=AYEAR
	OPEN(10,file=outfile,access='APPEND')
	write(*,32) tite,AYR
	write(10,32) tite,AYR

C Cycle on stat:
         DO 70 ist=1,8
       st=stat(ist)
C-      write(*,*) ' Enter st 00 for stop:'
C-	read(*,*) st
C-	if (st.eq.'00') goto 77
        select case(iflag)
      case(1)
      infile='stYEAR_1.out' ! CCIR	model
	infile(3:6)=AYEAR
       infile(1:2)=st
	case(2)
      infile='stYEARfh_2.out' ! GMF2	model
	infile(3:6)=AYEAR
       infile(1:2)=st
	case(3)
	infile='d:\web\graf\YEAR\styr.med' ! TEC-jpl data obs
      infile(13:16)=AYEAR
	infile(20:21)=AYR
	infile(18:19)=st
      end select
	write(*,31) infile,outfile
C
	OPEN(11,file=infile,action='READ')
	if (iflag.lt.3) then
	do k=1,7
	read(11,*) txt   ! title line
	enddo
C read model TEC
       DO jj=1,288
	read(11,33,end=51) tec(ist,jj)
	enddo
                     else
       DO jj=1,288
	read(11,34,end=51) tec(ist,jj)
	enddo
              	endif
   51   close(unit=11)
C
C output
C
   70 CONTINUE ! 
         do k=1,288
        write(*,35) (tec(nst,k),nst=1,8)
	write(10,35)  (tec(nst,k),nst=1,8)
	enddo
c++++++++++++++++++++++++++++++++++++++++++++++++++++++
   77	close(unit=10)
C
   33 format(144X,F6.2) ! TEC from IRI-Plas.out file
   34 format(26X,F5.1) ! TEC-jpl obs
   35 format(8(1X,F5.1)) ! tec 
       pause ' '
	STOP
	END