      program extfotctau
C                                                       Apr. 2018
C
C Extract foF2, hmF2, TEC, tau for 2014-2017: Mos: midnight:02UT & noon: 10UT
C
      character*65 infilef,infileh,infilet
	+,outfile1,outfile2,outfile3,outfile4 !tau
	character*128 txt
	dimension iff2(0:23),ihm2(0:23),itec(0:23)
	character*2 AYR,AMN,ADY,BYR,BMN,BDY
C
      infilef='d:\web\dat1\YR\moYRMN.txt'
	infileh='d:\web\dat6\YR\moYRMNh.txt'
	infilet='d:\web\dat7\YR\moYRMNt.txt'
	ADY='15'

	outfile1='mofo0012.txt'
	outfile2='mohm0012.txt'
	outfile3='motc0012.txt'
	outfile4='mota0012.txt'
	OPEN(16,file=outfile1)
	OPEN(17,file=outfile2)
	OPEN(18,file=outfile3)
	OPEN(19,file=outfile4)
   71 format(A128)
   72 format(3A2,2X,24(I3,2X))
C
	DO 40 iyr=14,17
	call blet2(iyr,AYR)
	infilef(13:14)=AYR
	infileh(13:14)=AYR
	infilet(13:14)=AYR
	infilef(18:19)=AYR
	infileh(18:19)=AYR
	infilet(18:19)=AYR

	DO 41 imn=1,12
	call blet2(imn,AMN)
	infilef(20:21)=AMN
	infileh(20:21)=AMN
	infilet(20:21)=AMN
C
       OPEN(11,file=infilef,action='READ')
	OPEN(12,file=infileh,action='READ')
	OPEN(13,file=infilet,action='READ')
	do i=1,4
	read(11,71) txt  !extra line
	read(12,71) txt  !extra line
	read(13,71) txt  !extra line
	enddo
C
	do i=1,15
	read(11,72) BYR,BMN,BDY,(iff2(k),k=0,23)
	read(12,72) BYR,BMN,BDY,(ihm2(k),k=0,23)
	read(13,72) BYR,BMN,BDY,(itec(k),k=0,23)
	enddo
	close(unit=11)
	close(unit=12)
	close(unit=13)
	f00=iff2(22)/10.
	t00=itec(22)/10.
	ihm00=ihm2(22)
		ihm12=ihm2(10)
      f12=iff2(10)/10.
	t12=itec(10)/10.
	xnm00=f00*f00*1.24
	xnm12=f12*f12*1.24
	rtau00=t00/xnm00*1000.
	rtau12=t12/xnm12*1000.
   73 format(1X,3A2,2(1X,F6.1))  !foF2
   74 format(1X,3A2,2(2X,I4))  !hmF2
	write(*,73) BYR,BMN,BDY,f12,f00
	write(16,73) BYR,BMN,BDY,f12,f00
	write(*,74) BYR,BMN,BDY,ihm12,ihm00
	write(17,74) BYR,BMN,BDY,ihm12,ihm00
	write(*,73) BYR,BMN,BDY,t12,t00
	write(18,73) BYR,BMN,BDY,t12,t00
	write(*,73) BYR,BMN,BDY,rtau12,rtau00
	write(19,73) BYR,BMN,BDY,rtau12,rtau00
   41	continue

   40 continue
      close(unit=16)
	close(unit=17)
	close(unit=18)
	close(unit=19)
      pause ' '
	stop
	end



