      program Vsw500d100
C...............................................Oct. 2019
C Extract days with Vsw >=500 km/s at DeltaVsw >=100 during 3 prec days
C to select High Speed Streams, days
C
      dimension vsw3(0:4)
      character*50 infile,outfile,txt
      character*2 AMN,ADY,AUT
	character*4 AYEAR

	infile='d:\apkp\OMNI\swYEAR.txt'
Crem	outfile='Vsw500d10.txt'	 ! 
	outfile='Vswd20.txt'	 ! 
C
   30	format(A50)
c2011 364  1   8.3  -0.5   12859.   4.9  406.
  31	format(I4,1X,I3,1X,I2,28X,F5.0)
	OPEN(11,file=outfile)
C
       icnt=0
	icnt500=0
	icnt700=0
C
	do i=0,4
	vsw3(i)=400.0
	enddo
        vswmin_pre=300.0
	vsout_pre=300.
	vs_3d=0
      DO 44 iyear=2011,2019
	call blet4(iyear,AYEAR)
	infile(16:19)=AYEAR
	iyr=iyear-iyear/100*100
C
	OPEN(10,file=infile,action='READ')
C
	do i=1,13
	read(10,30) txt ! extra lines
	enddo
C
	ryear=float(iyear)
		if(int(ryear/4.)*4.eq.iyear) THEN 
	ndnr=366
	                          ELSE
	ndnr=365
	ENDIF
C
C day-to day cycle
C
	DO lda=1,ndnr		 !++++++++
	call submmdd(lda,iyr,imn,idy)
	call blet2(imn,AMN)
	call blet2(idy,ADY)
	vsmax=0.
        do iut=0,23		   !==========
	call blet2(iut,AUT)
	  read(10,31,end=50) kyear,kday,kut,vsw
	if (vsw.gt.999.9) vsw=vswmin_pre
	do i=0,3
	vsw3(i)=vsw3(i+1)
	enddo
	vsw3(4)=vsw
	vsmin=minval(vsw3)
	delvsw=vsw-vsmin
	if (vsmax.lt.vsw) vsmax=vsw
C
	vswmin_pre=vsw
        enddo				  !==========
C+	if ((vsmax.ge.500.).and.(vsmax.gt.vsout_pre)) then
Crem	if ((vsmax.ge.500.).and.(delvsw.gt.100.)) then
Crem	if ((vsmax.ge.500.).and.(delvsw.gt.30.)) then
Crem	if ((vsmax.ge.500.).and.(delvsw.gt.20.)) then
Crem	if ((vsmax.ge.500.).and.(delvsw.gt.10.)) then
	if (delvsw.gt.20.) then
	icnt=icnt+1
      if ((vsmax.ge.500.).and.(vsmax.lt.700.)) icnt500=icnt500+1
	if (vsmax.ge.700.) icnt700=icnt700+1
	write(*,32) icnt,iyr,AMN,ADY,vsmax
	write(11,32) icnt,iyr,AMN,ADY,vsmax
	vsout_pre=vsmax
	                     else
      vsout_pre=vsmax
   32 format(1X,I4,1X,I2,2(1X,A2),1X,F6.0)
      endif

	ENDDO	   !++++++++
C
   50 close(unit=10)
   44 CONTINUE
      write(*,33) icnt500,icnt700
	write(11,33) icnt500,icnt700
   33 format(2(1X,I4))
       close(unit=11)
      pause ' '
	STOP
	END