C........................................................Oct.2020
C Extract fixed TEC or Vs-index from JPLi 15-min files (1 x 1 deg)
C along selected longitute for total day: 
C longs=-179.5:1:179.5
C lats -89.5:1:89.5
C input TEC; D:\UTEC\YEAR\MN\tiMNDDUTMM.jYR> IONEXi files
C       Vs : D:\web\drs\YR\MN\vlMNDDUTMM.jYR index file
C output <tvGLATGLONG.jYR>
C 
      PROGRAM decodjpli1
C----------------------------------------------------------------
C
      integer itecr(180,96),ivsr(180,96)
     +,itec(360),ivs(360)
C
	CHARACTER*2 AYR,AMN,ADY,AUT,AMM
	CHARACTER*4 AGLON
	CHARACTER*5 AGLONG
      CHARACTER*128 INFILET,INFILEV,OUTFILET,outfilev
	CHARACTER(10) DD
      CHARACTER(10) TT
      CHARACTER(5) ZZ
C++
C
      ICALLS=0
	CALL DATE_AND_TIME(DATE=DD,TIME=TT,ZONE=ZZ)
      TT(5:)='      '
      WRITE(*,*) 'PC Date: Year,Month,Day = ',DD,'Time = ',TT
C
	glon=35.0  !selected longitude
	iglon=int(glon)
C
 	if (iglon.lt.0) then 
 	mglon=-iglon
	call blet3(mglon,AGLON)
	AGLONG(1:1)='-'
	AGLONG(2:4)=AGLON
	else
	call blet3(iglon,AGLON)
	AGLONG(1:1)='x'
	AGLONG(2:4)=AGLON
	      endif
C 
       WRITE(*,*) ' Enter YR: '
	read(*,*) AYR
	outfilet='tcGLON.jYR'
	outfilet(3:6)=AGLONG
	outfilet(9:10)=AYR
	outfilev=outfilet
	outfilev(1:2)='vi'
C
       WRITE(*,*) ' Enter MN: '
	read(*,*) AMN
   1       WRITE(*,*) ' Enter iDY1  or <0> for stop: '
	read(*,*) idy1
	if (idy1.eq.0) then
	pause ' '
	 stop 
	endif
C
C
   30 FORMAT(1X,2A2,1X,I2,1X,F6.1)
   31 FORMAT(360(1X,I4))
   32 FORMAT(96(1X,I4))
C
	OPEN(10,file=outfilet,access='APPEND')
	OPEN(13,file=outfilev,access='APPEND')
	WRITE(*,30) AYR,AMN,idy1,glon
	WRITE(10,30) AYR,AMN,idy1,glon
	WRITE(13,30) AYR,AMN,idy1,glon

	infilet='D:\UTEC\20YR\MN\tiMNDDUTMM.jYR'
	infilev='D:\web\drs\YR\MN\vlMNDDUTMM.jYR'
	infilet(11:12)=AYR
	infilet(14:15)=AMN
	infilet(19:20)=AMN
	infilet(29:30)=AYR
	infilev(12:13)=AYR
	infilev(15:16)=AMN
	infilev(20:21)=AMN
	infilev(30:31)=AYR
C
C day-to-day cycle
C       DO 40 idy=idy1,idy2
       idy=idy1
	CALL blet2(idy,ADY)
	infilet(21:22)=ADY
	infilev(22:23)=ADY
C
       nn=0           ! cnt hr,min for given day
C UT cycle
       DO 41 iut=0,23
	call blet2(iut,AUT)
	infilet(23:24)=AUT
	infilev(24:25)=AUT
C
C Min cycle
       DO 42 imm=0,45,15
c      imm=0
	nn=nn+1
	call blet2(imm,AMM)
	infilet(25:26)=AMM
	infilev(26:27)=AMM

	OPEN(11,file=infilet,action='READ')
	OPEN(12,file=infilev,action='READ')
C
      xlat=-90.5
c-	coglat=90.0-glat
	coglon=360.-glon
C lati cycle
	DO nlat=1,180
	xlat=xlat+1.0
	coxlat=90.0-xlat
	read(11,31,end=45) itec
	read(12,31,end=46) ivs
C-	if (abs(coxlat-coglat).lt.0.5) then	!++
C
      xlon=-180.5
	DO nlon=1,360
	xlon=xlon+1.0
	coxlon=360.-xlon
	if (abs(coxlon-coglon).le.0.5) then  ! +++
C-	restec=itec(nlon)/10.
C-	iresvs=ivs(nlon)
      itecr(nlat,nn)=itec(nlon)
      ivsr(nlat,nn)=ivs(nlon)
C-	write(*,32) AYR,AMN,ADY,AUT,AMM,restec,iresvs
C-	write(10,32) AYR,AMN,ADY,AUT,AMM,restec,iresvs
      exit
	endif					! +++
	ENDDO   ! long cycle
C
C-      exit
C-	 endif !++
	ENDDO	  ! lat cycle
   45	 close(unit=11)
   46		 close(unit=12)
   42 CONTINUE	   ! min cycle
   41 CONTINUE		 ! UT cycle
      do ilat=1,180
		write(*,32) (itecr(ilat,k),k=1,96)
	write(10,32) (itecr(ilat,k),k=1,96)
		write(*,32) (ivsr(ilat,k),k=1,96)
	write(13,32) (ivsr(ilat,k),k=1,96)
	enddo
   40 CONTINUE
	close(unit=10)
	close(unit=13)
	goto 1
C
   35      write(*,*) infilet,infilev,outfilet
      pause ' ' 
      STOP
       END

C***********************************************************
