      program anetwupcdmm
C................................................................Aug. 2022
C..Extract daily Intensity of pos Ip (W=2,3,4) and neg In (W=-2,-3,-4) from UPC 15mm maps
C UPC 15mm indices based on -15d median 	from 1999.12 to 2022
C
		CHARACTER*2 AMN,ADY,AYR,SYR,SMN,SDY
			CHARACTER*4 AYEAR
	CHARACTER*64 infilep,infilen,outfile,txt
	DIMENSION IM(12),inw(0:96),ipw(0:96)
            DATA IM/31,28,31,30,31,30,31,31,30,31,30,31/
C
        infilep='d:\web\graf\datu\apwYYmm.txt'   !  
 	infilen='d:\web\graf\datu\anwYYmm.txt'   !  
      outfile='uwdavpn.txt'
	OPEN(10,file=outfile)
C
	DO 41 iyear=1996,2022
C	write(*,*) ' Enter iyear:'
C	read(*,*) iyear
	call blet4(iyear,AYEAR)
	iyr=iyear-iyear/100*100
	AYR=AYEAR(3:4)
	infilep(21:22)=AYR
      OPEN(11,file=infilep,action='READ')
	read(11,*) txt
	infilen(21:22)=AYR
      OPEN(12,file=infilen,action='READ')
	read(12,*) txt
C
	z1=iyear/4.0
      jz=int(z1)*4

      IF(jz.EQ.iyear) THEN
               IM(2)=29
	dnr=366.
        ELSE
                IM(2)=28
	  	dnr=365.
	       ENDIF
C
       del=1./dnr
        imn1=1
	imn2=12
	if (iyear.eq.2022) imn2=7 !TEMPPPPPPPP
	if (iyear.eq.1996) imn1=12
C
       DO 101 imn=imn1,imn2
C
	call blet2(imn,AMN)
       imndy=im(imn)

	DO 100 idy=1,imndy
	call blet2(idy,ADY)
	lda=ndoy(iyr,imn,idy)
	xyear=iyear+del*(lda-1)
	 read(11,33,end=153) SYR,SMN,SDY,(ipw(k),k=0,95),ipav
       read(12,33,end=154) SYR,SMN,SADY,(inw(k),k=0,95),inav
	if ((SYR.eq.AYR).and.(SMN.eq.AMN).and.(SDY.eq.ADY)) then
	write(*,32) xyear,lda,AMN,ADY,ipav,inav
	write(10,32) xyear,lda,AMN,ADY,ipav,inav
	endif
  100	Continue
  101	CONTINUE
  153 close(11)
  154 close(12)
   32	format(1X,F8.3,1X,I3,2(1X,A2),2(1X,I3))
   33 format(3A2,96(1X,I4),2X,I4)
C
   41 continue
	pause ' '
	STOP
	END