      program avewuled
C.............................................................May 2022
C Aver WU (-1d) (+1d)
C Aver WL (-1d) (+1d)
C Aver WE (-1d) (+1d)
C Aver Wp (-1d) (+1d)
      CHARACTER*64 infile1,infile2,infile3,infile4,outfile,infpeak
	DIMENSION inwu(0:47),inwl(0:47),inwe(0:47),wpin(0:47)
C
      infile1='kwupjm.txt'
	infile2='kwlnjm.txt'
	infile3='kwerjm.txt'
	infile4='kwptjm.txt'
	outfile='avewuljm.txt'
	OPEN(10,file=outfile)
      OPEN(11,file=infile1,action='READ')
	OPEN(12,file=infile2,action='READ')
	OPEN(13,file=infile3,action='READ')
	OPEN(14,file=infile4,action='READ')
	infpeak='wulessn0kp3jm.dat'
      OPEN(15,file=infpeak,action='READ')
   29 format(1X,F8.3,1X,I3,3(1X,I2),1X,F4.1,3(1X,I3,1X,F6.2),1X,I3
     +,1X,I4)
   30 format(48(1X,I4))
   31 format(48(1X,F4.1))
C
       DO 177 iev=1,563
	read(15,29,end=27) ryear1,lda1,imn1,idy1,iut1,xkp,jtwu,wumax,jtwl
     +,wlmin,jtwe,wemax,ikpsum,ninp
C
      read(11,30,end=51) inwu
	read(12,30,end=52) inwl
	read(13,30,end=53) inwe
	read(14,31,end=54) wpin
	kwu1=0
      kwl1=0
	kwe1=0
	wp1=0.
	DO k=0,23
	kwu1=kwu1+inwu(k)
	kwl1=kwl1+inwl(k)
	kwe1=kwe1+inwe(k)
	wp1=wp1+wpin(k)
	ENDDO
	awu1=kwu1/2400.
	awl1=kwl1/2400.
	awe1=kwe1/2400.
	awp1=wp1/24.
C
	kwu2=0
      kwl2=0
	kwe2=0
	wp2=0.
	DO k=24,47
	kwu2=kwu2+inwu(k)
	kwl2=kwl2+inwl(k)
	kwe2=kwe2+inwe(k)
	wp2=wp2+wpin(k)
	ENDDO
	awu2=kwu2/2400.
	awl2=kwl2/2400.
	awe2=kwe2/2400.
	awp2=wp2/24.
C
C Output
C
       write(*,32) ryear1,lda1,imn1,idy1,iut1,xkp,awu1,awu2,awl1,awl2
	+,awe1,awe2,awp1,awp2,ikpsum,ninp
	 write(10,32) ryear1,lda1,imn1,idy1,iut1,xkp,awu1,awu2,awl1,awl2
	+,awe1,awe2,awp1,awp2,ikpsum,ninp
  177	CONTINUE
   32	format(1X,F8.3,1X,I3,3(1X,I2),1X,F4.1,8(1X,F6.2),1X,I3,1X,I4)
   27 close(15)
  51	close(11)
  52	close(12)
  53	close(13)
  54	close(14)
      close(10)
	pause ' '
	STOP
	END
