C
C
      SUBROUTINE CCDATA (MARKY,NSTOP)
C
C     -----------------------------------------------------------------
C
C       SUBROUTINE PURPOSES:
C       1) COMPLETION OF INPUT DATA.
C       2) EVALUATION OF ROCK TEMP. AND AIRWAY WETNESS.
C
C     -----------------------------------------------------------------
C
      INCLUDE 'CMMNW.DAT'
C
C       NAV>0 INDICATES THE EXISTANCE OF AVERAGE VALUE CARD FOR
C     MISSING INFORMATION.
C
      IF (NAV.GT.0) THEN
         READ (9,*,ERR=130) HAAVR,HKAVR,A1,A2,AAVR,OAVR,TAVR
         KFAVR=A1+0.4
         LAAVR=A2+0.4
         IF (IOUT.LE.(-2)) THEN
            WRITE (8,330) HAAVR,HKAVR,KFAVR,LAAVR,AAVR,OAVR,TAVR
         ENDIF
      ELSE
         TAVR=75.0
         HAAVR=0.1
         HKAVR=3.0
         KFAVR=100
         LAAVR=500
         AAVR=100.0
         OAVR=40.0
         IF (MARKY.EQ.0) WRITE (8,290)
      ENDIF
      IF (HAAVR.LT.1.E-3.OR.HAAVR.GT.1.E3) HAAVR=0.1
      IF (HKAVR.LT.1.E-3.OR.HKAVR.GT.1.E3) HKAVR=3.0
      IF (KFAVR.LT.1.OR.KFAVR.GT.10000) KFAVR=100
      IF (LAAVR.LT.1.OR.LAAVR.GT.10000) LAAVR=500
      IF (AAVR.LT.1.E-3.OR.AAVR.GT.1.E5) AAVR=100.0
      IF (OAVR.LT.1.E-3.OR.OAVR.GT.1.E5) OAVR=40.0
      IF (TAVR.LT.(-50.0).OR.TAVR.GT.200.0) TAVR=75.0
      IF (MARKY.EQ.0) WRITE (8,310) TAVR,HAAVR,HKAVR,KFAVR,LAAVR,
     .                              AAVR,OAVR
C
C       MISSING OR INCONSISTENT DATA ARE MADE UP WITH THE USER-SPECIFIED
C     OR DEFAULT AVERAGE VALUES.
C
      DO 50 I=1,NB
         IF (HA(I).LE.0.0) HA(I)=HAAVR
         IF (HK(I).LE.0.0) HK(I)=HKAVR
         IF (KF(I).LE.0) KF(I)=KFAVR
         IF (LA(I).LE.0.0) LA(I)=FLOAT(LAAVR)
         IF (A(I).LE.0.0) A(I)=AAVR
         IF (O(I).LE.0.0) O(I)=OAVR
50    CONTINUE
C
C  ** CALCULATION OF ROCK TEMP. AND AIRWAY WETNESS.
C
      DO 120 J=1,NB
         IF (NO(J).LE.0) NO(J)=-NO(J)
         L=0
         M=0
C
C     NHM=0: DRY CASE ASSUMED.
C     NHM=1: WET CASE ASSUMED.
C
         IF (NHM.EQ.0) THEN
            DO 60 I=1,NJ
               IF (JS(J).EQ.JNO(I)) THEN
                  ES=Z(I)
                  TRS=T(I)
                  L=1
               ELSE IF (JF(J).EQ.JNO(I)) THEN
                  EF=Z(I)
                  TRF=T(I)
                  M=1
               ENDIF
               IF (Q(J).LT.0.0) THEN
                  STORE=TRF
                  TRF=TRS
                  TRS=STORE
               ENDIF
               IF ((L+M).EQ.2) THEN
                 IF (JF(J).EQ.JSTART.OR.(JF(J).GE.900.AND.JF(J).LE.950))
     .               TRF=TRS
                  DZRD(J)=EF-ES
                  IF (ABS(DZRD(J)).GT.LA(J)) THEN
                     LA(J)=ABS(DZRD(J))
C                    ******************
                     WRITE (8,320) NO(J),LA(J)
                  ENDIF
                  X=0.014*O(J)/(A(J)**0.8*(ABS(Q(J)))**0.2)
                  TROCKA=(TRF-TRS*EXP(-X*LA(J))+DZRD(J)*
     .            (1.+EXP(-X*LA(J)))/(2*187.))/(1.0-EXP(-X*LA(J)))
                  IF (ABS(TROCK(J)).LT.1.E-3.OR.TROCK(J).LT.(-50.0).OR.
     .               TROCK(J).GT.200.0) TROCK(J)=TROCKA
                  GO TO 70
               ENDIF
60          CONTINUE
70          CONTINUE
         ELSE
C
C     WET CASE:
C
            DO 110 I=1,NJ
               IF (JS(J).EQ.JNO(I)) THEN
                  ES=Z(I)
                  TRS=T(I)
                  GB=PRH2O(I)
                  L=1
               ELSE IF (JF(J).EQ.JNO(I)) THEN
                  EF=Z(I)
                  TRF=T(I)
                  GX=PRH2O(I)
                  M=1
               ENDIF
               IF (Q(J).LT.0.0) THEN
                  STORE=TRF
                  TRF=TRS
                  TRS=STORE
               ENDIF
               IF ((L+M).EQ.2) THEN
                 IF (JF(J).EQ.JSTART.OR.(JF(J).GE.900.AND.JF(J).LE.950))
     .               TRF=TRS
                  DZRD(J)=EF-ES
                  IF (ABS(DZRD(J)).GT.LA(J)) THEN
                     LA(J)=ABS(DZRD(J))
C                          ************
                     WRITE (8,320) NO(J),LA(J)
                  ENDIF
                  X=0.014*O(J)/(A(J)**0.8*(ABS(Q(J)))**0.2)
                  TROCKA=(TRF-TRS*EXP(-X*LA(J))+DZRD(J)*
     .            (1.+EXP(-X*LA(J)))/(2*187.))/(1.0-EXP(-X*LA(J)))
                  IF (ABS(TROCK(J)).LT.1.E-3.OR.TROCK(J).LT.(-50.0).OR.
     .               TROCK(J).GT.200.0) TROCK(J)=TROCKA
C
C       SUB. MTCOEF SERVES CALCULATION OF MASS TRANSFER COEFF. BETA.
C
                  IF (MARKY.EQ.0) THEN
                     TX=TROCK(J)
                     CALL MTCOEF (TX,TX,J,BETA)
                     TY=TX
                     IF (TY.GT.210.0) TY=210.0
                     IF (TY.LE.122.0) THEN
                        PV=-1.068+0.07946*TY-0.00129*TY*TY+1.26E-5*TY**3
                     ELSE
                        PV=-33.786+0.97*TY-9.306E-3*TY*TY+3.65E-5*TY**3
                     ENDIF
                     GW=0.622*PV/(101.35-PV)
C
C     EVALUATION OF WALL WETNESS.
C
                     DO 80 KI=1,INFLOW
                        IF (NO(J).EQ.NCENT(KI)) THEN
                           PSI(J)=0.0
                           GO TO 90
                        ENDIF
80                   CONTINUE
                     IF (GW.LT.GB.AND.GB.LE.GX) THEN
                        WRITE (8,270) NO(J)
                        PSI(J)=1.0
                     ELSE IF (GW.GT.GB.AND.GB.GE.GX) THEN
                        WRITE (8,275) NO(J)
                     ELSE IF (GX.GE.GB) THEN
                        AL=BETA*O(J)*LA(J)/(60.0*Q(J))
                        IF (AL.LT.10.0) THEN
                           EL=EXP(-AL)
                        ELSE
                           EL=0.0
                        ENDIF
                        PSI(J)=(GX-GB*EL)/(GW*(1.0-EL))
                        IF (PSI(J).GT.1.0) PSI(J)=1.0
                     ELSE IF (GX.LE.GB) THEN
                        WRITE (8,280) NO(J),PSI(J)
                        IF (PSI(J).LT.0.0) THEN
                           WRITE (8,260) PSI(J),NO(J)
                           PSI(J)=0.0
                        ENDIF
                     ENDIF
                  ENDIF
90                IF (PSI(J).LT.0.0) PSI(J)=0.0
                  IF (ABS(PSI(I)).LT.0.01) PSI(J)=0.6
C
C       HUMIDITY RATIO AT AIRWAY ENDING IS ASSUMED TO EQUAL THE
C     HUMIDITY RATIO IN THE JUNCTION WHICH THE AIRWAY IS
C     CONNECTED TO.
C
                  DO 100 IK=1,NJ
                     IF (JF(J).EQ.JNO(IK)) THEN
                         RDH2O(J)=PRH2O(I)
                         GO TO 120
                     ENDIF
100               CONTINUE
               ENDIF
110         CONTINUE
         ENDIF
120   CONTINUE
      DO 125 I=1,NB
         IF (TROCK(J).LT.(-50.0).OR.TROCK(J).GT.200.0) TROCK(J)=TAVR
125   CONTINUE
      RETURN
130   WRITE (6,340)
      WRITE (8,340)
      NSTOP=1
      RETURN
C
220   FORMAT (I5,F10.2,4F10.5,F10.1)
260   FORMAT (/,' * ATTN * INVALID WETNESS INPUT (',F6.3,') FOR AIRWAY',
     .        I6,/,1X,'ITS WETNESS IS TAKEN AS ZERO.')
270   FORMAT (/,1X,'* ATTN * INCONSISTANT DATA FOR AIRWAY',I6,' AND ITS'
     .        ,' RELATING ENDING JUNCTIONS.',/,1X,'THE WETNESS IS ',
     .        'TAKEN AS 1.0 DUE TO THE INCREASING HUMIDITY.',/)
275   FORMAT (/,1X,'* ATTN * INCONSISTANT DATA FOR AIRWAY',I6,' AND ITS'
     .        ,' RELATING ENDING',/,' JUNCTIONS. THE INPUT VALUE IS ',
     .        'TAKEN AS ITS WETNESS.',/)
280   FORMAT (/,1X,'* ATTN * WETNESS OF AIRWAY',I6,' CAN NOT BE DEFINED'
     .        ,' BY THE KNOWN',/,1X,'CONDITIONS. INPUT VALUE',F5.1,
     .        ' IS TAKEN.')
290   FORMAT (//,' * ATTN * AVE. VALUES WERE OMITTED BY USER (NAV=0)')
300   FORMAT (//,1X,'* WRN *  DUPLICATED ADDITIONAL DATA FOR AIRWAY',I5)
310   FORMAT (///,1X,'THE FOLLOWING AVERAGE VALUES WILL BE USED TO ',
     .       'FILL ANY MISSING DATA:',//,1X,'AVE. ROCK TEMPERATURE',
     .       T30,F7.1,T43,'F',/,1X,'THERMAL DIFFUSIVITY OF',
     .       ' ROCK',T30,F9.3,T43,'FT2/HR',/,1X,'ROCK THERMAL ',
     .       'CONDUCTIVITY',T30,F9.3,T43,'BTU/(HR*FT*F)',/,1X,
     .       'FRICTION FACTOR',T30,I9,T43,'1.E-10 LBF*MIN2/FT4',/,1X,
     .       'AIRWAY LENGTH',T30,I9,T43,'FT',/,1X,'SECTIONAL AREA ',
     .       T30,F9.3,T43,'FT2',/,1X,'PERIMETER',T30,F9.3,T43,'FT',/)
320   FORMAT (/,1X,'* WRN *  THE LENGTH OF AIRWAY ',I5,' IS LESS ',
     .       'THAN ITS ELEVATION',/,' DIFFERENCE, THEY ARE NOW TAKEN ',
     .       'EQUAL TO EACH OTHER AS ',F8.1)
330   FORMAT (///,' * INPUT DATA LIST (AVERAGE VALUE DATA) *',//,
     .       T2,'HAAVR=',T8,F7.2,T18,'HKAVR=',T26,F7.2,T37,'KFAVR=',
     .       T45,F7.3,T55,'LAAVR=',T63,F7.1,/,T2,'AAVR=',T8,F7.2,
     .       T18,'OAVR=',T26,F7.2,T37,'TAVR=',T45,F7.2,/)
340   FORMAT (//,' * ERR * ERROR READING INPUT DATA.',/)
C
      END
