C
C
      SUBROUTINE WDT (IC)
C
C     -----------------------------------------------------------------
C
C       SUBROUTINE PURPOSES:
C          EVALUATION OF WATER EVAPORATION CONDITIONS FOR EACH STATION
C          IN AIRWAYS WHICH HAVE THEIR DETAILED DATA RECORDS.
C
C     -----------------------------------------------------------------
C
      INCLUDE 'CMMNW.DAT'
C
      DIMENSION   NP(11)
C
C     NP(11): FLAG ARRAY.
C
      IF (IBTN(IC).EQ.0) RETURN
C
C  ** DATA PREPARATION FOR THE EVALUATION OF PARAMETERS AT STATIONS.
C
      DO 10 KL=1,NJ
         IF (JNO(KL).EQ.JS(IC)) GO TO 20
10    CONTINUE
C
C     GFS(IA): HUMIDITY RATIO BEHIND FIRE SOURCE NCENT(IA).
C     NPP: FLAG NUMBER INDICATING IF THE AIRWAY STARTED CALCULATION
C          OF TEMP. CORR. FOR THE 1ST TIME.
C     HABS1: HUMIDITY RATIO OF AIR AT STATIONS IN THE LAST INTERVAL.
C     NP: NP(J)=1: STATION J IS WITHIN THE INFLUENTIAL RANGE OF THE
C         STATION UNDER CONSIDERATION AND AIR HUMIDITY RATIO AT
C         STATION J HAS BEEN EVALUATED.
C
20    ABHH=PRH2O(KL)
      JLE=NSP(IC)
      KQ=IBTN(IC)
      IF (NPP(KQ).EQ.0) THEN
C
C       LINEAR INTERPOLATION OF HUMIDITY RATIO ALONG AN AIRWAY IS
C     PERFORMED FOR THE SET UP OF INITIAL CONDITIONS AT STATIONS.
C
         DO 50 IX=1,JLE
            HD=RH2O(IC)-PRH2OS(KL)
            HABS1(KQ,IX)=PRH2OS(KL)+HD*(IX-1)/FLOAT(JLE)
            NP(IX)=0
50       CONTINUE
         NP(JLE+1)=0
      ELSE
         DO 60 IY=1,JLE
            NP(IY)=0
60       CONTINUE
         NP(JLE+1)=0
      ENDIF
C
C  ** EVALUATION OF AIR AND WALL TEMP. AT STATIONS.
C     TDA: AIR TEMP. AT STATIONS.
C     STV: WALL TEMP. AT STATIONS.
C     HABS: HUMIDITY RATIO OF AIR AT STATIONS.
C
      KV=NSAC(IC,2)
      TDA(KQ,1)=TJS(IC)
      STV(KQ,1)=DCOAGE(IC)*(TROCK(IC)-TJS(IC))/BI(IC)+TJS(IC)
      IF (JLE.GE.2) THEN
         DO 90 IP=2,JLE
            SL=LA(IC)*FLOAT(IP-1)/JLE
            IF (KV.GE.1) THEN
               DO 70 ID=1,KV+1
                  IF (ID.EQ.1.AND.SL.LT.DPPA(KQ,ID,1)) THEN
                     T2=DPPA(KQ,ID,2)
                     T1=TJS(IC)
                     X1=0.0
                     X2=DPPA(KQ,ID,1)
                     GO TO 80
                  ELSE IF (ID.GT.KV.AND.SL.GT.DPPA(KQ,KV,1)) THEN
                     T2=TRD(IC)
                     X2=LA(IC)
                     IF (NSAC(IC,1).EQ.1) THEN
                        T1=T2+5.0
                     ELSE
                        T1=DPPA(KQ,ID-1,2)
                     ENDIF
                     X1=DPPA(KQ,ID-1,1)
                     GO TO 80
                  ELSE IF (SL.LT.DPPA(KQ,ID,1)) THEN
                     T2=DPPA(KQ,ID,2)
                     X2=DPPA(KQ,ID,1)
                     IF (ID.GE.2) THEN
                        T1=DPPA(KQ,ID-1,2)
                        X1=DPPA(KQ,ID-1,1)
                     ELSE
                        T1=TJS(IC)
                        X1=0.0
                     ENDIF
                     GO TO 80
                  ENDIF
70             CONTINUE
               GO TO 90
            ELSE
               T2=TRD(IC)
               T1=TJS(IC)
               X2=LA(IC)
               X1=0.0
            ENDIF
80          ES=ALOG(T1/T2)*(X1-SL)/(X2-X1)
            TDA(KQ,IP)=T1*EXP(ES)
            STV(KQ,IP)=DCOAGE(IC)*(TROCK(IC)-TDA(KQ,IP))/BI(IC)
     .                 +TDA(KQ,IP)
90       CONTINUE
      ENDIF
C
C  ** EVALUATION OF HUMIDITY RATIO OF AIR CURRENT AT STATIONS.
C     SLTH: INFLUENTIAL RANGE WITHIN WHICH THE HUMIDITY RATIO AT A
C           CERTAIN STATION CAN AFFECT THE HUMIDITY RATIO AT
C           ANOTHER STATION ON ITS LEEWARD SIDE. SLTH HAS TO BE LARGER
C           THAN THE DISTANCE BETWEEN TWO STATIONS TO ALLOW MASS
C           BALANCE AT STATIONS BE SEQUENTIALLY CONSIDERED.
C
      SLTH=QQ(IC)*(TMM(IC)+460)*DELTAT/(A(IC)*(TR+460)*60.0)
      IF (SLTH.LE.(LA(IC)/JLE)) SLTH=LA(IC)/JLE+1.0
      HABS1(KQ,1)=ABHH
      HABS(KQ,1)=ABHH
      NP(1)=1
      DO 120 JP=1,JLE
         GA1=HABS1(KQ,JP)
         DO 110 IP=JP+1,JLE+1
            IF (NP(IP).EQ.1) GO TO 110
            SL=LA(IC)*(IP-1)/JLE
            SLL=LA(IC)*(IP-JP)/JLE
            IF (SLL.GT.SLTH) GO TO 110
            IF (IP.EQ.(JLE+1)) THEN
               TA2=TRD(IC)
               T2=DCOAGE(IC)*(TROCK(IC)-TA2)/BI(IC)+TA2
            ELSE
               TA2=TDA(KQ,IP)
               T2=STV(KQ,IP)
            ENDIF
            T1=STV(KQ,IP-1)
            X1=SL-LA(IC)/JLE
            X2=SL
            TX=T1
            IF (TX.GT.210.0) TX=210.0
            IF (TX.LE.122.0) THEN
               PVW=-1.0682+0.07946*TX-0.00129*TX*TX+1.26E-5*TX**3
            ELSE
               PVW=-33.786+0.97*TX-9.305E-3*TX*TX+3.65E-5*TX**3
            ENDIF
            GAW=0.622*PVW/(101.35-PVW)
            IF (GA1.LE.GAW*PSI(IC).AND.T1.LE.CRITW) THEN
               PSII=PSI(IC)
            ELSE IF (GA1.GE.GAW) THEN
               PSII=1.0
            ELSE
               GA2=GA1
               GO TO 100
            ENDIF
            TA1=TDA(KQ,IP-1)
C
C     SUB. MTCOEF EVALUATES MASS TRANSFER COEFF. BETA.
C
            CALL MTCOEF (T1,TA1,IC,BETA)
            AA=T2+(T1-T2)*X2/(X2-X1)
            BB=(T1-T2)/(X1-X2)
            A0=-1.0682+0.07946*AA-0.00129*AA*AA+0.0000129*AA**3
            B0=0.07946*BB-0.00258*AA*BB+0.0000378*BB*AA*AA
            C0=0.0000378*AA*BB*BB-0.00129*BB*BB
            D0=0.0000126*BB**3
            PVM=A0+B0*(X2-X1)/2.0+C0*(X2-X1)**2/3.0+D0*(X2-X1)**3/4.0
            F1=PSII*BETA*O(IC)*0.622/(60.0*QQ(IC)*(101.35-PVM))
            F2=BETA*O(IC)/(60.0*QQ(IC))
            D1=F1*D0/F2
            C1=(F1*C0-3*D1)/F2
            B1=(F1*B0-2*C1)/F2
            A1=(F1*A0-B1)/F2
            ALPHA=GA1-(A1+B1*X1+C1*X1*X1+D1*X1**3)
            EX=F2*(X2-X1)
            IF (EX.GT.30.0) THEN
               AB=0.0
            ELSE
               AB=EXP(-EX)
            ENDIF
            GA2=ALPHA*AB+(A1+B1*X2+C1*X2*X2+D1*X2**3)
100         IF (TA2.GT.210.0) TA2=210.0
            IF (TA2.LE.122.0) THEN
               PVA=-1.0682+0.07946*TA2-0.00129*TA2*TA2+1.26E-5*TA2**3
            ELSE
               PVA=-33.786+0.97*TA2-9.305E-3*TA2*TA2+3.65E-5*TA2**3
            ENDIF
            GAE=0.622*PVA/(101.35-PVA)
            GFF(KQ,IP)=GA2-GAE
            IF (GFF(KQ,IP).LT.0.0) GFF(KQ,IP)=0.0
            IF (IP.EQ.(JLE+1)) THEN
               RDH2O(IC)=GA2-GFF(KQ,IP)
            ELSE
               HABS(KQ,IP)=GA2-GFF(KQ,IP)
            ENDIF
            NP(IP)=1
            GA1=GA2-GFF(KQ,IP)
110      CONTINUE
120   CONTINUE
C
      RETURN
      END

