      program decomni
	character*50 infile1,infile2,outfile,outfiledy
	+,txt
	 character*2 AMN,ADY
	infile1='ace181130sw.txt'
	infile2='ace181130mb.txt'
	outfile='ace181130.res'
	outfiledy='omniswdy.txt'
	OPEN(11,file=infile1,action='READ')
	OPEN(12,file=infile2,action='READ')
	OPEN(10,file=outfile)
	OPEN(13,file=outfiledy,access='APPEND')
   31	format(A50)
C2018 12 01  0000   58453       0    0        4.2      303.9     2.29e+04
   32 format(I4,2(1X,I2),2X,I2,27X,F7.1,4X,F7.1,4X,F5.2,1X,F3.0)
   33 format(I4,2(1X,I2),2X,I2,32X,F7.1,9X,F7.1)
   	do i=1,18
	read(11,31) txt
	enddo
	do i=1,20
	read(12,31) txt
	enddo
C	 ndnr=334 ! 1 Dec -1
      ndnr=304 ! 1 Nov -1
    1	ndnr=ndnr+1
      if (ndnr.gt.335) goto 51 ! STOP
	sumsw=0.
	cntdy=0.
      DO 40 nut=0,23
      read(11,32,end=51) iyear,imn,idy,iut,den,vsw,tem,teme
	tem=tem*10.**teme
	if (vsw.gt.0.) then
	cntdy=cntdy+1.
	sumsw=sumsw+vsw
	endif
      if (tem.lt.0.) tem=9999999.
	if (den.lt.0.) den=999.9
	if (vsw.lt.0.) vsw=9999.
C
      read(12,33,end=52) kyear,kmn,kdy,kut,bz,bt
		if (bz.lt.-999.) then
		bz=999.9
	endif
	if (bt.lt.-999.) bt=999.9

	write(*,34) kyear,ndnr,kut,bt,bz,tem,den,vsw
	write(10,34) kyear,ndnr,kut,bt,bz,tem,den,vsw
   40	enddo
   34 format(I4,1X,I3,1X,I2,2(1X,F5.1),1X,F8.0,1X,F5.1,1X,F5.0)
      if (cntdy.gt.0.) vswdy=sumsw/cntdy
	call blet2(kmn,AMN)
	call blet2(kdy,ADY)
	 	write(*,35) kyear,AMN,ADY,vswdy
	write(13,35) kyear,AMN,ADY,vswdy
   35 format(I4,2A2,1X,F5.0)
      goto 1
   51 close(unit=11)
   52   close(unit=12)
	close(unit=10)
	close(unit=13)
	pause ' '
	stop
	END