      subroutine subpred45d(kYR,kMN,kDY)
C...............................................Feb. 2022
C 45d prediction SSN2 F107
C
      dimension IM(12)
      CHARACTER*64 outfile,infiles,infilef            
      CHARACTER(10) DD
      CHARACTER(10) TT
      CHARACTER(5) ZZ
	CHARACTER*4 AYEAR
	CHARACTER*2 AYR,AMN,ADY,BDY,BMN
	CHARACTER*48 product
	CHARACTER*30 titl
	DATA IM/31,28,31,30,31,30,31,31,30,31,30,31/
C
       product='  Product: 45 Day Forecast SSN2 F107 MSA45 Model'
       titl=' __YEAR___MN_DY___SSN2___F107_'
C      title='______________________________'
        outfile='predict45d.txt'
	OPEN(10,file=outfile)
      CALL DATE_AND_TIME(DATE=DD,TIME=TT,ZONE=ZZ)
      TT(5:)='      '
	AYEAR=DD(1:4)
	AYR=AYEAR(3:4)
	AMN=DD(5:6)
	ADY=DD(7:8)
	write(*,29) product
C		
	write(10,29) product
      WRITE(*,*) ' Issued: Year,Month,Day = ',AYEAR,' ',AMN,' ',ADY,' '
	+,'Time = ',TT
      WRITE(10,*) ' Issued: Year,Month,Day = ',AYEAR,' ',AMN,' ',ADY,' '
	+,'Time = ',TT
   28 format(A30)
   29 format(A48)
       read(ADY,*) rdy
	jdy=int(rdy)
	call blet2(jdy,ADY)
      read(AYR,*) ryr
	jyr=int(ryr)
      read(AMN,*) rmn
	jmn=int(rmn)
	jdy_pre=jdy-2
	jmn_pre=jmn
	jyr_pre=jyr
	if (jdy_pre.le.0) then
	jmn_pre=jmn-1
	if (jmn_pre.eq.0) then
	jmn_pre=12
	jyr_pre=jyr-1
	endif
	jdy_pre=IM(jmn_pre)+jdy_pre
	endif
c+      call blet2(jyr_pre,AYR)
C+	call blet2(jmn_pre,AMN)
C+      call blet2(jdy_pre,ADY)
      call blet2(kyr,AYR)
	call blet2(kmn,AMN)
      call blet2(kdy,ADY)
C
	write(*,28) titl
	write(10,28) titl
        infiles='ssnp45YYMMDDw.txt'
	infilef='covp45YYMMDDw.txt'
	infiles(7:8)=AYR
	infiles(9:10)=AMN
	infiles(11:12)=ADY
	infilef=infiles
	infilef(1:3)='cov'
	OPEN(11,file=infiles,action='READ')
	OPEN(12,file=infilef,action='READ')
	do 50 kk=1,45
	READ(11,30,end=51) ryear,kmn,kdy,fi,ssn
	READ(12,30,end=52) ryear,kmn,kdy,fi,cov
	call blet2(kmn,BMN)
      call blet2(kdy,BDY)
	write(*,31) ryear,bmn,bdy,ssn,cov
	write(10,31) ryear,bmn,bdy,ssn,cov
   50	continue
   51	close(unit=11)
   52	close(unit=12)
     	close(unit=10)
   30	format(1X,F8.3,2(1X,I2),2X,F7.4,1X,F6.2)
   31	format(1X,F8.3,2(1X,A2),2(1X,F6.1))
C
C
C+        pause ' '
	RETURN
C	STOP
	end
