CFPRIME CMBRAN                                                          CMBRAN      1
C***********************************************************************RIGHTE      1
C*                                                                     *RIGHTE      2
C*        Extended Transient-Midterm Stability Program (ETMSP)         *RIGHTE      3
C*        ====================================================         *RIGHTE      4
C*                                                                     *RIGHTE      5
C*       Copyright (C) (1993) Electric Power Research Institute        *RIGHTE      6
C*                                                                     *RIGHTE      7
C* EPRI reserves all rights in the software and associated             *RIGHTE      8
C* documentation as delivered. The software and its associated         *RIGHTE      9
C* documention or any portion thereof may not be reproduced in any form*RIGHTE     10
C* whatsoever without the consent of EPRI, except as explicity provided*RIGHTE     11
C* for by license. Licensee shall submit a detailed description to EPRI*RIGHTE     12
C* of any changes or modifications to the software within two (2)      *RIGHTE     13
C* months after such changes or modifications are made. At EPRI's sole *RIGHTE     14
C* discretion, the software, as changed or modified, shall be given a  *RIGHTE     15
C* new designation sufficiently different from its then current        *RIGHTE     16
C* designation as to prevent mistake,confusion, or deception as between*RIGHTE     17
C* the current software as changed or modified.                        *RIGHTE     18
C*                                                                     *RIGHTE     19
C* A license under EPRI's rights in the software can be obtained       *RIGHTE     20
C* directly from EPRI.                                                 *RIGHTE     21
C*                                                                     *RIGHTE     22
C* This program and supporting materials may be independently available*RIGHTE     23
C* from Electric Power Software centre (EPSC) for an appropriate       *RIGHTE     24
C* distribution fee. The EPSC is a service of                          *RIGHTE     25
C*                                                                     *RIGHTE     26
C*                    Power Computing Company                          *RIGHTE     27
C*                    1930 Hi Line                                     *RIGHTE     28
C*                    Dallas, Tx 75207                                 *RIGHTE     29
C*                                                                     *RIGHTE     30
C* NEITHER EPRI, ANY MEMBER OF EPRI, NOR ANY PERSON OR  ORGANIZATION   *RIGHTE     31
C* ACTING ON BEHAVE OF THEM:                                           *RIGHTE     32
C*                                                                     *RIGHTE     33
C* 1. MAKE ANY WARRANTY OR REPRESENTATION WHATSOEVER, EXPRESS OR       *RIGHTE     34
C*    IMPLIED, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR FITNESS OR *RIGHTE     35
C*    ANY PURPOSE WITH RESPECT TO THE SOFTWARE OR ITS ASSOCIATED       *RIGHTE     36
C*    DOCUMENTATION; OR                                                *RIGHTE     37
C*                                                                     *RIGHTE     38
C* 2. ASSUMES ANY LIABILITY WHATSOEVER WITH RESPECT TO ANY USE OF THE  *RIGHTE     39
C*    SOFTWARE OR ITS ASSOCIATED DOCUMENTATION OR ANY PORTION THEREOF  *RIGHTE     40
C*    OR WITH RESPECT TO ANY DAMAGES WHICH MAY RESULT FROM SUCH USE.   *RIGHTE     41
C*                                                                     *RIGHTE     42
C* THIS NOTICE MAY NOT BE REMOVED FROM THE SOFTWARE BY ANY USER        *RIGHTE     43
C* THEREOF.                                                            *RIGHTE     44
C*                                                                     *RIGHTE     45
C***********************************************************************RIGHTE     46
      SUBROUTINE CMBRAN(LBUS)                                           CMBRAN      3
CD                                                                      CMBRAN      4
CD   TO COMBINE THE PARALLEL BRANCHES BASED ON THE LINKNET INFORMATION. CMBRAN      5
CD                                                                      CMBRAN      6
      INCLUDE 'PARX.INS'                                                CMBRAN      7
      INCLUDE 'CNFLAG.INS'                                              CMBRAN      8
      INCLUDE 'CNPT.INS'                                                CMBRAN      9
      INCLUDE 'CNLKN1.INS'                                              CMBRAN     10
      INCLUDE 'CNBRAU.INS'                                              CMBRAN     11
      INCLUDE 'CNBRAL.INS'                                              CMBRAN     12
C                                                                       CMBRAN     13
      COMMON /SCRAT1/ ILBRIX(NB),ITBUS(NB)                              CMBRAN     14
C                                                                       CMBRAN     15
      LDEB=(JDEB(33).NE.0)                                              CMBRAN     16
C                                                                       CMBRAN     17
      IEBK=0                                                            CMBRAN     18
C                                                                       CMBRAN     19
      DO 100 I=1,LBUS                                                   CMBRAN     20
      IM=LBRI(I)                                                        CMBRAN     21
      NBRANC=0                                                          CMBRAN     22
      DO 20 J=1,NL                                                      CMBRAN     23
      NJ=KTNO(IM)                                                       CMBRAN     24
      IF(NJ.GT.0)THEN                                                   CMBRAN     25
      NBRANC=NBRANC+1                                                   CMBRAN     26
      ITBUS(NBRANC)=NJ                                                  CMBRAN     27
      ILBRIX(NBRANC)=IM                                                 CMBRAN     28
      ENDIF                                                             CMBRAN     29
      IM=NELI(IM)                                                       CMBRAN     30
      IF(IM.EQ.0)GOTO 30                                                CMBRAN     31
 20   CONTINUE                                                          CMBRAN     32
 30   CONTINUE                                                          CMBRAN     33
      IF(NBRANC.EQ.1)GOTO 100                                           CMBRAN     34
      J=0                                                               CMBRAN     35
      JJ=NBRANC-1                                                       CMBRAN     36
 40   J=J+1                                                             CMBRAN     37
      NJ=ITBUS(J)                                                       CMBRAN     38
      IF(NJ.GT.0)THEN                                                   CMBRAN     39
      IENDA=ILBRIX(J)                                                   CMBRAN     40
      KT=(IENDA+1)/2                                                    CMBRAN     41
       K=J                                                              CMBRAN     42
 50    K=K+1                                                            CMBRAN     43
       NK=ITBUS(K)                                                      CMBRAN     44
        IF(NK.EQ.NJ)THEN                                                CMBRAN     45
        IENDB=ILBRIX(K)                                                 CMBRAN     46
        KS=(IENDB+1)/2                                                  CMBRAN     47
        IPOB=KS+KS                                                      CMBRAN     48
        IPOA=IPOB-1                                                     CMBRAN     49
        BRAU(KT)=BRAU(KT)+BRAU(KS)                                      CMBRAN     50
        BRAL(KT)=BRAL(KT)+BRAL(KS)                                      CMBRAN     51
C        BRAU(KS)=BRAU(KT)                                              CMBRAN     52
C        BRAL(KS)=BRAL(KT)                                              CMBRAN     53
        ITBUS(K)=-1                                                     CMBRAN     54
        KTNO(IPOA)=0                                                    CMBRAN     55
        KTNO(IPOB)=0                                                    CMBRAN     56
        ENDIF                                                           CMBRAN     57
       IF(K.LT.NBRANC)GOTO 50                                           CMBRAN     58
      ENDIF                                                             CMBRAN     59
      IF(J.LT.JJ)GOTO 40                                                CMBRAN     60
 100  CONTINUE                                                          CMBRAN     61
      RETURN                                                            CMBRAN     62
      END                                                               CMBRAN     63
