      program cnttau1c
C.............................................................!.Jan. 2024
C add cycle on 76 stations for current month
c	
c	  count Tau=TEC/NmF2, rv
C Input: (1) styrmnt.txt
C        (2) styrmn.txt
C Output:(1) styrmns.txt	 !slab-thickness Tau
C	   
      DIMENSION IM(12),ff2(0:23),tec(0:23)
	INTEGER*4 JRES(0:23)
	CHARACTER*128 INFILE1,INFILE2,OUTFILE,TXT
	CHARACTER*2 st(80),stcode,yy,amn
	CHARACTER*6	YRMNDY
	CHARACTER*4	AYMN,YEAR
	DATA IM/31,28,31,30,31,30,31,31,30,31,30,31/
	DATA ST/'as','at','bc','bp','br','cb','ch','cn','cq','bj'
     +,'cw','jb','db','dw','eg','eb','di','gr','gu','ha' ! jb > cr Mar 2020
     +,'he','ho','jj','jm','jr','kk','lm','ml','mo','mq'
     +,'mw','nd','ni','ok','pe','pq','sa','rm','ro','vt' ! sa > ps
     +,'pf','tv','tr','wk','wp','wz','mm','tk','kg','mg'	  ! Mar 2020
     +,'sd','rv','qn','ns','so','gm','ei','gg','if','tu'	!tu> nc
     +,'pa','fz','ff','kh','au','al','ga','nc','yg','ic'	!fz> yk nc>di Sep 2019
     +,'ad','bb','bl','ea','mh','wa','sp','cj','er','ll'/			  !Jan.2021
C Test
	year='2026'  ! TEMP
	yy=year(3:4)
	outfile='c:\web\graf\dat9\15\styrmns.txt'
	infile1='c:\web\graf\dat1\15\styrmn.txt'
	infile2='c:\web\graf\dat7\15\styrmnt.txt'
C 
        WRITE(*,*)' ENTER yrmn (0000=stop):'
		READ(*,15) AYMN
	YY=AYMN(1:2)
	AMN=AYMN(3:4)
   15	FORMAT(A4)
c--	if (aymn.eq.'0000') goto 2	   ! Stop program
	outfile(18:19)=yy
	outfile(23:24)=yy
	outfile(25:26)=amn
	infile1(18:19)=yy
	infile1(23:24)=yy
	infile1(25:26)=amn
	infile2(18:19)=yy
	infile2(23:24)=yy
	infile2(25:26)=amn

  200 continue
  199	format(A2)
	do 300 jsta=1,80
c-        jsta=55 ! so
	stcode=st(jsta)
	ieof=0
	write(*,*) stcode
	 OUTFILE(21:22)=stcode
	infile1(21:22)=stcode
	infile2(21:22)=stcode
c     
	OPEN(111,FILE=INFILE1)				  ! file foF2
	OPEN(112,FILE=INFILE2)				  ! file TEC
	OPEN(113,FILE=OUTFILE)				  ! Tau
C
  201	continue
	read(aymn,*) iymn
	iy=IYMN/100
	mn=IYMN-iy*100
	yr=float(iy)
	z1=yr/4.
	jz=int(z1)*4
	IF(jz.EQ.iy) THEN
               IM(2)=29
					dnr=366.
        ELSE
                IM(2)=28
	  	dnr=365.
	       ENDIF

  220 L=0   
      JFL=0 
  159	format(A6,2X,24(F3.1,2X))
  160	format(A128)
  161	format(A6,24(1X,F4.1))
  162	format(A6,24(1X,I4))

C Read-write title lines:
	do k=1,4
	read (111,160,err=270,end=300) txt      ! title
	read (112,160,err=270,end=300) txt      ! title
	if (k.eq.1) txt(15:17)='Tau'
	write(*,160) txt
	write(113,160) txt
	enddo
	ndnr=im(mn)
C Day-to-day cycle:
	DO 260 idy=1,ndnr
   	read (111,159,err=270,end=300) YRMNDY,(ff2(k),k=0,23)      ! file foF2
      read (112,161,err=270,end=300) YRMNDY,(tec(k),k=0,23)      ! file foF2
	do 10 i=0,23
	 xnm=ff2(i)*ff2(i)*1.24
	if (xnm.eq.0.) then
	write(*,*) infile1,YRMNDY,i,' Enter missed foF2:'
	read(*,*) fof2
	 xnm=fof2*fof2*1.24
c	pause ' '

c	rtau=1000.
c	goto 11
	endif

	rtau=tec(i)/xnm
   11	 jres(i)=nint(rtau*1000.)
   10	continue
	write(*,162) YRMNDY,(jres(k),k=0,23)
	write(113,162) YRMNDY,(jres(k),k=0,23)
  260	continue
	goto 300
  270	 write(*,*) 'INPUT FILE IS NOT IN YOUR DIRECTORY ',infile1,infile2

  300	CONTINUE
	goto 301

  301	close(unit=111)
	close(unit=112)
	close(unit=113)
	pause ' '
      STOP
	end