C
C
      SUBROUTINE MSLIST
C
C
C     ---------------------------------------------------------------
C
C       SUBROUTINE PURPOSES:
C       SET-UP OF MESH LIST.
C
C     ---------------------------------------------------------------
C
      INCLUDE 'CMMNW.DAT'
C
      MESC=0
C
C     MNO: NUMBER OF INDEPENDENT MESHES IN THE NETWORK.
C     MEND(K): ADDRESS OF THE LAST BRANCH OF MESH K IN ARRAY MSL(N).
C     MSL(N): ONE DIMENSIONAL LIST OF MESH FORMATION PATTERN. IT IS
C             SO ARRANGED THAT A PRIMARY AIRWAY TAKES THE FIRST POSITION
C             IN THE LIST FOR THE MESH.
C       THE AIRWAY IN THE SAME ORIENTATION AS THE PRIMARY AIRWAY IN
C     THE MESH IS LABELED AS POSITIVE IN MSL LIST. OTHERWISE, LISTED
C     WITH NEGATIVE SIGNS.
C
      MNO=0
      DO 60 K=1,NB
        IF (JF(K).LT.0) THEN
          JF(K)=-JF(K)
          MNO=MNO+1
          JBM=JS(K)
          JEM=JF(K)
          NK=K
10        MESC=MESC+1
          MEND(MNO)=MESC
          MSL(MESC)=NK
C
C     KNO, KJS, KJF: AUXILIARY ARRAYS SERVING MESH FORMATION, OBTAINED
C     FROM SUB. BASE.
C
          DO 20 KCO=1,NJ
            IF (JBM.EQ.KJF(KCO)) THEN
              KB=KCO
              GO TO 30
            ENDIF
20        CONTINUE
30        DO 40 KCO=1,NJ
            IF (JEM.EQ.KJF(KCO)) THEN
              KE=KCO
              GO TO 50
            ENDIF
40        CONTINUE
50        IF (KB.LT.KE) THEN
            NK=KNO(KB)
            JBM=KJS(KB)
            GO TO 10
          ELSE IF (KB.GT.KE) THEN
            NK=-KNO(KE)
            JEM=KJS(KE)
            GO TO 10
          ENDIF
        ENDIF
60    CONTINUE
      IF (MEND(MNO).GT.LMX) THEN
         WRITE (8,*) 'CAPACITY OF ARRAY MSL EXCEEDED.'
         WRITE (8,*) 'LMX IN MAIN AND ALL RELEVANT SUBS. ARE NECESSARY.'
      ENDIF
C
      RETURN
      END

