      program extdstmin
C...............................................Dec. 2018
C
C extract days of Dst peaks 1957-2018
C cnt delpch >0 delpch(i)=Pch(i)-Pch(i-1)
C to produce histogram of delpch >0
C
      character*50 infile,outfile
      character*2 AMN,ADY,AUT

	infile='dststorm2.txt'
	outfile='dstmin.txt'	 ! dst peaks
	OPEN(10,file=infile,action='READ')
	OPEN(11,file=outfile)
   30 format(24X,2I2,2(1X,I2),1X,F5.0)
C
      DO 44 ii=1,1634
	read(10,30,end=50) iyr,iMN,iDY,iUT,dst
      lda=ndoy(iyr,imn,idy)
	ryr=float(iyr)
		if(int(ryr/4.)*4.eq.iyr) THEN 
	dnr=366.
	                          ELSE
	dnr=365.
	ENDIF
      delyr=1./dnr
	if (iyr.gt.50) then 
	ryear=1900.0
	else
	ryear=2000.0
	endif
	ryear=ryear+ryr+(lda-1)*delyr
	call blet2(imn,AMN)
      call blet2(idy,ADY)
	call blet2(idy,AUT)
	write(*,31) ryear,AMN,ADY,AUT,dst,ii
	write(11,31) ryear,AMN,ADY,AUT,dst,ii
C
   44 CONTINUE
   50 close(unit=10)
       close(unit=11)
   31 format(1X,F8.3,3(1X,A2),1X,F5.0,1X,I4)
      pause ' '
	STOP
	END