	subroutine subprobjvs9(AYR,AMN,IDY1,IDY2)
C.....................................................Dec. 2018
C Extract Vs index at geogr. lats (~ 9 mlats) at ranges of glongs for IONEX -180:5:180
C     (1) mlat < -70
C     (2) mlat -70:-50
C     (3) mlat -50:-30
C     (4) mlat -30:-10
C     (5) mlat -10: 10
C     (6) mlat  10: 30
C     (7) mlat  30: 50
C     (8) mlat  50: 70
C     (9) mlat  >= 70
C
C day-by-day calculation of pVs+ and pVs- and pVs total for 9 zones of mlat

C.....................................................Mar. 2013
C Probability of occurrence of W+ , W- storm
C produce counts of CWp=3 & 4, /5112 grids on map * 100% (Occur.%)
C produce counts of CWn=-3 & -4, /5112 grids on map * 100% (Occur.%)
C CWt=cwp+cwn
C
C JPL maps
C
C IONEX maps
C for glat=-87.5:2.5:87.5, glong=-180:5:165  (5113 grids)
C
C Input: maps of Vs-index: viMNDYUT.jYR files 
C             for glat=-87,5:2.5:857., glong=-180:5:180  
C
C
C
c from hourly IONEX maps
c
	DIMENSION IRESP(9,0:23),IRESN(9,0:23),DHR(0:71),IM(12)
C 
     +,IRES(9,0:23)
	+,dip(0:71)	! glats at glons -180:5:180
     +,cnttot(9),cntneg(9),cntpos(9),cntzon(9)
	 INTEGER*2 IYR,IMN,IDY,idy1,idy2,iut
	CHARACTER*64,infile,outfile,outfilep,outfilen,title
	CHARACTER*133 wpast(0:365),wwpos(0:365),wwneg(0:365),txt
	CHARACTER*2 AYR,AMN,AUT,ADY
	+,aa(24),bb
	CHARACTER*6 YRMNDY
	CHARACTER*4 AMEAN
      DATA IM/31,28,31,30,31,30,31,31,30,31,30,31/
	DATA aa/'00','01','02','03','04','05','06','07','08','09','10'
	+,'11','12','13','14','15','16','17','18','19','20','21','22','23'/
      data DIP/
     +   2.60,  1.75,  1.05,  0.45, -0.10, -0.61, -1.20, -1.79, -2.40
     +, -3.20, -3.65, -4.27, -4.94, -5.68, -6.50, -7.40, -8.45, -9.55
     +,-10.60,-11.47,-12.10,-12.18,-11.62,-10.37, -8.45, -6.00, -3.01
     +,  0.34,  3.34,  5.89,  7.97,  9.49, 10.50, 11.17, 11.46, 11.57
     +, 11.52, 11.37, 11.19, 10.92, 10.54, 10.05,  9.41,  8.73,  8.07
     +,  7.50,  7.20,  7.05,  7.03,  7.12,  7.29,  7.47,  7.65,  7.84
     +,  7.91,  7.93,  7.87,  7.76,  7.58,  7.47,  7.45,  7.52,  7.58
     +,  7.71,  7.68,  7.51,  7.25,  6.80,  6.20,  5.33,  4.47,  3.50/
C     +,  2.60/
C
	bb='UT'
	amean='mean'
	title='YYMMDD UT CNTNEG CNTPOS CNTTOT   TOT%   Vsp'

C start
c      WRITE(*,'(\A\)') ' ENTER YEAR OF INPUT FILE='
c      READ(*,'(A)') AYEAR
c//	AYEAR='2014'
c//	ayr=ayear(3:4)
	read(ayr,*) year
	iyr=int(year)
	if(int(year/4.)*4.eq.iyr) THEN 
	ndnr=366
	im(2)=29
	                          ELSE
	ndnr=365
	im(2)=28
	ENDIF
C
C  month
c//      WRITE(*,'(\A\)') ' ENTER MN OF INPUT FILE='
c//      READ(*,'(A)') AMN
	read(amn,*) rmn
	imn=int(rmn)
	iflag=0

c//      WRITE(*,'(\A\)') ' ENTER DY1 & DY2 ='
c//      READ(*,13) idy1,idy2
Crem	idy1=1
Crem	idy2=im(imn)
 13   FORMAT(I2)

CC CALCULATION OF DAYS OF YEAR	
      infile='d:\web\drs\YR\MN\viMNDYUT.jYR' ! JPL Vs index (glat & glong map)
  	infile(12:13)=ayr
	infile(15:16)=amn
  	infile(28:29)=ayr
	infile(20:21)=amn
      outfile='tvstocYR.txt'	!W-indices from W-maps geogr.coord.<oc>=occurrence
	outfile(7:8)=AYR
 	outfilep=outfile
	outfilen=outfile
	outfilep(1:1)='p'
	outfilen(1:1)='n'
   14	format(1X,A43)
C
  	OPEN(112,FILE=OUTFILE,access='APPEND')
	OPEN(113,FILE=OUTFILEP,access='APPEND')
	OPEN(114,FILE=OUTFILEN,access='APPEND')
 198	format(4X,A2,24(3X,A2),3X,A4)
C
	lda1=ndoy(iyr,imn,idy1)  ! day-of-year
	mndy=im(imn)
  130	format(A133)

	if((imn.eq.1).and.(iflag.eq.0)) then 

	write(112,198) bb,aa,amean
	write(113,198) bb,aa,amean
	 write(114,198) bb,aa,amean
      write(*,198) bb,aa,amean
	iflag=1

	endif
		goto 197 ! avoid read-re-write
C
C---------------------------------------------------
C read-re-write outfile for days from 1 to lda1-1:
	ncnt=0
	do 149 ipast=0,lda1-1
	do mm=1,9
	read(112,130,END=151,ERR=2) txt
	wpast(ipast)=txt
	YRMNDY=txt(1:6)
  151	read(113,130,END=152,ERR=2) txt
 	wwpos(ipast)=txt
  152	read(114,130,END=153,ERR=2) txt
 	wwneg(ipast)=txt
	if (yrmndy.eq.'      ') goto 149
	enddo
	ncnt=ncnt+1
  149	continue
  153 close(unit=112)
      close(unit=113)
	close(unit=114)
C
c  	OPEN(112,FILE=OUTFILE)
c	OPEN(113,FILE=OUTFILEP)
c	OPEN(114,FILE=OUTFILEN)
C re-write past data:
	do ipast=0,ncnt-1
	write(112,130) wpast(ipast)
cc	write(*,130) wpast(ipast)  ! test
	write(113,130) wwpos(ipast)
	write(114,130) wwneg(ipast)
	enddo
      close(unit=112)
      close(unit=113)
	close(unit=114)
CC  
  197 continue
c  	OPEN(112,FILE=OUTFILE,ACCESS='APPEND')
c	OPEN(113,FILE=OUTFILEP,ACCESS='APPEND')
c	OPEN(114,FILE=OUTFILEN,ACCESS='APPEND')

C
C  day-to-day cycle
C ========================================

       DO 500 idy=idy1,idy2
	lda=ndoy(iyr,imn,idy)  ! day-of-year
	call blet2(idy,ady)
	infile(22:23)=ady
c	if (idy.eq.idy1) then
c	infile(19:19)='c'		  ! last observaed file
c	else
c	infile(19:19)='a'         ! one day prediction file
c	endif
C
      do i=1,9
      do k=0,23
	ires(i,k)=0
	iresp(i,k)=0
	iresn(i,k)=0
	enddo
	enddo
C
C cycle on UT:
C -----------------------------------------------------
      DO 801 iut=0,23		! cycle on UT
	call blet2(iut,aut)
	infile(24:25)=aut
	OPEN(111,FILE=INFILE)
c
      do i=1,9
	cnttot(i)=0.       !!!new for W-map
	cntneg(i)=0.       !!!new for W-map
	cntpos(i)=0.       !!!new for W-map
         cntzon(i)=0.
	enddo

C ===== Input datafile 
      xlat=-90.0
 1311	DO 1799 jj=1,71	  ! glats= -87.5:2.5:87.5
      xlat=xlat+2.5
c	pause ' '
    1	READ (111,12,END=3,ERR=2) (DHR(k),k=0,71) ! W(longs=-180:5:175)
  12	FORMAT(72(1X,F4.0))
C
	DO k=0,71				! Cycle on Longi	 <<<<<<<<
C
C Determine MLAT zone:
C
         iz=0
	if (xlat.lt.dip(k)-70.0) iz=1
      if ((xlat.ge.dip(k)-70.0).and.(xlat.lt.dip(k)-50.0)) iz=2
	if ((xlat.ge.dip(k)-50.0).and.(xlat.lt.dip(k)-30.0)) iz=3
	if ((xlat.ge.dip(k)-30.0).and.(xlat.lt.dip(k)-10.0)) iz=4
	if ((xlat.ge.dip(k)-10.0).and.(xlat.lt.dip(k)+10.0)) iz=5
	if ((xlat.ge.dip(k)+10.0).and.(xlat.lt.dip(k)+30.0)) iz=6
	if ((xlat.ge.dip(k)+30.0).and.(xlat.lt.dip(k)+50.0)) iz=7
	if ((xlat.ge.dip(k)+50.0).and.(xlat.lt.dip(k)+70.0)) iz=8
	if (xlat.ge.dip(k)+70.0) iz=9
	cntzon(iz)=cntzon(iz)+1. ! Roral number of grids in zones 1,...,9
C++	Count stormy indices W-:
	if (dhr(k).lt.-2) then 
      cntneg(iz)=cntneg(iz)+1.  !!!new for W map
	cnttot(iz)=cnttot(iz)+1.  !!!new for W map
	 endif
C++	Count stormy indices W+:
		if (dhr(k).gt.2) then 
      cnttot(iz)=cnttot(iz)+1.  !!!new for W map
	cntpos(iz)=cntpos(iz)+1.  !!!new for W map
	 endif

	enddo		    ! Cycle on Longi	 >>>>>>>>>>>>>


 1799	CONTINUE				   ! Cycle jj on glats (total W map)
  3   CLOSE(unit=111)

C----------------------------------------------------------
      DO i=1,9  
	cres=cnttot(i)/cntzon(i)*10000.
	cresp=cntpos(i)/cntzon(i)*10000.
	cresn=cntneg(i)/cntzon(i)*10000.
	ires(i,iut)=nint(cres) !prob*10000. = occur*100,%
	iresn(i,iut)=nint(cresn)
	iresp(i,iut)=nint(cresp)
	enddo
c   
  801 continue            ! end cycle on UT 

C  Daily mean:
C
       DO II=1,9
	sumt=0.
	sump=0.
	sumn=0.
		do m=0,23      ! cycle on UT		======
 175	sumt=sumt+float(ires(ii,m))
	sump=sump+float(iresp(ii,m))
	sumn=sumn+float(iresn(ii,m))
	enddo							 !=========
	isumt=nint(sumt/24.)
	isump=nint(sump/24.)
	isumn=nint(sumn/24.)
	yrmndy='000000'
	yrmndy(1:2)=AYR
	yrmndy(3:4)=AMN
	yrmndy(5:6)=ADY	
	write(*,72) yrmndy,(ires(ii,k),k=0,23),isumt,ii
 	write(*,72) yrmndy,(iresp(ii,k),k=0,23),isump,ii
 	write(*,72) yrmndy,(iresn(ii,k),k=0,23),isumn,ii
	write(112,72) yrmndy,(ires(ii,k),k=0,23),isumt,ii
		write(113,72) yrmndy,(iresp(ii,k),k=0,23),isump,ii
		write(114,72) yrmndy,(iresn(ii,k),k=0,23),isumn,ii
	ENDDO
C
  500	CONTINUE ! next day
C
  100	CONTINUE ! next	month
   72 format(A6,24(1X,I4),1X,I6,1X,I1)
	CLOSE(unit=112)
	CLOSE(unit=113)
	CLOSE(unit=114)
	goto 900
    2 CONTINUE
           write(*,*) 'INPUT FILE IS NOT IN YOUR DIRECTORY '
c      pause ' '
  900	RETURN
c//      STOP
      END

