C
C
      SUBROUTINE ARR (MARKX)
C
C     ------------------------------------------------------------
C
C       SUBROUTINE PURPOSES:
C       1) GROUPING AIRWAYS ACCORDING TO THEIR TYPES.
C       2) ARRANGING REGULAR AIRWAYS ACCORDING TO THE PRODUCT OF
C          Q AND R.
C
C     ------------------------------------------------------------
C
      INCLUDE 'CMMNW.DAT'
C
C       THE ORDERED AIRWAY LIST IS STORED IN ARRAY INU. FIXED
C     QUANTITY AIRWAYS ARE ON ITS "BOTTOM". THEN COME THE FAN
C     BRANCHES. THE REGULAR AIRWAYS WHICH CONTAIN NO FAN AND NO
C     ADDITIONAL RESTRICTIONS SPECIFIED BY USER ARE ON THE TOP OF
C     LIST.
C
      NBU=NB
      NBL=1
      DO 10 K=1,NB
         IF (NWTYP(K).LT.0) THEN
            INU(NBU)=K
            NBU=NBU-1
         ELSE IF (NWTYP(K).EQ.0.OR.NWTYP(K).EQ.10) THEN
            RQ(K)=ABS(R(K)*Q(K))
            NWTYP(K)=2
         ELSE
            IF (NFNUM.GT.0) THEN
               DO 5 J=1,NFNUM
                  IF (NOF(J).EQ.NO(K).AND.NWTYP(K).EQ.1) GO TO 10
5              CONTINUE
            ENDIF
            INU(NBL)=K
            NBL=NBL+1
         ENDIF
10    CONTINUE
      IF (NFNUM.GT.0) THEN
         DO 25 K=1,NB
            DO 20 J=1,NFNUM
               IF (NOF(J).EQ.NO(K).AND.NWTYP(K).EQ.1) THEN
C                                  *****************
C               IF (NOF(J).EQ.NO(K)) THEN
                  RGRAD(J)=0.0
                  NFCW(J)=0
                  NFREG(J)=K
                  INU(NBU)=K
                  NBU=NBU-1
                  GO TO 25
               ENDIF
20          CONTINUE
25       CONTINUE
      ENDIF
C
C       REGULAR AIRWAYS ARE STORED IN THE ORDER OF THE PRODUCTS
C     OF Q AND R.
C
C
      IF (NBU.GT.(NBL-1)) THEN
30       NRETU=0
         DO 40 K=1,NB
            IF (NWTYP(K).GE.2) THEN
               IF (NRETU.LE.0) THEN
                  MMIN=K
                  NRETU=1
               ENDIF
               IF (RQ(MMIN).GT.RQ(K)) MMIN=K
            ENDIF
40       CONTINUE
         INU(NBL)=MMIN
         NBL=NBL+1
         NWTYP(MMIN)=0
         IF ((NBU+1).GT.NBL) GO TO 30
      ENDIF
C
C       AIRWAYS CONTAINING FIRE SOURCES HAVE THEIR NWTYP(I) EQUAL TO
C     10 TO DISTINGUISH THEMSELVES FROM OTHERS.
C     MARKX=1: THE PROGRAM HAS REACHED THE DYNAMIC SIMULATION PART.
C
      IF (MARKX.GT.0) THEN
         DO 60 I=1,INFLOW
            DO 50 J=1,NB
               IF (NCENT(I).EQ.NO(J)) THEN
                  NWTYP(J)=10
                  GO TO 60
               ENDIF
50          CONTINUE
60       CONTINUE
      ENDIF
C
      RETURN
      END

