      SUBROUTINE TBZONE(AIRMAS,FLOC,FLOW11,QBASFT,QBWAG,QBWBGT,
     +QDCTZF,QFLBAS,QFRLFE,QINCB,QINFB,QINFC,QINFS,QINT,QIZFRNB,
     +QNT,QPARTB,QRADCB,QRETB,QSUMB,QSUMB1,QSUMB2,QIZONB,TBAS,
     +TBASN,TIMN,TIN,IDBG)
C
C  COMPUTE ZONE AIR TEMPERATURE
C
C  RQINT(NZN)  RATIO OF QINT FLOWING TO THIS ZONE
C
C - - - CONSTANTS
CMDK BTUKWH
CMDK CPAIR
CMDK FTR
CMDK NZN
CMDK NIWL
CMDK NKONST
CMDK NWL
CMDK NWN
CMDK NZW
CMDK NZN7
CMDK RHOAIR
CMDK BAR
CMDK BLKFMT
CMDK BLKQGS
CMDK BLKQS
CMDK BLKGS2
CMDK BLKRAD
CMDK CNSTRK
CMDK DUCTS1
CMDK DUCTS4
CMDK EBALA
CMDK ENCBK1
CMDK ENCBK2
CMDK ENCBLK
CMDK INDIC1
CMDK IZZQ
CMDK MRTBLK
CMDK MZON1
CMDK OWETHR
CMDK QIZNB
CMDK QUAYLE
CMDK SOILB
CMDK SOLARB
CMDK STRUCA
CMDK SURFAR
CMDK TEMPB
CMDK TEMP1
CMDK TIMEB
CMDK TSTATC
CMDK TSTB2
CMDK TSTB4
C
C - - - DIMENSIONS
      INTEGER FLOC(NZN7)
      REAL AIRMAS(NZN), QINFC(NZN), QINFS(NZN), TIN(NZN)
      LOGICAL FIRST,IFN
      CHARACTER*125 FRMT
C
      DATA FIRST/.TRUE./
      IDBGSV=IDBG
C     IF(TIME.GT.0.35)IDBG=1
C     IF(TIME.GT.16.57.AND.TIME.LE.16.64)IDBG=1
C     IF(TIME.GT.17.80)IDBG=1
      IF(.NOT.FIRST)GO TO 2
      RHOBT=RHOAIR*BARRAT*(70.+FTR)
      FIRST=.FALSE.
    2 CONTINUE
      CALL ZERV(9,QBWAG,QSUMB2,QPARTB,QBASFT,QBWBGT,QRADPQ,QRADAQ,
     +            QRADFQ,QRADBQ,0.)
C
      SMA=0.
      SMTA=0.
      NRM=NZNBAS
      TBAS=TI(NRM)
      IFN=.FALSE.
      IF(ICTRLZ(NRM).EQ.1.AND.IEFAN.EQ.1)IFN=.TRUE.
      IF(HIBLWR.EQ.0.)IFN=.FALSE.
      IZWQ=0
      IZWR=0
C  M CP OF ROOM AIR
      AIRMAS(NRM)=RHOBT/(TBAS+FTR)*ROMVOL(NRM)/DTIME
      CPMASS=CPAIR*AIRMAS(NRM)
C  SET HEAT FLOW ASSOCIATED WITH INTERZONE AIR FLOWS
      QIZONB=QIZN(NRM)-QIZONS(NRM)+QIZFRNB
      N2=NWALLA(NRM)
C
      DO 10 K2=1,N2
      IZW=NENC(NRM,K2)
      KON=KONSTA(IZW)
      NLM=NLMP(KON)
      ID=IDEXP(IZW)
      NZONC=NZNC(IZW)
      NZON=NZONC-8
      IF(ID.EQ.5)THEN
C  BSMT CEILING - - - - -
C     CEILING HEAT FLOW IS QFLBAS, WHICH IS CALC IN TAZONE
C     RADIANT INTERCHANGE WITH BSMT CEILING IS QRADCB(CALC IN TAZONE)
         SMA=SMA+AWALLA(IZW)
         SMTA=SMTA+AWALLA(IZW)*TMP(3,IZW)
         ENDIF
      IF(ID.EQ.7)THEN
C - - - -PARTITION HEAT FLOW
C           DOUBLE AREA IF SUBMERGED ENCLOSURE ELEMENT
          XR=1.
          IF(NZON.EQ.NRM)XR=2.
          TWI=TMP(4,IZW)
          IF(NLM.EQ.1)TWI=TMP(3,IZW)
          HIWPC=HC(NRM,IZW,3,IFN,TWI,TBAS)
C  GET HIW TO USE WITH FURNITURE
          IF(XR.EQ.2)HIWPCS=HIWPC
          QPARTC=HIWPC*XR*AWALLA(IZW)*(TWI-TBAS)
          QCSURF(IZW)=QCSURF(IZW)-QPARTC/XR
          IF(IDBG.NE.0)WRITE(60,501)NRM,IZW,QPARTC,TWI,HIWPC
          SMA=SMA+XR*AWALLA(IZW)
          SMTA=SMTA+XR*AWALLA(IZW)*TWI
          QRADP=QRMRT(IZW)*XR
          QRADPQ=QRADPQ+QRADP
          QPARTB=QPARTB+QPARTC
          ENDIF
C  BASMT FLOOR
      IF(ID.EQ.8)THEN
          IZWQ=IZWQ+1
          TWI=TMP(4,IZW)
          IF(NLM.EQ.1)TWI=TMP(3,IZW)
          H3FBC=HC(NRM,IZW,7,IFN,TWI,TBAS)
          QBF=H3FBC*AWALLA(IZW)*(TWI-TBAS)
          QCSURF(IZW)=QCSURF(IZW)-QBF
          SMA=SMA+AWALLA(IZW)
          SMTA=SMTA+AWALLA(IZW)*TWI
          QBASFT=QBASFT+QBF
C  NOTE: QBASF VALUES ARE SUMMED FOR A FULL HOUR TO GET HRLY INTEG VAL
          QRADF=QRMRT(IZW)
          QRADFQ=QRADFQ+QRADF
          QBASF(IZWQ)=QBASF(IZWQ)+DTIME*(QBF+QRADF)
          ENDIF
      IF(ID.EQ.9)THEN
C  BELOW-GROUND BASEMENT WALL
          IZWR=IZWR+1
          TWI=TMP(4,IZW)
          IF(NLM.EQ.1)TWI=TMP(3,IZW)
          HIWBGC=HC(NRM,IZW,4,IFN,TWI,TBAS)
          QWF=HIWBGC*AWALLA(IZW)*(TWI-TBAS)
          QCSURF(IZW)=QCSURF(IZW)-QWF
          SMA=SMA+AWALLA(IZW)
          SMTA=SMTA+AWALLA(IZW)*TWI
          QBWBGT=QBWBGT+QWF
          QRADWB=QRMRT(IZW)
          QRADBQ=QRADBQ+QRADWB
          QBWBG(IZWR)=QBWBG(IZWR)+DTIME*(QWF+QRADWB)
              ENDIF
C  BASMT WALL ABV GROUND
      IF(ID.EQ.10)THEN
          TWI=TMP(4,IZW)
          IF(NLM.EQ.1)TWI=TMP(3,IZW)
          HIWAGC=HC(NRM,IZW,4,IFN,TWI,TBAS)
          QBWAGC=AWALLA(IZW)*HIWAGC*(TWI-TBAS)
          QBWAG=QBWAG+QBWAGC
          QCSURF(IZW)=QCSURF(IZW)-QBWAGC
          SMA=SMA+AWALLA(IZW)
          SMTA=SMTA+AWALLA(IZW)*TWI
          QRADWA=QRMRT(IZW)
          QRADAQ=QRADAQ+QRADWA
          ENDIF
   10 CONTINUE
C  GET FURNITURE HEAT EXCHANGE
      CALL FMASS(NRM,HIWPCS,TBAS,TFM,QCFM)
      QCFMQ(NRM)=QCFM
C  INITIAL VALUE OF QINFB IS RESET IN QIZSET EACH TIMESTEP!      
C  INFILTRATION DIRECTLY INTO BASEMENT DUE TO FURN OPERATION IS ADDED 
C  TO QINFB IN LOOP BEFORE CALL TO TBZONE.
      QINFB=QINFB+QINFC(NRM)-TI(NRM)*QINFS(NRM)
C
C - - -NET HEAT DELIVERY TO ZONE NRM FROM DUCTS
      QNTN=QNET(NRM)
      QNT=QNT+QNTN
C
C - - -SUM OF MISC HEAT FLOWS
C
C - - - - CONVECTION PORTION OF INTERNAL LOADS
          QINCB=QINT*(1.-RADINT)*RQINT(NRM)
C
      QSUMB1=QBWBGT+QBWAG
      QSUMB2=QPARTB+QBASFT+QINCB+QCFM
C
C - - -SUM OF HEAT FLOWS
      QFRLF=QFRLFE*FLOC(2)
C  QDCTZF IS HEAT FLOW UP THRU BSMT CEILING FROM SUPPLY DUCT HEAT LOSS
      QDCTZF=(QDUCTZ(2)-QRETB)*DCTFLR
      QDCTZ=(QDUCTZ(2)-QRETB)*(1.-DCTFLR)+QRETB
C  HERE TIMN SHOULD BE MEAN OF CONDITIONED ZONES!
      QRETBS=FLOW11*(TIMN-TBAS)*IBRP
      QSUMN=QSUMB1+QINFB+QFLBAS+QDCTZ+QNTN+QSUMB2+QFRLF+QIZONB+QRETBS
      QSUMB=QSUMN
C
C - - -AIR TEMP IN BASEMENT
      TIN(NRM)=QSUMN/CPMASS+TBAS
      TBASN=TIN(NRM)
      IF(IDBG.NE.0)THEN
          TIMP=TIME*60.
          TEMCMN=SMTA/SMA
          WRITE(60,500)TIMP,NRM,TBASN,TBAS,TMR(NZNBAS),TEMCMN
          FRMT='(10X,98H  QINFB     QNTN      QSUMB2    QIZONB    QFRLF
     +    QDCTZ     QRETBS    QPARTB    QFLBAS    QBASFT/10X,10F10.1)'
          CALL VZOUT(10,FRMT,QINFB,QNTN,QSUMB2,QIZONB,QFRLF,QDCTZ,
     +    QRETBS,QPARTB,QFLBAS,QBASFT)
          FRMT='(10X,63H  QBWBGT    QBWAG     QINCB    TI(1)    TI(2)
     +     TBAS  QCFM/10X,7F10.1/)'
          CALL VZOUT(7,FRMT,QBWBGT,QBWAG,QINCB,TI(1),TI(2),TBAS,QCFM,
     +                 DM1,DM2,DM3)
          WRITE(60,502)HIWPC,H3FBC,HIWBGC,HIWAGC
          ENDIF
      IF(TIME.GT.TMEBLS)THEN
         ETRM=QSUMB1+QFLBAS+QINFB+QSUMB2+QNTN+QDCTZ+QFRLF+QIZONB+QRETBS
         EBAL(NZNBAS)=EBAL(NZNBAS)+ETRM
         EBALT(NZNBAS)=EBALT(NZNBAS)+QNTN+QDCTZ
         ENDIF
C      LUMP CEILING Q INTO QSUMB2 RATHER
C      INTO QCEIL4, WHICH IS RESERVED FOR CEILING-TO-ATTIC Q
      QSUMB2=QSUMB2+QFLBAS+QIZONB
      QBASFT=QBASFT-QRADFQ
      QBWBGT=QBWBGT-QRADBQ
      QBWAG=QBWAG-QRADAQ
      QFLBAS=QFLBAS-QRADCB
      QPARTB=QPARTB-QRADPQ
      IDBG=IDBGSV
      RETURN
  500 FORMAT(/20X,'TBZONE:TIME(MIN),NRM,TBASN,TBAS,TMR,TEMCMN= '/
     +20X,F8.1,I5,4G13.5)
  501 FORMAT(/20X,'TBZONE:NRM,IZW,QPARTC,TWI,HIWPC= ',2I5,3G13.5)
  502 FORMAT(20X,'HIWPC,H3FBC,HIWBGC,HIWAGC= ',4G13.5)
  503 FORMAT(1X,'TBZONE:TIME,TBAS,TBASN,QIZONB= ',4G13.5)
      END
