      program cntvsw3h
C...............................................Oct.2019
C DelVsw >= 50                                  
C...............................................Jan. 2019
C Solar Wind speed Delta= Max(3h) - Min (-3h)
C cnt delVsw >0 delVsw(i)=Vswmax(3h_i)-Vswmin(-3h_i-1)
C to select High Speed Streams, HSS, with delVsw > 100 km/s  ! >= 50 km/s
C
      dimension vsw(3)
C?	+,pchs(2849),iyrs(2849,3)
      character*50 infile,outfile,outfihss,txt
      character*2 AMN,ADY,AUT
	character*4 AYEAR

	infile='d:\apkp\OMNI\swYEAR.txt'
	outfile='delvsw3h.txt'	 ! all min(-3h),max(+3h)+- delvsw 
C	outfihss='cnthss.res'
	outfihss='cnthss50.res'
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)
		OPEN(12,file=outfihss)
	vswmin_pre=348.				! min Vsw for the last 3h of prec. year (2010)
	nhss=0
C
      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
	DO lda=1,ndnr
	call submmdd(lda,iyr,imn,idy)
	call blet2(imn,AMN)
	call blet2(idy,ADY)
	delmax=0.
	vmax_hss=0.
	vmin_hss=0.
        do nut=0,7		   !==========
	iut=nut*3
	call blet2(iut,AUT)
	  read(10,31,end=50) kyear,kday,kut,vsw(1)
	if (vsw(1).gt.2000.0) vsw(1)=vswmin_pre
	read(10,31,end=50) kyear,kday,kut,vsw(2)
	if (vsw(2).gt.2000.0) vsw(2)=vswmin_pre
	read(10,31,end=50) kyear,kday,kut,vsw(3)
	if (vsw(3).gt.2000.0) vsw(3)=vswmin_pre
	vsmax=AMAX1(vsw(1),vsw(2),vsw(3))
	del=vsmax-vswmin_pre
	if (del.gt.delmax) then 
	delmax=del ! max delta for day
	vmax_hss=vsmax
	vmin_hss=vswmin_pre
	endif
	write(*,32) iyr,AMN,ADY,AUT,vswmin_pre,vsmax,del
	write(11,32) iyr,AMN,ADY,AUT,vswmin_pre,vsmax,del
   32 format(1X,I2,2(1X,A2),1X,A2,3(1X,F6.0))
	vswmin_pre=AMIN1(vsw(1),vsw(2),vsw(3))
	  enddo				  !==========
Crem	if (delmax.ge.100.) then 
	if (delmax.ge.50.) then 
		 nhss=nhss+1
	xyear=ryear+(float(lda)-1.)/float(ndnr)
	write(*,33) xyear,AMN,ADY,vmin_hss,vmax_hss,delmax,nhss
	write(12,33) xyear,AMN,ADY,vmin_hss,vmax_hss,delmax,nhss
   33 format(1X,F8.3,2(1X,A2),3(1X,F6.0),1X,I4)
	endif

	ENDDO
C
   50 close(unit=10)
   44 CONTINUE
       close(unit=11)
	 close(unit=12)
      pause ' '
	STOP
	END