      SUBROUTINE CEIL(NRM, IZW, KON, NZONC, IDBG)
C 
C  CEILING TEMPERATURES 
C 
C - - - PARAMETER CONSTANTS 
C 
CMDK NKONST
CMDK NWL
CMDK NWN
CMDK NZN
CMDK NZW
CMDK BLKQS
CMDK CNSTRK
CMDK ENCBK2
CMDK IZPART
CMDK MRTBLK
CMDK SURFAR
CMDK TCNBLK
CMDK TEMPB
C 
C  CEILING ENCLOSURE ELEMENT
      K=KON 
      IA=0
      NLM=NLMP(K) 
      IF(NZONC.GT.8)IA=3
      IF(NZONC.EQ.4)IA=1
      IF(NZONC.EQ.5)IA=2
C 
      IF(IA.EQ.0)STOP 'CEIL:NZONC NOT 4 OR 5 OR GT 8' 
      IF(IA.EQ.3)THEN 
C   CEILING IS PARTITION BETWEEN ZONES
C     NOTE:: CODE BELOW IS LIKE CODE IN IWALLS FOR PART. BETWN ZONES
          IZWO=IZSET(IZW) 
C   CEILING TEMPS ALREADY CALC IN ANOTHER ZONE? (YES IF IZWO LT IZW)
          IF(IZWO.LT.IZW)THEN 
              IF(NLM.EQ.1)THEN
                  TMPN(1,IZW)=TMPN(3,IZWO)
                  TMPN(2,IZW)=TMPN(2,IZWO)
                  TMPN(3,IZW)=TMPN(1,IZWO)
                  QRMRT(IZW)=QRMRT(IZWO)
                  GO TO 200 
                  ENDIF 
              IF(NLM.EQ.3)THEN
                  TMPN(1,IZW)=TMPN(4,IZWO)
                  TMPN(2,IZW)=TMPN(3,IZWO)
                  TMPN(3,IZW)=TMPN(2,IZWO)
                  TMPN(4,IZW)=TMPN(1,IZWO)
                  QRMRT(IZW)=QRMRT(IZWO)
                  GO TO 200 
                  ENDIF 
              ENDIF 
          ENDIF 
C 
C  CEILING TEMPERATURES 
C     MAKE SURE THAT LVG SPC ZONES ARE CALC BEFORE BSMT ZONE!!!!! 
C       OR ELSE HEAT FLOW AT LVG SPC SIDE OF BSMT CEILING WILL BE 
C       CALC WITH WRONG H AND QRFSUM VALUES 
      IF(NRM.EQ.NZNBAS)STOP 'CEIL:ENTER BSMT-ZONE DATA LAST'
      T1=TMP(1,IZW) 
      T2=TMP(2,IZW) 
      T3=TMP(3,IZW) 
      T4=TMP(4,IZW) 
      TC1=TCON(1,K) 
      TC2=TCON(2,K) 
      TC3=TCON(3,K) 
      TC4=TCON(4,K) 
      TC5=TCON(5,K) 
      TC6=TCON(6,K) 
      TC7=TCON(7,K) 
      TC8=TCON(8,K) 
C  QCEIL IS CALC IN TATTC;  ACEIL IS SET IN ROOFC 
C  QRFSUM IS CALC IN ROOFC. 
      TMPN(1,IZW)=TC1*(T2-T1)+TC2*(QCEIL(IA)/ACEIL(IA)
     +                          -QRFSUM(IA))+T1 
      TMPN(2,IZW)=TC3*(T1-T2)+TC4*(T3-T2)+T2
      TMPN(3,IZW)=TC5*(T2-T3)+TC6*(T4-T3)+T3
      QPRAD=HRI(IZW)*(TMR(NRM)-T4)
      TMPN(4,IZW)=TC7*(T3-T4)+TC8*(QCSURF(IZW)/AWALLA(IZW)+ 
     +            QPRAD)+T4 
      IF(IDBG.NE.0)THEN 
      WRITE(60,500)    NRM, IZW, KON, NZONC, QRFSUM(1),QRFSUM(2) 
      WRITE(60,501)IA,TATTA,T1,TMPN(1,IZW),T2,TMPN(2,IZW), 
     +T3,TMPN(3,IZW),T4,TMPN(4,IZW),
     +TC1,TC2,TC3,TC4,TC5,TC6,TC7,TC8 
      WRITE(60,502)QPRAD,HRI(IZW),TMR(NRM) 
      ENDIF 
      QRMRT(IZW)=QPRAD*AWALLA(IZW)
  200 CONTINUE
      RETURN
  500 FORMAT(20X,'CEIL:NRM,IZW,KON,NZONC= ',4I5/
     +20X,'QRFSUM(1-2)= ',2G13.5) 
  501 FORMAT(25X,'IA,TATTA= ',I5,2G13.5/
     +20X,'T1,T1N= ',2G13.5/
     +20X,'T2,T2N= ',2G13.5/
     +20X,'T3,T3N= ',2G13.5/
     +20X,'T4,T4N= ',2G13.5/
     +20X,'TC1= ',G13.5,' TC2= ',G13.5/ 
     +20X,'TC3= ',G13.5,' TC4= ',G13.5/ 
     +20X,'TC5= ',G13.5,' TC6= ',G13.5/ 
     +20X,'TC7= ',G13.5,' TC8= ',G13.5) 
  502 FORMAT(20X,'QPRAD,HRI,TMR= ',3G13.5)
      END 
