      subroutine subtecutc(AYR,AMN,ADY)
C .................................................Jan 2025
C Extract TEC UT maps from daily JPL GIM-TEC file
C
	CHARACTER*2 AYR,AMN,ADY,RMN,RDY,ADY0,AUT
	INTEGER itec(71,0:72)
C++	INTEGER*2 idy,iut
	CHARACTER*128 infile,outfile
	CHARACTER*41 outf                  !Ljuba
      CHARACTER*25 ile                  !Ljuba
	CHARACTER*16 start,txt1
	CHARACTER*60 txt
	CHARACTER*4 RYEAR
	integer*4 ixx(16)
	dimension itxx(0:72)
C
	start='START OF TEC MAP'
	read(ady,*) zdy
	idy=int(zdy)
1001	ndyend=idy       ! for one day TEC maps
      IRUN=0 ! NORMAL COMMAND
	iut0=0 ! NORMAL COMMAND
	ady0=ady

C	outfile='d:\web\graf\dtc\yr\mn\ut\tcmndyut.jyr'  ! ionex type map  ! Tamara
C	outfile(17:18)=ayr                                                 ! Tamara
C	outfile(20:21)=amn                                                 ! Tamara
C	outfile(28:29)=amn                                                 ! Tamara
C	outfile(30:31)=ady                                                 ! Tamara
C	outfile(36:37)=ayr                                                 ! Tamara

      outf='/var/www/izmiran/ionosphere/weather/graf/'	 !Ljuba 41
      ile='dtc/yr/mn/ut/tcmndyut.jyr'                      !Ljuba 25  
      ile(5:6)=ayr	                 !Ljuba                          
	ile(8:9)=amn					 !Ljuba   						  
	ile(16:17)=amn					 !Ljuba   						  
	ile(18:19)=ady					 !Ljuba							  
	ile(24:25)=ayr	                 !Ljuba                           
      outfile=outf//ile  	             !Ljuba   

C      infile='d:\web\graf\TECI\YRMNDDt.txt'	!!!!!!!! JPLR-file-hourly  ! Tamara
C	infile(18:19)=ayr		  !                                        ! Tamara
C	infile(20:21)=amn		  !                                        ! Tamara
C	infile(22:23)=ady		  !                                        ! Tamara

      infile='/var/www/izmiran/ionosphere/weather/graf/TECI/YRMNDDt.txt'	!Ljuba
	infile(47:48)=ayr		  ! 									  !Ljuba
	infile(49:50)=amn		  ! 									  !Ljuba
	infile(51:52)=ady		  !										  !Ljuba

	iruns=24
 
	iutend=iruns
	 OPEN(20,FILE=INFILE)  ! ,ACTION='READ' Ljuba    
	ihr=0 
C+++++++++++++++++++++++++++++++++++++++++++++++++
C start cycle on hr-to-hr input:
   80	do i=1,600					             !!
	READ (20,187,END=33,ERR=2) txt,txt1
  187	format(A60,A16)
	if (txt1.eq.start) goto 88
	enddo									 !!
  88	continue
C Start of reading VTEC ========================
   	read (20,89,end=9,err=85) ryear,rmn,rdy,iut
CADD++++++++++++++++++++++++++++++++++++++++++++++++
	if (rdy(1:1).eq.' ') rdy(1:1)='0'
	if ((iut.lt.iut0).and.(rdy.eq.ady0)) goto 80  ! 
   89 format(2X,A4,4X,A2,4X,A2,4X,I2)
   85	continue
      rut=float(iut)
	call blet2(iut,AUT)	
C
C	outfile(32:33)=aut  ! true                                 ! Tamara     
	outfile(61:62)=aut  ! true								 !Ljuba

	if (rmn(1:1).eq.' ') rmn(1:1)='0'
 	if (rdy(1:1).eq.' ') rdy(1:1)='0'
	read (rdy,*) day
	idy=int(day)
C start cycle on glatitudes:
  	ilat=0
	glati=90.0
	nnlat=72
C
	DO 777 lat=1,71	   ! Start cycle on glati ++++++++++++++++++++++++++++++++
		ilat=ilat+1   ! ilat=1 for 87.5
	glati=glati-2.5
   87	read (20,90,end=9,err=2) glat,txt
   90	format(3X,F5.1,A60)
  91   	j1=0
C
C Add check of wrong TEC.le.0<=itec_pre +++++++++++++
C
	itec_pre=20	  ! assumed TEC_pre 
	do j=1,4        
	j1=(j-1)*16
   1	READ (20,180,END=9,ERR=2) (ixx(i),i=1,16)
  180	format(16(1X,I4))
	do k=1,16
	if ((ixx(k).le.0).or.(ixx(k).eq.9999)) then
	ixx(k)=itec_pre ! replace wrong TEC
	endif
	itxx(j1+k-1)=ixx(k)
	itec_pre=ixx(k)		! latest TEC_pre
	enddo
	enddo			  ! start selection of 4 longitudes
	READ (20,179,END=9,ERR=2) (ixx(i),i=1,9)
  179	format(9(1X,I4))
	do k=1,9
	if ((ixx(k).le.0).or.(ixx(k).eq.9999)) then
	ixx(k)=itec_pre ! replace wrong TEC
	endif
	itxx(63+k)=ixx(k)
	itec_pre=ixx(k)		! latest TEC_pre
	enddo

	nnlat=nnlat-1  ! Keep results for GLAT=87.5(-87.5) at nnlat=71(1)

C Select values for Long=-180,-165,...0,15,30,..,165,180!!!!!!!!!!!!:
C
	ii=-1
	 jj=71
C====================================================
	do il=-180,180,5     ! for long-cycle
	ii=ii+1					   ! ii=0 for glong=-180,...,ii=72 for glong=180
	ires=ii
	if (itxx(ii).lt.10) itxx(ii)=10 ! Replace TEC<1 by TEC=1 TECU (=0.1TECU)
	glong=float(il)
CC++		   
	itec(nnlat,ires)=itxx(ii)	! remember tec map
	enddo
  777	continue   ! End cycle of reading all GLATs
C
	READ (20,187,END=33,ERR=2) txt,txt1  ! END OF TEC MAP  ! Jan 2025
      write(*,187) txt,txt1  !							   ! Jan 2025
C
C Prepare output of results for nnlong=0,1,...,72
		OPEN(14,FILE=OUTFILE)
		DO nnlat=1,71
crem	write(*,182) (itec(nnlat,k),k=0,72)
	write(14,182) (itec(nnlat,k),k=0,72) !OUT of TEC hourly maps
	ENDDO
 182	format(73(1X,I4))							
	close(unit=14)
    9	continue
  
C Continue to the next UT hr :
  32		irun=irun+1 
 	ady0=rdy
	if (irun.lt.iutend) goto 80 ! continue to the next UT hr =>>>>
   33	close(unit=20)
	goto 35	   ! end of calculations
C
    2 CONTINUE
      if (irun.eq.0) then
       write(*,*) 'INPUT FILE IS NOT IN YOUR DIRECTORY '
C 	pause ' '            !!!!!!!!Ljuab
	goto 35
      endif
C   33 if ((iidy.le.idy2).and.(idy1.lt.idy2)) goto 32
   35      write(*,*) infile,outfile
   	write(*,*) irun
	 nndy=nndy+1
crem	if (nndy.le.im(mn)) then
crem	if (nndy.le.ndyend) then
crem	goto 1001
crem	endif
C      pause ' ' 
      RETURN
       END
C -----------------------------------------------------------
