C
C
      SUBROUTINE  CDJUNC (NSTART,JUMPBK,L,KR,KS)
C
C     ------------------------------------------------------------------
C
C       SUBROUTINE PURPOSE:
C       EVALUATION OF AIR TEMP. AND CONTENT OF CONTAMINANTS IN JUNCTIONS
C
C     ------------------------------------------------------------------
C
      INCLUDE 'CMMNW.DAT'
C
C     KS=0: THE SUB. IS CALLED FOR FROM THE MAIN PROGRAM.
C     KS=1: THE SUB. IS CALLED FOR FROM SUB. RECIRC.
C
      DO 20 I=1,NJ
         IF (KS.EQ.0) THEN
            L=JLR(I)
            IF (JNO(L).GE.0) GO TO 5
         ELSE
            IF (JNO(KR).EQ.JNOL(I)) GO TO 5
         ENDIF
         GO TO 20
5        JY=1
         IF (I.GT.1) JY=MIN(I-1)+1
         JZ=MIN(I)
         SUMAIR=0.0
         SUMPR=0.0
         SUMCH4=0.0
         SUMHT=0.0
         DO 10 K=JY,JZ
            J=NGIN(K)
            IF (JF(J).GE.0.AND.KS.EQ.0) GO TO 20
            SUMAIR=SUMAIR+Q(J)
            SUMPR=SUMPR+RDPROP(J)*Q(J)
            SUMCH4=SUMCH4+RDCH4(J)*Q(J)
            SUMHT=SUMHT+TRD(J)*Q(J)*(0.2376+1.2E-5*TRD(J))
10       CONTINUE
C
C       IF DATA PREPARATION FOR ANY ONE OF THE JUNCTIONS IN THE
C     SYSTEM IS NOT COMPLETE, THE PROCESS OF DATA PREPARATION WILL
C     CONTINUE (JUMPBK=1).
C
         NSTART=I
         IF (KS.EQ.1) L=KR
         IF (JNO(L).NE.JSTART.AND.(JNO(L).LT.900.OR.JNO(L).GT.950)) THEN
            PROP(L)=SUMPR/SUMAIR
            PRCH4(L)=SUMCH4/SUMAIR
            RTCONT=9.801E7+2.0*SUMHT/(SUMAIR*2.4E-5)
            T(L)=-9900.+SQRT(RTCONT)
         ENDIF
         JUMPBK=1
         RETURN
20    CONTINUE
C
      RETURN
      END

