      program formbrfht80
C.......................................................Aug 2019
C Form .br files from .txt Polyfit2 results for 0,1,...,23 UT for 80 stations
C
      dimension IM(12)
	character*128 infilef,infileh,infilem
	+,outfilef,outfileh,outfilem,txt       ! Aug 2019
      CHARACTER*2 ST,STS(80),AYR,AMN,ADY
C	common /BL1/xi,yi
      DATA IM/31,28,31,30,31,30,31,31,30,31,30,31/
      DATA STS/
     + 'as','at','bc','bp','br','cb','ch','cn','cq','cs'     ! July 2019
     +,'cw','cr','db','dw','eg','eb','gm','gr','gu','ha'	   ! July 2019
     +,'he','ho','jj','jm','jr','kk','lm','ml','mo','mq'	   ! July 2019
     +,'mw','nd','ni','ok','pe','pq','ps','rm','ro','vt'	   ! July 2019
     +,'sq','tv','tr','wk','wp','wz','mm','tk','kg','mg'	   ! July 2019
     +,'sd','rv','tz','ns','so','mb','ei','gg','if','tu'     ! July 2019
     +,'pa','fz','ff','kh','au','al','ga','nc','yg','ic'	   ! Sep 2019
     +,'mh','bb','bl','sv','lv','sj','sp','cj','er','ll'/	   ! Sep 2019
C
C
C      infilef='d:\web\dat1\YR\stYRMN.txt'                            ! AUG 2019
      infilef='d:\web\dat1\YR\stYRMN.dat'                            ! Sep 2019
C	infileh='d:\web\dat6\YR\stYRMNh.txt'                           ! AUG 2019
	infileh='d:\web\dat6\YR\stYRMNh.dat'                           ! Sep 2019
	infilem='d:\web\dat5\YR\stYRMNm.txt'                           ! July 2019
      WRITE(*,*) ' ENTER JYR and JMN FOR INPUT FILE='  ! July 2019
      READ(*,*) JYR,JMN                                ! July 2019
C    
	call blet2(jyr,AYR)
	call blet2(jmn,AMN)
	ryr=float(jyr)
	if(int(ryr/4.)*4.eq.jyr) THEN 
		im(2)=29
	                          ELSE
		IM(2)=28
	ENDIF
	ndmn=im(jmn)
C
C Input Poly coefficients
C
C Input data
C
	infilef(13:14)=AYR
	infilef(18:19)=AYR
	infilef(20:21)=AMN
	infileh(13:14)=AYR
	infileh(18:19)=AYR
	infileh(20:21)=AMN
	infilem(13:14)=AYR
	infilem(18:19)=AYR
	infilem(20:21)=AMN
	outfilef='d:\web\graf\2019\styrf.br'
	outfilef(15:16)=AYR
	outfilef(20:21)=AYR
	outfileh=outfilef
	outfileh(22:22)='h'
	outfilem=outfilef
	outfilem(22:22)='m'

   1  DO 1234 ist=1,80
C
       st=sts(ist)                                  ! July 2019
	infilef(16:17)=st								  ! July 2019
	infileh(16:17)=st								  ! July 2019
	infilem(16:17)=st								  ! July 2019
	outfilef(18:19)=st								  !Aug.2019
	outfileh(18:19)=st								  !Aug.2019
	outfilem(18:19)=st								  !Aug.2019
C
	OPEN(10,file=infilef,action='READ')
	OPEN(11,file=infileh,action='READ')
	OPEN(12,file=infilem,action='READ')
	OPEN(13,file=outfilef)
	OPEN(14,file=outfileh)
	OPEN(15,file=outfilem)
C
       DO k=1,4
	read(10,29,end=43) txt ! title line
	read(11,29,end=44) txt ! title line
	read(12,29,end=45) txt ! title line
	 ENDDO
C
   29 FORMAT(A128)
   30 FORMAT(3A2,2X,24(I3,A2))
   31 FORMAT(3A2,1X,24(I4,1X))
C
C Day-to-day cycle
C
	DO 10 jdy=1,ndmn
	call blet2(jdy,ADY)
C	read(10,30,end=43) CYR,CMN,CDY,(idatf(k),CF(k),k=0,23)
C	read(11,30,end=44) CYR,CMN,CDY,(idath(k),CH(k),k=0,23)
C	read(12,31,end=45) CYR,CMN,CDY,(idatt(k),k=0,23)
	read(10,29,end=43) txt
	write(13,29) txt
	read(11,29,end=44) txt
	write(14,29) txt
	read(12,29,end=45) txt
	write(15,29) txt
C
   10	CONTINUE			 ! next day
   43 close(unit=10)
   44 close(unit=11)
   45 close(unit=12)
   	close(unit=13)
 	close(unit=14)
 	close(unit=15)
C
 1234 CONTINUE     ! next st
C
C
	pause ' '
	END
C=========================================
