C
C
C
      SUBROUTINE CHECK1 (NSTOP,MAXNO)
C
C     ---------------------------------------------------------
C
C       SUBROUTINE PURPOSE:
C       1) MAKE-UP OF THE MISSING DATA.
C       2) CHECK FOR CONSISTENCY OF INPUT DATA.
C
C     ---------------------------------------------------------
C
      INCLUDE 'CMMNW.DAT'
C
C  ** CALCULATION OF VENTILATION RESISTANCE.
C
      MAXNO=0
      DO 10 I=1,NB
         IF (NO(I).GT.MAXNO) MAXNO=NO(I)
         IF (NWTYP(I).EQ.0) THEN
            IF (R(I).LE.0) THEN
               IF (A(I).LE.0) THEN
                  WRITE (8,130) NO(I)
                  NSTOP=1
               ELSE
                  R(I)=KF(I)*LA(I)*O(I)/(5.2*A(I)**3)*DR/0.075
               ENDIF
            ENDIF
            RSTD(I)=R(I)
         ELSE
            RSTD(I)=R(I)
         ENDIF
10    CONTINUE
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
      LF1=0
      DO 15 I=1,NFNUM
         DO 15 J=1,NB
            IF (NWTYP(J).EQ.1.AND.NO(J).EQ.NOF(I)) LF1=1
15    CONTINUE
      IF (LF1.EQ.0) THEN
         DO 16 J=1,NB
            IF(NWTYP(J).EQ.1.AND.R(J).GT.0.0) LF1=1
16       CONTINUE
      ENDIF
      IF (LF1.EQ.0)  WRITE (8,*) "* WARNING * NO FAN IN THE NETWORK. "
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C
C  ** CHECK FOR DATA CONSISTENCY.
C
      MAXJ=0
      DO 30 I=1,NB
         IF (IABS(NWTYP(I)).GT.1) THEN
            WRITE (8,160) NWTYP(I),NO(I)
            NSTOP=1
         ENDIF
         IF (JS(I).EQ.JF(I)) THEN
            WRITE (8,100) NO(I)
            NSTOP=1
         ENDIF
         NREV(I)=0
         N1=0
         N2=0
         DO 20 J=1,NJ
            IF (JNO(J).GT.MAXJ.AND.I.EQ.1) MAXJ=JNO(J)
            IF (JS(I).EQ.JNO(J)) N1=N1+1
            IF (JF(I).EQ.JNO(J)) N2=N2+1
20       CONTINUE
         IF (N1.EQ.0) THEN
            WRITE (8,105) NO(I),JS(I)
            NSTOP=1
         ELSE IF (N1.GE.2) THEN
            WRITE (8,110) NO(I),JF(I)
            NSTOP=1
         ENDIF
         IF (N2.EQ.0) THEN
            WRITE (8,105) NO(I),JS(I)
            NSTOP=1
         ELSE IF (N2.GE.2) THEN
            WRITE (8,110) NO(I),JF(I)
            NSTOP=1
         ENDIF
30    CONTINUE
      DO 50 J=1,NJ
         IF (T(J).LT.(-100.0).OR.T(J).GT.1500.0) T(J)=TR
         IF (CH4C(J).LT.0.0.OR.CH4C(J).GT.75.0) CH4C(J)=0.0
        J1=0
        DO 40 I=1,NB
           IF (JS(I).EQ.JNO(J).OR.JF(I).EQ.JNO(J)) THEN
              J1=J1+1
           ENDIF
40      CONTINUE
        IF (J1.EQ.0) THEN
            WRITE (8,115) JNO(J)
            NSTOP=1
         ENDIF
50    CONTINUE
      DO 70 I=1,NB
         J1=0
         J2=0
         J3=0
         DO 60 J=1,NB
            IF (NO(I).EQ.NO(J)) J1=J1+1
            IF (JS(I).EQ.JS(J)) J2=J2+1
            IF (JS(I).EQ.JF(J)) J2=J2+1
            IF (JF(I).EQ.JS(J)) J3=J3+1
            IF (JF(I).EQ.JF(J)) J3=J3+1
60       CONTINUE
         IF (J1.GT.1) THEN
            WRITE (8,140) NO(I)
            NSTOP=1
         ENDIF
         IF (J2.LE.1.OR.J3.LE.1) THEN
            IF (J2.LE.1) WRITE (8,170) NO(I),JS(I)
            IF (J3.LE.1) WRITE (8,170) NO(I),JF(I)
            NSTOP=1
         ENDIF
70    CONTINUE
      DO 90 I=1,NJ
         J2=0
         DO 80 J=1,NJ
            IF (JNO(I).EQ.JNO(J)) J2=J2+1
80       CONTINUE
         IF (J2.GT.1) THEN
            WRITE (8,150) JNO(I)
            NSTOP=1
         ENDIF
90    CONTINUE
C
100   FORMAT (/,1X,'* ERR *  AIRWAY',I5,' IS ISOLATED FROM ',
     .        'THE NETWORK.')
105   FORMAT (/,1X,'* ERR *  AIRWAY',I5,'  IS ISOLATED FROM ',
     .        'THE NETWORK',/,' FOR THE UNCONNECTED END',I5)
110   FORMAT (/,1X,'* ERR *  DUBLICATED JUNCTION NUMBER',I5)
115   FORMAT (/,1X,'* ERR *  JUNCTION',I5,'  IS ISOLATED FROM ',
     .        'THE NETWORK.')
130   FORMAT (/,1X,'* ERR *  NO RESISTANCE AND DIMENSION WERE',
     .        ' STATED FOR AIRWAY',I5)
140   FORMAT (/,1X,'* ERR *  DUPLICATED AIRWAY ID NUMBER',I5)
150   FORMAT (/,1X,'* ERR *  DUPLICATED JUNCTION ID NUMBER',I5)
160   FORMAT (/,1X,'* ERR *  INVALID AIRWAY TYPE',I4,' FOR AIRWAY',
     .        I6,' DETECTED.')
170   FORMAT (/,1X,'* ERR *  AIRWAY',I6,' IS ISOLATED FROM THE ',
     .        'NETWORK DUE TO DEADEND',I6)
C
      RETURN
      END

