	Program Read_pcnpcs2
C...................................................Dec 2021
C Read PCS (North) & PCS (south) 
C
       DIMENSION wup(3,0:95),wln(3,0:95)
	 CHARACTER*64 infipcn,infipcs,outfile
	CHARACTER*2 AYR,ANN,CYR,CMN1
     +,CDY1,CMN2,CDY2,CMN3,CDY3
	CHARACTER*4 AYEAR
C
c	infile='d:\Arts\Storm\Shub\Data\testreadnn.txt'
	outfile='pcnpch13.txt'
	infipcn='d:\Apkp\PC\PCNYEAR'
	infipcs='d:\Apkp\PC\PCSYEAR'
C
   1     nn=13            !2000.07.15-17
C        nn=23            !2015.03.17-19
	call blet2(nn,ANN)
c	infile(33:34)=ANN
C
C-	OPEN(10,file=infile,action='READ')
C-	read(10,101) ayear,kmn,kdy,kut,kmm,isym,rfi
C-	close(unit=10)
        AYEAR='2000'

	kut=0   ! temp
	kmn=7
Crem	kdy=15
	kdy=17
C+	kdy=kdy+2 ! temp
C	kdy=kdy-1 ! temp
C
	AYR=AYEAR(3:4)
	read(AYR,*) ryr
	kyr=int(ryr)
      lda=ndoy(kyr,kmn,kdy)
C
	infipcn(15:18)=AYEAR
	infipcs(15:18)=AYEAR
      OPEN(11,file=infipcn,action='READ')
	OPEN(12,file=infipcs,action='READ')
C
      OPEN(14,file=outfile,access='APPEND')
C
  21  format(3A2,24(1X,F4.2))		   !TG
	DO kk=1,lda
	read(11,21,end=61) cyr,cmn1,cdy1,(wup(1,k),k=0,23)
	read(12,21,end=62) cyr,cmn1,cdy1,(wln(1,k),k=0,23)
	ENDDO
	read(11,21,end=61) cyr,cmn2,cdy2,(wup(2,k),k=0,23)
	read(12,21,end=62) cyr,cmn2,cdy2,(wln(2,k),k=0,23)
	read(11,21,end=61) cyr,cmn3,cdy3,(wup(3,k),k=0,23)
	read(12,21,end=62) cyr,cmn3,cdy3,(wln(3,k),k=0,23)
   61	close(unit=11)
   62	close(unit=12)
C
C Select output values:
C-      utout=kut+kmm/60.
      utout=float(kut)
C-	jn=kut*4-1
	jn=kut-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)
	write(*,102) ayear,cmn1,cdy1,utout,resu,resl
	write(14,102) ayear,cmn1,cdy1,utout,resu,resl
       jj=jj+1
C	utout=utout+0.25
	utout=utout+1.0
	   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)
	write(*,102) ayear,cmn2,cdy2,utout,resu,resl
	write(14,102) ayear,cmn2,cdy2,utout,resu,resl
       jj=jj+1
C	utout=utout+0.25
	utout=utout+1.0
	   if (utout.lt.24.0) then		 !4
	   goto 40
	                 else		 !4
         goto 39
	                 endif		 !4			      
	                                   else   !3
C	if (iflag.eq.3) then
C	      if (jj.lt.192) then          !5
	      if (jj.lt.48) then          !5
	      resu=wup(3,jn)
      	  resl=wln(3,jn)
	write(*,102) ayear,cmn3,cdy3,utout,resu,resl
	write(14,102) ayear,cmn3,cdy3,utout,resu,resl
       jj=jj+1
C	utout=utout+0.25
	utout=utout+1.0
	 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,2(1X,F6.3))
	end			