      program decodtoiwg
C
C......................................................................Jan 2020
C
C Decode foF2 monthly files to standard annual foF2 file
C
      DIMENSION IM(12)
	CHARACTER*120 text,infile,outfile,title
	CHARACTER*5 blank,blanks(24)
	CHARACTER*4 AYEAR
	CHARACTER*2	AMN,ST,AYR,CYR,CMN,CDY
	DATA IM/31,28,31,30,31,30,31,31,30,31,30,31/
       
	BLANK='    C'
	do i=1,24
	BLANKS(i)=blank
	enddo
C
 101	 write(*,*) 'Enter st name: '
	read(*,29) ST
 102	write(*,*) 'Enter YEAR: '
 	read(*,30) AYEAR
      AYR=AYEAR(3:4)
	read(AYEAR,*) ryear
	iyear=int(ryear)
 	z1=iyear/4.0
      jz=int(z1)*4

      IF(jz.EQ.iyear) THEN
               IM(2)=29
	ndnyr=366
        ELSE
                IM(2)=28
	  ndnyr=365
	       ENDIF


C+	infile='d:\web\graf\1997\CL97.txt'
	infile='d:\web\dat1\YR\stYRMM.txt'
	outfile='d:\data\iwg\ST\stYR'
	infile(16:17)=ST
	infile(13:14)=AYR
	infile(18:19)=AYR
	outfile(13:14)=ST
	outfile(16:17)=ST
	outfile(18:19)=AYR
C	CODE='CL424'
C?	UTIME='0000'
C
C?      AYR='94'
C foF2
	OPEN(13,file=outfile)
C
	DO 50 imn=1,12
C	AMN=blet2(imn)
      call blet2(imn,AMN)
	infile(20:21)=AMN
	OPEN(12,file=infile,action="READ")
      do i=1,4
	read(12,31,end=133) text
	if (i.eq.1) then 
	title=text
	title(47:50)=AYEAR
	title(52:53)=AMN
	write(*,31) title
	write(13,31) title
	endif
	enddo
	mndy=im(imn)
      do idy=1,mndy
	read(12,33,end=133) CYR,CMN,CDY,text
      write(*,31) text
	write(13,31) text
	enddo
  133	close(unit=12)
	if (mndy.eq.31) goto 49
	do iidy=mndy+1,31
	write(*,32) (blanks(k),k=1,24)
	write(13,32) (blanks(k),k=1,24)
	enddo
   49	DO kk=1,2
	write(*,32) (blanks(k),k=1,24)
	write(13,32) (blanks(k),k=1,24)
	enddo
C
   50	CONTINUE
	close(unit=13)
C
  29	format(A2)
  30	format(A4)
  34	format(A5)
  31	format(A120)
  33	format(3A2,2X,A120)
   32	format(24A5)
C
C
  131 FORMAT(3A2,2X,A120)
  330 FORMAT(24(I3,A2))
  331 FORMAT(3A2,2X,24(I3,A2))
C
   44	close(unit=10)
      close(unit=11)
	GOTO 101
	pause ' '
	STOP
	END