	Program Read_wuwlwems
C...................................................May 2021
C Read WU, WL,WE (regarding Shub TEC) 15min for storms 01...24 only for SC23 SC24 (nn=9,...,24)
C
       DIMENSION wup(3,0:95),wln(3,0:95),wer(3,0:95)
C	+,idat1(0:96),idat2(0:96),idat3(0:96)
C-	+,resu(0:191),resl(0:191),rese(0:191)
	 CHARACTER*64 infile,infiwu,infiwl,infiwe,outfile
	+,txt1,txt2,txt3
	CHARACTER*2 AYR,ANN,CYR,CMN1
     +,CDY1,CMN2,CDY2,CMN3,CDY3
	CHARACTER*4 AYEAR
C	+,CYEAR
C		CHARACTER*8 YYMMDD
C
	infile='d:\Arts\Storm\Shub\Data\testreadnn.txt'
	outfile='testwuxxwns.txt'
	infiwu='d:\web\graf\dats\wupYRmms.txt'
	infiwl='d:\web\graf\dats\wlnYRmms.txt'
	infiwe='d:\web\graf\dats\werYRmms.txt'

C
C	DO 50 nn=12,24            ! 15min for 2000-2017
C	DO 50 nn=20,24            ! 15min for 2000-2017
	DO 50 nn=9,10            ! 15min for 2000-2017
	call blet2(nn,ANN)
	infile(33:34)=ANN
C
	OPEN(10,file=infile,action='READ')
	read(10,101) ayear,kmn,kdy,kut,kmm,isym,rfi
	close(unit=10)
C
	AYR=AYEAR(3:4)
	read(AYR,*) ryr
	kyr=int(ryr)
      lda=ndoy(kyr,kmn,kdy)
C
	infiwu(21:22)=AYR
	infiwl(21:22)=AYR
	infiwe(21:22)=AYR
      OPEN(11,file=infiwu,action='READ')
	OPEN(12,file=infiwl,action='READ')
	OPEN(13,file=infiwe,action='READ')
	read(11,*) txt1
	read(12,*,end=5) txt2
c	goto 7
    5	continue
    7	read(13,*,end=6) txt3
c      goto 8
    6	continue

    8	outfile(9:10)=ANN
      OPEN(14,file=outfile)
C
  21  format(3A2,96(1X,F4.2),2X,I4)		   !TG
c  21  format(3A2,96(1X,I4),2X,I4)		   !TG
	DO kk=1,lda
	read(11,21,end=61) cyr,cmn1,cdy1,(wup(1,k),k=0,95),iwday
C	read(11,*,end=61) CYEAR,imn1,idy1,(idat1(k),k=0,96)
	ENDDO
	DO kk=1,lda
	read(12,21,end=62) cyr,cmn1,cdy1,(wln(1,k),k=0,95),iwday
C	read(12,*,end=66) CYEAR,imn1,idy1,(idat2(k),k=0,96)
	ENDDO
   66	DO kk=1,lda
	read(13,21,end=63) cyr,cmn1,cdy1,(wer(1,k),k=0,95),iwday
C	read(13,*,end=63) CYEAR,imn1,idy1,(idat3(k),k=0,96)
	ENDDO
C	do k=0,95
C	wup(1,k)=idat1(k)/100.
C	wln(1,k)=idat2(k)/100.
C	wer(1,k)=idat3(k)/100.
C	enddo
	read(11,21,end=61) cyr,cmn2,cdy2,(wup(2,k),k=0,95),iwday
C	read(11,*,end=61) CYEAR,imn2,idy2,(idat1(k),k=0,96)
	read(12,21,end=62) cyr,cmn2,cdy2,(wln(2,k),k=0,95),iwday
C	read(12,*,end=62) CYEAR,imn2,idy2,(idat2(k),k=0,96)
	read(13,21,end=63) cyr,cmn2,cdy2,(wer(2,k),k=0,95),iwday
C>>	read(13,*,end=63) CYEAR,imn2,idy2,(idat3(k),k=0,96)
C	do k=0,95
C	wup(2,k)=idat1(k)/100.
C	wln(2,k)=idat2(k)/100.
C	wer(2,k)=idat3(k)/100.
C	enddo
      read(11,21,end=61) cyr,cmn3,cdy3,(wup(3,k),k=0,95),iwday
C	read(11,*,end=61) CYEAR,imn3,idy3,(idat1(k),k=0,96)
	read(12,21,end=62) cyr,cmn3,cdy3,(wln(3,k),k=0,95),iwday
C>>	read(12,*,end=62) CYEAR,imn3,idy3,(idat2(k),k=0,96)
	read(13,21,end=63) cyr,cmn3,cdy3,(wer(3,k),k=0,95),iwday
C>>	read(13,*,end=63) CYEAR,imn3,idy3,(idat3(k),k=0,96)
C	do k=0,95
C	wup(3,k)=idat1(k)/100.
C	wln(3,k)=idat2(k)/100.
C	wer(3,k)=idat3(k)/100.
C	enddo
   61	close(unit=11)
   62	close(unit=12)
   63	close(unit=13)
C      cyr=cyear(3:4)
c	call blet2(imn1,cmn1)
c	call blet2(imn2,cmn2)
c	call blet2(imn3,cmn3)
c	call blet2(idy1,cdy1)
c	call blet2(idy2,cdy2)
c	call blet2(idy3,cdy3)
C
C Select output values:
      utout=kut+kmm/60.
	jn=kut*4-1
C
C      jj=0,192
       jj=0
	iflag=0
C?	j2=0
   39	iflag=iflag+1
      if (iflag.gt.1) then
	 jn=-1
	utout=0.0
	endif
   40	jn=jn+1
	if (iflag.eq.1) then			!1
      resu=wup(1,jn)
	resl=wln(1,jn)
	rese=wer(1,jn)
	write(*,102) ayear,cmn1,cdy1,utout,resu,resl,rese
	write(14,102) ayear,cmn1,cdy1,utout,resu,resl,rese
C      write(*,102) ayear,cmn1,cdy1,utout,resu
C	write(14,102) ayear,cmn1,cdy1,utout,resu
       jj=jj+1
	utout=utout+0.25
	   if (utout.lt.24.0) then		 !2
	   goto 40
	                 else		 !2
         goto 39
	                 endif		 !2			      
	else						 !1
	if (iflag.eq.2) then         !3
      resu=wup(2,jn)
	resl=wln(2,jn)
	rese=wer(2,jn)
	write(*,102) ayear,cmn1,cdy1,utout,resu,resl,rese
	write(14,102) ayear,cmn1,cdy1,utout,resu,resl,rese
c	write(*,102) ayear,cmn2,cdy2,utout,resu
c	write(14,102) ayear,cmn2,cdy2,utout,resu
       jj=jj+1
	utout=utout+0.25
	   if (utout.lt.24.0) then		 !4
	   goto 40
	                 else		 !4
         goto 39
	                 endif		 !4			      
	                                   else   !3
C	if (iflag.eq.3) then
	      if (jj.lt.192) then          !5
	      resu=wup(3,jn)
      	  resl=wln(3,jn)
            rese=wer(3,jn)
c	write(*,102) ayear,cmn3,cdy3,utout,resu
c	write(14,102) ayear,cmn3,cdy3,utout,resu
	write(*,102) ayear,cmn1,cdy1,utout,resu,resl,rese
	write(14,102) ayear,cmn1,cdy1,utout,resu,resl,rese
       jj=jj+1
	utout=utout+0.25
	 goto 40
	                    endif		 !5
	                                      endif !3
             endif                 !1
c	
      close(unit=14)
   50 CONTINUE                ! END tests files
      pause ' '
	stop
  20  format(i4,4(1x,i2.2),2x,f5.1,1x,i3,3x,4(3x,f7.2))
 100  format(1x,'Day Month Year      UT     SYM_H')
 101  format(1X,A4,4(1X,I2),1X,I4,1X,F6.3)
 102  format(1X,A4,2(1X,A2),1X,F5.2,3(1X,F6.3))
C 102  format(1X,A4,2(1X,A2),1X,F5.2,1X,F6.3)
	end			