C*************************************************************   
CC 
      SUBROUTINE SUBTAU81UML(IYYYY,IMN,IDY,ryear,ldaend,Ftau)
CC-------------------------------------------------------------------
CC......................................................Apr. 2024
CC Ytau27=(1-tau)/(1-tau**n)*(F0+tau*F_1+tau**2*F_2...+tau**29*F_26) =smoothed TECnoon(tau) ndex
CC
C Ref. Deminov M.G. Geomagn. Aeronomy, 2022, V.62, No. 3, P.302-306 
C
CC Modified to produce sunspot number R81, and solar radio flux F81 
CC from two successive kpYEAR annual files
CC Input: 
CC       kpYEAR  (preceding year: IYYYY-1)                              
CC       kpYEAR  (given year: IYYYY)                              
c--------------------------------------------------------------------
c 
c T.L. Gulyaeva ......................................  Sep. 2001. 
c Modified for producing solar radio flux F10.7, F81, averaged for
c 81 days preceeding given day
C 
C------------------------------------------------------------------------
      DIMENSION lm(12)
     &,tec(0:82)
      CHARACTER*4 YEAR,YEAR_pre
      CHARACTER*80 infilekp
      DATA LM/31,28,31,30,31,30,31,31,30,31,30,31/
C
C START: 
      ipcnt=0 ! keep cnt 
C	tau=0.9636
      tau=exp(-1./27.)
         do k=0,82
       tec(k)=0
         enddo
	iyear_cur=iyyyy
	imn_cur=imn
	idy_cur=idy
C
        iy=iyyyy-1900

 770       z1=iy/4.0
        lm(2)=28
	ndnr=365
           if(iyyyy/4*4.eq.iyyyy) then 
		 lm(2)=29
	ndnr=366
	         endif
	del=1.0/ndnr
      if (iy.ge.100) then
      iyr=iy-100
      else
      iyr=iy
      endif
      call blet4(iyyyy,YEAR)
      iYYYY_pre=iYYYY-1
      call blet4(iYYYY_pre,YEAR_pre)
C
      idend=idy
C
C Day-of-year:
      ldaend=ndoy(iyyyy,imn,idend)       ! current day-of-year
	ryear=iyyyy+(ldaend-1.0)*del
C
      ipre=0
c-       if (ldaend.lt.82) then
c-        ipre=1    ! Include data for preceding year
c-       endif
C
Cnorm       infilekp='tecnoonumld.txt'  
       infilekp='tecnoonumld1.txt'   !temp
      OPEN(19,FILE=infilekp,action='READ')  
c  203	READ(19,10,END=30) JYR,JMN,JDY,tecnoon
c-	if (jyr.lt.100) then 
c-	goto 203
c-	endif
c-	 if (jyr+2000.lt.iYYYY_pre) GOTO 203 
C
10    FORMAT(1X,3I2,1X,F5.1)

C
C-------------------------------------------------------------------------------
C Go to read TECnoon daily data
C
C
  204 continue  
C
      READ(19,10,END=30) JYR,JMN,JDY,tecnoon
      tec(82)=tecnoon
C Move data 1 line up:
  140 do  k=0,81
      tec(k)=tec(k+1)
      enddo
C
      IF ((JYR.eq.IYR).and.(JMN.eq.IMN).and.(JDY.eq.idend)) then 
      goto 207
      ELSE
      goto 204
      ENDIF

C data for 81 preceding days are collected                       
  207 Ftau=0.0
      	fsum=tec(81)
C?      fsum=0.
	stau=tau
	stausum=1.
C
      do k=80,0,-1
	fsum=fsum+stau*tec(k)
	stau=stau*tau
	stausum=stausum+stau
	enddo
	coef=(1.-tau)/(1.-stau)
	Ftau=coef*fsum
	Ftau=fsum/stausum
C
C
      goto 30
21      write(*,100)
100     format(1X,'Date is outside range of Kp-Ap indices file.')
      goto 30
  29  write(*,*) 'Error in input k-index file',infilekp 
C      pause ' '
      stop
  30  CLOSE(unit=19)
      RETURN
      END

C __________________________________________________________________________
C
