      program extroutir
C......................................................Nov. 2019
C extract IRI out foF2 (monthly x UT)
C
      DIMENSION fc(12,0:23)
	  CHARACTER*50 infile,outfile,txt
	CHARACTER*2 AYR,AMN,XX
	xx='19'
C
      infile='IRIout5865.txt' ! CCIR-IG=IRI
	outfile='resiri5865.txt'	 ! CCIR=IRI-Plas
	OPEN(10,file=infile,action='READ')
	OPEN(11,file=outfile)

	do i=1,45
	read(10,*) txt ! extra line
	if (i.eq.1) then
	write(11,*) txt
	endif
	enddo
C
   30 FORMAT(2X,I2,1X,I2,16X,F6.3)
   31 FORMAT(1X,3A2,24(F6.2))
C  Year cycle 1958:1965
	iyr=57
  	 DO ii=1,8
	iyr=iyr+1
	call blet2(iyr,AYR)
	do kk=1,12
	do kkk=0,23
	fc(kk,kkk)=0.
	enddo
	enddo
C  Month cycle 1...12
      DO imn=1,12
	call blet2(imn,AMN)

C UT cycle
      DO iut=0,23
	READ(10,30,end=50) kyr,kmn,fc(imn,iut)
	if (kyr.ne.iyr) pause ' '
	if (kmn.ne.imn) pause ' '
	ENDDO
	write(*,31) XX,AYR,AMN,(fc(imn,k),k=0,23)
      write(11,31) XX,AYR,AMN,(fc(imn,k),k=0,23)
	ENDDO	! month
C
        ENDDO ! year
   50 close(unit=10)
      close(unit=11)
	pause ' '
	STOP
	END   