      program extwpmax
C
C..........................................................Aug. 2022
C extract D-o-y Wp max from TEC-Wp storms
C
      CHARACTER*120 infile,outfile,txt
	CHARACTER*4 AYEAR
	CHARACTER*2 AMN,ADY
	CHARACTER*8 DAY1,DAY2,DAY3
C
C      infile='d:\web\storm\tecstorm_geom.txt'
      infile='wpstorm'
C      infile1='wpyr'
C      infile2='wp'
	outfile='extwpmax.txt'
	OPEN(10,file=infile,action='READ')
C	OPEN(11,file=infile2,action='READ')
	OPEN(12,file=outfile)
c	DO i=1,8
c	read(10,*) txt
c	ENDDO
c   30	format(18X,A4,A2,A2,1X,I2,2X,F4.1)
   30	format(A8,I2,F4.1)
C
C    1	read(11,30,end=51) ayear,amn,ady,iut,wp
    1	read(10,*,end=51) day2,iut,wp
C    1	read(11,30,end=51)
	AYEAR=day2(1:4)
	AMN=DAY2(5:6)
	ADY=DAY2(7:8)
      read(ayear,*) ryear
	iyear=int(ryear)
	iyr=iyear-iyear/100*100
 		if(int(ryear/4.)*4.eq.iyear) THEN 
	ndnyr=366
	                          ELSE
	ndnyr=366
	ENDIF
      del=1./ndnyr
      read(amn,*) rmn
	imn=int(rmn)
      read(ady,*) rdy
	idy=int(rdy)
	lda=ndoy(iyr,imn,idy)
	xyear=ryear+del*(lda-1)
	write(*,31) xyear,lda,AMN,Ady,wp
	write(12,31) xyear,lda,AMN,Ady,wp
	GOTO 1
31	format(1X,F8.3,1X,I3,1X,2A2,1X,F4.1)
   51	close(10)
      close(12)
	pause ' '
	STOP
	END



