      SUBROUTINE HBKFACT(T) 
C ROUTINE TO CALCULATE HANDBOOK FACTORS AT THE END OF EACH DAY OF 
C SIMULATION. AND TO ACCUMULATE THEM FOR THE TOTAL RUN
C  REF:  SEE REF NO. 3 ON FILE \HII\SCR\S2.DOC AND 
C        ASHRAE 1988 EQUIPMENT HANDBOOK, P. 24.8 TO 24.17
C        FOR MORE INFORMATION ABOUT HANDBOOK FACTORS AND DATA 
C        ON TAPES 25 AND TAPES33-37
C TAPE25 IS THE REFERANCE NET LOAD FILE. WRITE IF HBKRNL=0               
C                                        READ  IF HBKRNL.NE.0 
CMDK NHBK
CMDK HANDBK
      CHARACTER*80 NAME(30) 
      DOUBLE PRECISION T
      LOGICAL FIRST,I25F,I32F,I37F
      REAL HBKOUT(30) 
      REAL MGF,NL,ILF,LMF,LRC(3),CRF(3),CMSI(3) 
      DATA LRC/1.0, 3.0, 5.0/, FIRST/.TRUE./
      DATA I25F,I32F,I37F/.TRUE.,.TRUE.,.TRUE./
100   IF(FIRST)GOTO 800 
      HBKOUT(01)=HBK(1) 
      FO1=HBK(1)
      HBKOUT(02)=HBK(2) 
C      FO2=HBK(2)
      HBKOUT(03)=HBK(3) 
C      FO3=HBK(3)
      HBKOUT(04)=HBK(4) 
      PEI=HBK(4)
      HBKOUT(05)=HBK(5) 
      AEI=HBK(5)
      TEI=PEI+AEI 
      HBKOUT(06)=TEI
      DENOM=TEI 
      IF(TEI.EQ.0.0)DENOM=1.0E10
      FE=FO1/DENOM
      HBKOUT(07)=FE 
      HBKOUT(08)=FO1
      DI=FO1
      HBKOUT(09)=HBK(6) 
      DO=HBK(6) 
      DENOM=DI
      IF(DI.EQ.0.0)DENOM=1.0E10 
      DE=DO/DENOM 
      HBKOUT(10)=  DE 
      HDE=FE*DE 
      HBKOUT(11)=  HDE
      HBKOUT(12)=HBK(7) 
      THD=HBK(7)
      DENOM=DO
      IF(DO.EQ.0.0)DENOM=1.0E10 
      MGF=THD/DENOM 
      HBKOUT(13)=  MGF
      SE=HDE*MGF
      HBKOUT(14)=  SE 
      RNL=HBKRNL
      HBKOUT(15)=  RNL
      HBKOUT(16) = THD
      NL=THD
      IF(RNL.EQ.0)THEN
C            WRITE DATA FOR RNL ON TAPE25      
        RNL=NL 
        IF(I25F)THEN
          I25F=.FALSE.
          OPEN(25,FILE='TAPE25',STATUS='NEW',IOSTAT=IO25)
C    FOLLOWING THREE LINES ADDED BY RDF   3/11/91 !!!!!          
          IF(IO25.NE.0)THEN
            OPEN(25,FILE='TAPE25',STATUS='OLD')
          ENDIF
        ENDIF
        WRITE(25,*)RNL 
      ELSE
C          READ DATA FOR RNL ON TAPE25      
        IF(I25F)THEN
          I25F=.FALSE.
          OPEN(25,FILE='TAPE25',STATUS='OLD',IOSTAT=IO25)
C   FOLLOWING IF SEGMENT ADDED BY RDF  3/5/91  !!!!!!!          
          IF(IO25.NE.0)THEN
            OPEN(25,FILE='TAPE25',STATUS='NEW')
            RNL=NL
            WRITE(25,*)RNL
            CLOSE(25)
            OPEN(25,FILE='TAPE25',STATUS='OLD')
          ENDIF
C RNL - REFERENCE NET LOAD  (FROM A PREVIOUS RUN OF BASELINE CASE)          
        READ(25,*,END=910)RNL
        ENDIF 
      ENDIF
      SIL=NL-RNL
      HBKOUT(17)=  SIL
      DENOM=NL 
      IF(NL.EQ.0.0)DENOM=1.0E10
      ILF=SIL/DENOM 
      HBKOUT(18)=  ILF
      LMF=1.0-ILF 
      HBKOUT(19)=  LMF
      SI=SE*LMF 
      HBKOUT(20)=  SI 
      DENOM=PEI
      IF(PEI.EQ.0.0)DENOM=1.0E10 
      AER=AEI/DENOM 
      HBKOUT(21)=  AER
      DO 210 I=1,3
      II=18+3*I 
      HBKOUT(II+1)=  LRC(I) 
      CRF(I)=(1.0+AER)/(1.0+LRC(I)*AER) 
      HBKOUT(II+2)=  CRF(I) 
      CMSI(I)=SI*CRF(I) 
210   HBKOUT(II+3)=  CMSI(I)
C 
C           PRINT OUT RESULTS 
C 
      IF(I32F)THEN
        I32F=.FALSE.
        OPEN(32,FILE='TAPE32',STATUS='NEW')
      ENDIF
      WRITE(32,1000)T,
     +     (I,NAME(I)(1:10),HBKOUT(I),NAME(I)(11:80),I=1,30)
1000  FORMAT('1HANDBOOK FACTORS ',8X,'(TIME=',F13.7,'):'//
     +(' FACTOR NUMBER ',I2,') ',A10,F20.5,A60) ) 
      IF(I37F)THEN
        I37F=.FALSE.
        OPEN(37,FILE='TAPE37',STATUS='NEW')
      ENDIF
      WRITE(37,1010)(HBK(I),I=1,7)
1010  FORMAT(7F18.5)
C 
      RETURN
910   STOP 'SUB.HBK: EOF ON T25'
C 
C-------------------------------------------------------------------- 
C  FIRST TIME THROUGH, SET UP THE OUTPUT FILE 
C 
800   CONTINUE
      NAME(1)=
     +'FO1..(BTU) FURNACE OUTPUT = ENTHALPY CHANGE ACROSS FURNACE   ' 
      NAME(2)=
     +'FO2..(BTU) FURNACE OUTPUT = INPUT - FURNACE LOSSES           ' 
      NAME(3)=
     +'FO3..(BTU) FURNACE OUTPUT = ENERGY DELIVERED + DUCT LOSS     ' 
      NAME(4)=
     +'PEI..(BTU) PRIMARY ENERGY INPUT                              ' 
      NAME(5)=
     +'AEI..(BTU) AUXILIARY ENERGY INPUT                            ' 
      NAME(6)=
     +'TEI..(BTU) TOTAL ENERGY INPUT                                ' 
      NAME(7)=
     +'FE.....(%) FURNACE EFFICIENCY                                ' 
      NAME(8)=
     +'DI...(BTU) DUCT INPUT = FO1 (ABOVE)                          ' 
      NAME(9)=
     +'DO...(BTU) DUCT OUTPUT                                       ' 
      NAME(10)= 
     +'DE.....(%) DUCT EFFICIENCY                                   ' 
      NAME(11)= 
     +'HDE....(%) HEAT DELIVERY EFFICIENCY                          ' 
      NAME(12)= 
     +'THD..(BTU) TOTAL HEAT DELIVERY (TO CONDITIONED SPACE)        ' 
      NAME(13)= 
     +'MGF....(-) MISCELLANEOUS GAIN FACTOR                         ' 
      NAME(14)= 
     +'SE.....(%) SYSTEM EFFICIENCY                                 ' 
      NAME(15)= 
     +'RNL..(BTU) REFERENCE NET LOAD                                ' 
      NAME(16)= 
     +'NL...(BTU) NET LOAD                                          ' 
      NAME(17)= 
     +'SIL..(BTU) SYSTEM INDUCED LOAD                               ' 
      NAME(18)= 
     +'ILF....(-) INDUCED LOAD FACTOR                               ' 
      NAME(19)= 
     +'LMF....(-) LOAD MODIFICATION FACTOR                          ' 
      NAME(20)= 
     +'SI.....(%) SYSTEM INDEX                                      ' 
      NAME(21)= 
     +'AER....(-) AUXILIARY ENERGY RATIO                            ' 
      NAME(22)=
     +'LRC1.($/$) LOCAL RATIO OF ELECTRICITY TO GAS (BTU BASIS) =1.0' 
      NAME(23)= 
     +'CRF1...(-) COST RATIO FACTOR                                 ' 
      NAME(24)= 
     +'CMSI1..(%) COST MODIFIED SYSTEM INDEX                        ' 
      NAME(25)= 
     +'LRC2.($/$) LOCAL RATIO OF ELECTRICITY TO GAS (BTU BASIS) =3.0' 
      NAME(26)= 
     +'CRF2...(-) COST RATIO FACTOR                                 ' 
      NAME(27)= 
     +'CMSI2..(%) COST MODIFIED SYSTEM INDEX                        ' 
      NAME(28)= 
     +'LRC3.($/$) LOCAL RATIO OF ELECTRICITY TO GAS (BTU BASIS) =5.0' 
      NAME(29)= 
     +'CRF3...(-) COST RATIO FACTOR                                 ' 
      NAME(30)= 
     +'CMSI3..(%) COST MODIFIED SYSTEM INDEX                        ' 
      FIRST=.FALSE. 
      GOTO 100
      END 
