      program readatm
C..............................................May 2022
	CHARACTER*64 infile
	+,outfile
      dimension ave(3),icnts(3)
	CHARACTER*8 yr1,yr2,yr3,yryr
	CHARACTER*4 AYEAR
	CHARACTER*2 AMN,ADY,AUT
	CHARACTER*10 yrmndy
C
      yr1='19581979'
      yr2='19802014'
	yr3='20152022'
	infile='d:\Data\Press\AtmYER1YER2.txt'
	outfile='d:\Data\Press\AtmYER1YER2c.txt'
       
	do 100 kyr=1,3
C
	yryr=yr1
	if (kyr.eq.2) yryr=yr2
	if (kyr.eq.3) yryr=yr3
	infile(18:25)=yryr
	OPEN(11,file=infile,action='READ')
      atmav=0.
	icnt=0
   1	read(11,*,end=50) yrmndy,dut,patm
      if (patm.gt.0.) then
	atmav=atmav+patm
	icnt=icnt+1
	endif
	goto 1
   50	close(11)
      aver=atmav/icnt
	ave(kyr)=atmav
	icnts(kyr)=icnt
	OPEN(11,file=infile,action='READ')
	outfile(18:25)=yryr
	OPEN(12,file=outfile)
   2	read(11,*,end=51) yrmndy,dut,patm
      if (patm.eq.0.)	patm=9918.397
	AYEAR=yrmndy(1:4)
	AMN=yrmndy(6:7)
	ADY=yrmndy(9:10)
	iut=int(dut)
	 call blet2(iut,AUT)
	read(AYEAR,*) ryear
	iyear=int(ryear)
	iyr=iyear-iyear/100*100
		z1=iyear/4.0
      jz=int(z1)*4
      IF(jz.EQ.iyear) THEN
	dnr=366.
		  ELSE
                dnr=365.
		       ENDIF
	del=1./dnr
       read(AMN,*) rmn
	imn=int(rmn)
	       read(ADY,*) rdy
	idy=int(rdy)
	lda=ndoy(iyr,imn,idy)
	xyear=ryear+(lda-1)*del
	write(*,30) xyear,lda,amn,ady,aut,patm
	write(12,30) xyear,lda,amn,ady,aut,patm
   30	format(1X,F8.3,1X,I3,3(1X,A2),1X,F8.1)
      goto 2
   51 close(11)
      close(12)
  100	CONTINUE
       avertot=0.
	icntot=0
      do kk=1,3
	avertot=avertot+ave(kk)
	icntot=icntot+icnts(kk)
	enddo
	averfin=avertot/icntot
	write(*,*) icntot,averfin
	pause ' '
	STOP
	END
