C
C
      SUBROUTINE  PARAM
C
C     ------------------------------------------------------------------
C
C       SUBROUTINE PURPOSES:
C       1) EVALUATION OF MEAN AND MEAN-SQUARE TEMP. IN AIRWAYS.
C       2) CALCULATION OF VARIED AIRFLOW RESISTANCE AND THE INTEGRAL
C          OF AIR DENSITY*ELEVATION VARIATION OF EACH AIRWAY FOR
C          ASSESSING NVP.
C
C     ------------------------------------------------------------------
C
      INCLUDE 'CMMNW.DAT'
C
      DO 30 I=1,NB
         IF (NWTYP(I).EQ.10) THEN
            TMRD(I)=TRD(I)
            FRNVP(I)=2116.0*DZRD(I)/(53.352*(TRD(I)+460.0))
            R(I)=RSTD(I)*(TMRD(I)+460.0)**2/(TR+460.0)**2
         ENDIF
         IF (IBTN(I).EQ.0) GO TO 30
         FRNVP(I)=0.0
         IF (NSAC(I,2).EQ.0) THEN
C
C     SHORT AIRWAYS ARE EVALUATED BASED ON CONDITIONS AT ITS TWO ENDS.
C
            F1=ABS(TJS(I)-TROCK(I))
            F2=ABS(TRD(I)-TROCK(I))
            FF=MAX(F1,F2)
            IF (FF.LT.0.1) THEN
               TMRD(I)=TJS(I)
               TMSQR=(TJS(I)+460.0)**2
               FRNVP(I)=2116.0*DZRD(I)/(53.352*(TJS(I)+460.0))
            ELSE
              TTROCK=TROCK(I)
               IF (ABS(TJS(I)-TTROCK).LT.0.01) TTROCK=TJS(I)-5.0
               TT=(TRD(I)-TTROCK)/(TJS(I)-TTROCK)
               IF (TT.LT.0.01) THEN
                  TTROCK=AMIN1(TJS(I),TRD(I))-5.0
                  TT=(TRD(I)-TTROCK)/(TJS(I)-TTROCK)
               ENDIF
               IF (ABS(TT-1.0).LT.1.E-3) THEN
                  TMRD(I)=TJS(I)
                  TMSQR=(TJS(I)+460.0)**2
                  FRNVP(I)=2116.0*DZRD(I)/(53.352*(TJS(I)+460.0))
               ELSE
C
C     TMRD(I): MEAN AIR TEMP. IN AIRWAY NO(I).
C     TMSQR: MEAN-SQUARE TEMP. IN THE SAME AIRWAY.
C
                  A1=TRD(I)-TTROCK
                  A2=TJS(I)-TTROCK
                  TJ=TTROCK+460.0
                  TMSQR=TJ*TJ+2.0*TJ*(TRD(I)-TJS(I))/ALOG(TT)
     .                  +(A1*A1-A2*A2)/(2.0*ALOG(TT))
                  TMRD(I)=TTROCK+(TRD(I)-TJS(I))/ALOG(TT)
                  YQ=ALOG((TRD(I)+460.0)/(TJS(I)+460.0))/ALOG(TT)
                  FRNVP(I)=2116.0*DZRD(I)*(1.0-YQ)/(53.352*TJ)
               ENDIF
            ENDIF
         ELSE
C
C       PARAMETER EVALUATIONS FOR AIRWAYS WITH DETAILED DATA RECORDS
C     ARE PROCESSED POINT BY POINT.
C
            NZ=NSAC(I,2)
            IQ=IBTN(I)
            TMRD(I)=0.0
            TMSQR=0.0
            DO 10 J=1,NZ+1
               IF (J.EQ.1) THEN
                  D2=LA(I)-DPPA(IQ,J,1)
                  C1=TAUXC(IQ)
                  C2=TRD(I)
               ELSE
                  D2=DPPA(IQ,J-1,1)-DPPA(IQ,J,1)
                  C1=TAUXA(IQ,J-1)
                  C2=DPPA(IQ,J-1,2)
               ENDIF
               IF (D2.LT.1.E-5) D2=0.01
               F1=ABS(C1-TROCK(I))
               F2=ABS(C2-TROCK(I))
               FF=MAX(F1,F2)
               IF (FF.LT.0.1) THEN
                  TMRD(I)=TMRD(I)+C1*D2
                  TMSQR=TMSQR+D2*(C1+460.0)**2
                  FRNVP(I)=FRNVP(I)+2116.0*DZRD(I)*D2/
     .                     (53.352*(C1+460.0))
               ELSE
                  TTROCK=TROCK(I)
                  IF (ABS(C1-TTROCK).LT.0.01) TTROCK=C1-5.0
                  TT=(C2-TTROCK)/(C1-TTROCK)
                  IF (TT.LT.0.01) THEN
                     TTROCK=AMIN1(C1,C2)-5.0
                     TT=(C2-TTROCK)/(C1-TTROCK)
                  ENDIF
                  IF (ABS(TT-1.0).LT.1.E-3) THEN
                     TMRD(I)=TMRD(I)+C1*D2
                     TMSQR=TMSQR+D2*(C1+460.0)**2
                     FRNVP(I)=FRNVP(I)+2116.*DZRD(I)*D2/
     .                         (53.352*(C1+460.))
                  ELSE
                     TMRD(I)=TMRD(I)+(TTROCK+(C2-C1)/ALOG(TT))*D2
                     A1=C2-TTROCK
                     A2=C1-TTROCK
                     TJ=TTROCK+460.0
                     TMSQR=TMSQR+D2*(TJ*TJ+2.0*TJ*(C2-C1)/ALOG(TT)
     .                     +(A1*A1-A2*A2)/(2.0*ALOG(TT)))
                     YQ=ALOG((C2+460.0)/(C1+460.0))/ALOG(TT)
                     FRNVP(I)=FRNVP(I)+2116.0*DZRD(I)*D2*(1.0-YQ)/
     .                         (53.352*TJ)
                  ENDIF
               ENDIF
10          CONTINUE
            TMRD(I)=TMRD(I)/LA(I)
            TMSQR=TMSQR/LA(I)
            FRNVP(I)=FRNVP(I)/LA(I)
         ENDIF
C
C
C       AIRFLOW RESISTANCE IS ASSUMED VARYING LINEARLY WITH
C     MEAN-SQUARE TEMP. DUE TO CHANGED AIRFLOW VELOCITY.
C
         IF (NWTYP(I).NE.1) R(I)=RSTD(I)*TMSQR/(TR+460.0)**2
30    CONTINUE
C
      RETURN
      END

