      SUBROUTINE OWALLS(NRM, IZW, ID, KON, WALLF, FAWLOD,
     +                  HO, TODBR4, IDBG) 
C 
C  TEMPERATURES IN OUTSIDE ENCLOSURE WALLS
C 
C - - - PARAMETER CONSTANTS 
C 
CMDK NZN
CMDK NIWL
CMDK NKONST
CMDK NWL
CMDK NWN
CMDK NZW
CMDK SIGMA      
C 
C - - - COMMON BLOCKS 
CMDK BLKBSF
CMDK BLKMMU
CMDK BLKQS
CMDK CNSTRK
CMDK ENCBLK
CMDK ENCBK1
CMDK ENCBK2
CMDK IWLS
CMDK IZWQ
CMDK MRTBLK
CMDK NIJB
CMDK OWETHR
CMDK SOILB
CMDK SOLARB
CMDK SURFAR
CMDK TCNBLK
CMDK TEMPB
CMDK TIMEB
CMDK TSTATC
CMDK UABAS
C 
      DATA FTR/459.7/,NQTM/0/
      
      IF(IGRND.GT.0.AND.NQTM.EQ.0.AND.ID.EQ.9)THEN
C         INITIALIZE BELOW GRND BSMT WALLS, IF IGRND > 0     
        NQTM=1
C         ASSUME HEAT FLOW/UNIT AREA IS SAME FOR EACH WALL SEGMENT 
C         SO USE IZW BELOW
        QSURF=QCSURF(IZW)/AWALLA(IZW)        
        DO 2 I=1,4
        IZ=IZWE(I)
        KONF=KONSTA(IZ)
        NLM=NLMP(KONF)
        TWI=TBASM - 5.
C              GET INITIAL VALUE OF INSIDE SURF WALL TEMP        
        CALL TWISET(4,QSURF,TBASM,TWI)
        TMID=0.5*(TSOIL(I)+TWI)
        TMP(1,IZ)=TSOIL(I)
        TMP(2,IZ)=TMID
        TMP(3,IZ)=TWI
        IF(NLM.NE.1)THEN
          TMP(4,IZ)=TWI
          TMP(3,IZ)=TMID+0.5*(TWI-TMID)
        ENDIF
    2   CONTINUE
      ENDIF
      K=KON 
      NLM=NLMP(K) 
C 
C  OUTSIDE WALL TEMPS 
      T1=TMP(1,IZW) 
      T2=TMP(2,IZW) 
      T3=TMP(3,IZW) 
      IF(NLM.EQ.3)T4=TMP(4,IZW) 
      IF(ID.EQ.9)THEN 
         QLSWLN=0.
      ELSE
         T14=(T1+FTR)**4
         FASIWE=FAWLOD*SIGMA*WALLF
         QLSWLN=FASIWE*(T14-TODBR4)*AWALLA(IZW) 
         ENDIF
      IF(ID.LE.4)THEN 
C  NOTE:  NIJA IS SET IN SOLRLD 
C         AND SEE NOTE ON IWALS IN STRRUN OR SOLRLD 
          IF(IWALS.EQ.1)THEN
             ISURF=NIJA(IZW)
          ELSE
             ISURF=NIJA(ID) 
             ENDIF
          TWO=(SOLARL(ISURF)-QLSWLN/AWALLA(IZW))/HO+TODDB 
      ELSE IF(ID.EQ.10)THEN 
C  NO SOLAR RADIATION SHINING ON ABOVE GROUND BASEMENT WALL!      
          TWO=TODDB - QLSWLN/AWALLA(IZW)/HO
          IZWK=IZW
          ENDIF 
      TC1=TCON(1,K) 
      TC2=TCON(2,K) 
      TC3=TCON(3,K) 
      IF(ID.EQ.9)THEN 
C                                BASEMENT WALL BELOW GROUND 
        IHIT=0
C   IZWE IS SET IN CONSLD ABOVE LABEL 134 
        DO 20 I=1,4 
          IF(IZWE(I).EQ.IZW)THEN
            IHIT=1
            IF(IGRND.EQ.0.OR.ICODE.EQ.1.OR.ICODE.EQ.4)THEN
              TMPN(1,IZW)=TSOIL(I)
C  NOTE:  HEAT FLOW TO SOIL WHEN YOU USE TSOIL OPTION W/ IGRND=0
C         WILL NOT BE INCLUDED IN QLOSWL FOR ENERGY BALANCE CALC.
C         THIS HEAT FLOW IS CALC IN ENRBALS FROM AVAIL DATA.
            ELSE
              IJ=I
              IF(I.GT.2)IJ=I+5
C                    CONDWL IS CALC IN SETNOD.FOR ON GROUND.FOR FILE
              QWALBG=CONDWL(I)*(TG(IJ)-T1)
              TMPN(1,IZW)=TC1*(T2-T1)+TC2*QWALBG+T1
C  QLOSWL(I) WAS ZEROED IN STRLP1 
              QLOSWL(NRM)=QLOSWL(NRM)-AWALLA(IZW)*QWALBG
            ENDIF
          ENDIF 
   20   CONTINUE
        IF(IHIT.EQ.0)STOP ' OWALLS: IZW NOT IN IZWE()!'
      ENDIF
      IF(ID.LE.4.OR.ID.EQ.10)THEN 
C            OUTSIDE WALLS OR    BASEMENT WALL ABOVE GROUND 
        QWALOC=HO*(TWO-T1)
C  FOR ID LE 4, QWALOC INCLUDES EFFECT OF SOLAR AND RADIATION LOSS        
C  FOR ID EQ 10, QWALOC INCLUDES RADIATION LOSS
        TMPN(1,IZW)=TC1*(T2-T1)+TC2*QWALOC+T1 
      ENDIF 
      IF(NLM.EQ.1)THEN
          TMPN(2,IZW)=0.5*TC1*(T1-2.*T2+T3)+T2
          IF(ICODE.EQ.1.OR.ICODE.EQ.4)THEN
            QSURF=QCSURF(IZW)/AWALLA(IZW)
            TWI=T3
            CALL TWISET(4,QSURF,TBASM,TWI)
            TMPN(3,IZW)=TWI
          ELSE
            QPRAD=HRI(IZW)*(TMR(NRM)-T3)
            QSURF=QCSURF(IZW)/AWALLA(IZW)+QPRAD
C  QCSURF IS MEAN CONVECTIVE HEAT FLOW CALC IN TAZONE OR TBZONE .
C  IT IS CALC IN TAZONE, TBZONE AND AVERAGED IN ENDLP1.
            TMPN(3,IZW)=TC3*(T2-T3)+TC2*QSURF+T3
          ENDIF
      ELSE
          TC4=TCON(4,K) 
          TC5=TCON(5,K) 
          TC6=TCON(6,K) 
          TC7=TCON(7,K) 
          TC8=TCON(8,K) 
          TMPN(2,IZW)=TC3*(T1-T2)+TC4*(T3-T2)+T2
          TMPN(3,IZW)=TC5*(T2-T3)+TC6*(T4-T3)+T3
          IF(ICODE.EQ.1.OR.ICODE.EQ.4)THEN
C                                 QCSURF IS SET IN BSMTPRE          
            QSURF=QCSURF(IZW)/AWALLA(IZW)
            TWI=T4
            CALL TWISET(4,QSURF,TBASM,TWI)
            TMPN(4,IZW)=TWI
          ELSE
            QPRAD=HRI(IZW)*(TMR(NRM)-T4)
C                                 QCSURF IS SET IN TBZONE            
            QSURF=QCSURF(IZW)/AWALLA(IZW) + QPRAD
            TMPN(4,IZW)=TC7*(T3-T4)+TC8*QSURF+T4 
          ENDIF
      ENDIF 
      QRMRT(IZW)=QPRAD*AWALLA(IZW)
      IF(IDBG.NE.0)THEN 
          WRITE(60,500)NRM, IZW,ID,KON, WALLF, FAWLOD,
     +                  HO, TODBR4,         QLSWLN
          IF(NLM.EQ.3)THEN
              WRITE(60,501)T1,TMPN(1,IZW),T2,TMPN(2,IZW),T3, 
     +        TMPN(3,IZW),T4,TMPN(4,IZW),AWALLA(IZW), 
     +        ISURF,IT,SOLARL(ISURF),DSOLAR(IT,ISURF),
     +        TODDB,TWO,TA(NRM),HO,
     +        TC1,TC2,TC3,TC4,TC5,TC6,TC7,TC8 
          ELSE IF(NLM.EQ.1)THEN 
              WRITE(60,503)T1,TMPN(1,IZW),T2,TMPN(2,IZW),T3,TMPN(3,IZW), 
     +                    AWALLA(IZW),TODDB,TA(NRM),HO,TC1,TC2,TC3 
              ENDIF 
          WRITE(60,502)QCSURF(IZW),QRMRT(IZW),TMR(NRM) 
          ENDIF 
C     IDBG=0
      RETURN
  500 FORMAT(15X,'OWALLS:NRM,IZW,ID,KON= ',4I5/ 
     +15X,'WALLF,FAWLOD,HO,TODBR4= ',4G13.5/
     +15X,'    QLOSWL(IZW)= ', G13.5) 
  501 FORMAT(15X,'T1,T1N= ',2G13.5/ 
     +15X,'T2,T2N= ',2G13.5/
     +15X,'T3,T3N= ',2G13.5/
     +15X,'T4,T4N= ',2G13.5/
     +15X,'AWALLA(IZW),ISURF,IT,SOLARL,DSOLAR= ',G13.5,2I5,2G13.5/
     +15X,'TODDB,TWO,TA(NRM),H= ',4G13.5/ 
     +15X,'TC1= ',G13.5,' TC2= ',G13.5/ 
     +15X,'TC3= ',G13.5,' TC4= ',G13.5/ 
     +15X,'TC5= ',G13.5,' TC6= ',G13.5/ 
     +15X,'TC7= ',G13.5,' TC8= ',G13.5) 
  502 FORMAT(15X,'QCSURF,QRMRT,TMR= ',3G13.5) 
  503 FORMAT(12X,'T1,T1N= ',2G13.5/ 
     +12X,'T2,T2N= ',2G13.5/
     +12X,'T3,T3N= ',2G13.5/
     +12X,'AWALLA(IZW),TODDB,TA(NRM),H= ',4G13.5/ 
     +12X,'TC1= ',G13.5,' TC2= ',G13.5/ 
     +12X,'TC3= ',G13.5)
  504 FORMAT(5X,'OWALLS:CHECK--I,IZW,IZWE,CONDWL(I),T1,TMPN(1,IZW)= '/
     +5X,3I3,3G13.5)
      END 
