      program extreuv
C........................................................Sep. 2016
C Extract EUV (1) 26 - 34 nm flux; (2) 0.1 - 50 nm flux 
	CHARACTER*90 OUTFILE1,OUTFILE2,infile
	CHARACTER*4 AYEAR
	CHARACTER*1 cc,ci
	CHARACTER*2 AYR,AMN,ADY
	 dimension im(12),rdat(16)
	DATA  IM/31,28,31,30,31,30,31,31,30,31,30,31/
C
	cc=';'
	infile='d:\apkp\euv\euvYEAR.txt'
  15	FORMAT(A4)
  16	FORMAT(A1)
  201	      WRITE(*,*)' ENTER year: '
		READ(*,15) AYEAR
	AYR=AYEAR(3:4)
	read(ayr,*) ryr
	iyr=int(ryr)
	if(int(ryr/4.)*4.eq.iyr) THEN 
	im(2)=29
	ndnr=366
	                          ELSE
	IM(2)=28
	ndnr=365
	ENDIF
C
	infile(16:19)=AYEAR
	outfile1=infile
	outfile1(20:)='-1.txt'
	outfile2=outfile1
	outfile2(21:21)='2'

	OPEN(10,file=infile,action='READ')
	OPEN(11,file=outfile1)
	OPEN(12,file=outfile2)
C
  202	read(10,16) ci
	if (ci.eq.cc) then
	goto 202
	else
	backspace(10)
	endif
C day-to-day cycle
	nn=0
      DO 222 lda=1,ndnr
	call submmdd(lda,iyr,imn,idy)
	call blet2(imn,AMN)
	call blet2(idy,ADY)

	read(10,*,end=223) rdat
	nn=nn+1
      lda1=int(rdat(3))
	if (lda1.eq.lda) then
	res1=rdat(15)
	res2=rdat(16)
	else
	res1=0.
	res2=0.
	endif
	write(*,17) AYEAR,AMN,ADY,lda,res1
	write(11,17) AYEAR,AMN,ADY,lda,res1
	write(*,17) AYEAR,AMN,ADY,lda,res2
	write(12,17) AYEAR,AMN,ADY,lda,res2
  222	continue
  223 close(unit=10)
   17	format(1X,A4,2A2,1X,I4,1X,1PE10.4)
      write(*,*) ayear,nn
      pause ' '
	stop
	END
