CFPRIME CHKBUS                                                          CHKBUS      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 CHKBUS(BUS,IBUS)                                       CHKBUS      3
CD                                                                      CHKBUS      4
CD    TO PERFORME AN EXPONENTIAL SEARCH TO CHECK A BUS NAME BASED ON THECHKBUS      5
CD    LOAD FLOW CASE AND RETURN THE CORRESPONDING BUS NUMBER "IBUS". IF CHKBUS      6
CD    NO MATCH IS FOUND, "IBUS" IS SET TO 0.                            CHKBUS      7
CD                                                                      CHKBUS      8
      INCLUDE 'PARX.INS'                                                CHKBUS      9
      INCLUDE 'EPBUS.INS'                                               CHKBUS     10
*IF -PRIME                                                              CHKBUS     11
C                                                                       CHKBUS     12
      CHARACTER *(*) BUS                                                CHKBUS     13
      CHARACTER*12 NAME                                                 CHKBUS     14
      CHARACTER*12 CNAMES(NB)                                           CHKBUS     15
C                                                                       CHKBUS     16
C  INTNUM() CROSSREF FOR BUS NAME TO BUS NUMBER                         CHKBUS     17
C                                                                       CHKBUS     18
      EQUIVALENCE (INAMES(1,1),CNAMES(1))                               CHKBUS     19
C                                                                       CHKBUS     20
C--------------------------------------------------                     CHKBUS     21
C  BINARY SEARCH FOR BUS NAME FROM INAMES() ARRAYS                      CHKBUS     22
C--------------------------------------------------                     CHKBUS     23
C                                                                       CHKBUS     24
      MIN=1                                                             CHKBUS     25
      MAX=NOBUS                                                         CHKBUS     26
      MID=0                                                             CHKBUS     27
 1000 CONTINUE                                                          CHKBUS     28
      IF (MIN.LE.MAX) THEN                                              CHKBUS     29
        MID=(MAX+MIN)/2                                                 CHKBUS     30
        NAME = CNAMES(MID)                                              CHKBUS     31
        IF (BUS .LT. NAME) THEN                                         CHKBUS     32
           MAX=MID-1                                                    CHKBUS     33
        ELSE                                                            CHKBUS     34
           IF (BUS .GT.NAME) THEN                                       CHKBUS     35
              MIN=MID+1                                                 CHKBUS     36
           ELSE                                                         CHKBUS     37
C             FOUND IT .. SET IBUS TO BUS NUMBER.                       CHKBUS     38
              IBUS=INTNUM(MID)                                          CHKBUS     39
              GO TO 990                                                 CHKBUS     40
           ENDIF                                                        CHKBUS     41
        ENDIF                                                           CHKBUS     42
        GO TO 1000                                                      CHKBUS     43
      ENDIF                                                             CHKBUS     44
C                                                                       CHKBUS     45
C----------------------------------------------------                   CHKBUS     46
C     No match found. Flag condition with IBUS = 0                      CHKBUS     47
C     and repeat search using A8, F4.0 match.                           CHKBUS     48
C----------------------------------------------------                   CHKBUS     49
C                                                                       CHKBUS     50
      IBUS=0                                                            CHKBUS     51
      READ (BUS(9:12), 1030, IOSTAT=IOS) BASE2                          CHKBUS     52
      IF (IOS.NE.0) RETURN                                              CHKBUS     53
 1010 IF (MID .GT. NOBUS) THEN                                          CHKBUS     54
         MID = MID - 1                                                  CHKBUS     55
         GO TO 1010                                                     CHKBUS     56
      ELSE IF (MID .GT. 0) THEN                                         CHKBUS     57
C                                                                       CHKBUS     58
        NAME = CNAMES(MID)                                              CHKBUS     59
         IF (NAME(1:8) .GE. BUS(1:8)) THEN                              CHKBUS     60
            MID = MID - 1                                               CHKBUS     61
            GO TO 1010                                                  CHKBUS     62
         ENDIF                                                          CHKBUS     63
      ENDIF                                                             CHKBUS     64
      I = MID + 1                                                       CHKBUS     65
      DO 1040 MID = I, NOBUS                                            CHKBUS     66
         NAME = CNAMES(MID)                                             CHKBUS     67
         IF (NAME(1:8) .EQ. BUS(1:8)) THEN                              CHKBUS     68
            READ (NAME(9:12), 1030, IOSTAT=IOS) BASE1                   CHKBUS     69
            IF (IOS.NE.0) GOTO 1040                                     CHKBUS     70
            IF (BASE1 .EQ. BASE2) THEN                                  CHKBUS     71
               IBUS = INTNUM(MID)                                       CHKBUS     72
               GO TO 990                                                CHKBUS     73
            ENDIF                                                       CHKBUS     74
         ELSE                                                           CHKBUS     75
            GO TO 990                                                   CHKBUS     76
         ENDIF                                                          CHKBUS     77
 1040 CONTINUE                                                          CHKBUS     78
 990  CONTINUE                                                          CHKBUS     79
C                                                                       CHKBUS     80
 1030 FORMAT (F4.0)                                                     CHKBUS     81
C                                                                       CHKBUS     82
*ENDIF                                                                  CHKBUS     83
*IF PRIME                                                               CHKBUS     84
*ENDIF                                                                  CHKBUS    158
C                                                                       CHKBUS    159
      RETURN                                                            CHKBUS    160
      END                                                               CHKBUS    161
      SUBROUTINE CHKGEN(IPBNO,MCID,IMAC)                                CHKBUS    162
C                                                                       CHKBUS    163
      INCLUDE 'PARX.INS'                                                CHKBUS    164
      INCLUDE 'CNB1.INS'                                                CHKBUS    165
      INCLUDE 'CNIPTR.INS'                                              CHKBUS    166
C                                                                       CHKBUS    167
      CHARACTER*4 MCID                                                  CHKBUS    168
C                                                                       CHKBUS    169
      IFIN=NTHG(IPBNO+1)-1                                              CHKBUS    170
      IMAC=NTHG(IPBNO)-1                                                CHKBUS    171
 160  IMAC=IMAC+1                                                       CHKBUS    172
C                                                                       CHKBUS    173
      IF(MCID.EQ.NDGC(IMAC))RETURN                                      CHKBUS    174
C                                                                       CHKBUS    175
      IF(IMAC.LT.IFIN)GOTO 160                                          CHKBUS    176
C                                                                       CHKBUS    177
      IMAC=0                                                            CHKBUS    178
C                                                                       CHKBUS    179
      RETURN                                                            CHKBUS    180
C                                                                       CHKBUS    181
      END                                                               CHKBUS    182
C                                                                       CHKBUS    183
      SUBROUTINE CHKSVC(IPBNO,UID,IMAC)                                 CHKBUS    184
C                                                                       CHKBUS    185
      INCLUDE 'PARX.INS'                                                CHKBUS    186
      INCLUDE 'CNB1.INS'                                                CHKBUS    187
      INCLUDE 'CNIPTR.INS'                                              CHKBUS    188
C                                                                       CHKBUS    189
      CHARACTER*4 UID                                                   CHKBUS    190
C                                                                       CHKBUS    191
C     SVC BUS MATCH                                                     CHKBUS    192
C                                                                       CHKBUS    193
      IMAC=NTHSR(3,IPBNO)                                               CHKBUS    194
      IF(UID.NE.NSVCID(IMAC))IMAC=0                                     CHKBUS    195
C                                                                       CHKBUS    196
      END                                                               CHKBUS    197
