CFPRIME USTRNG                                                          USTRNG      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  USTRNG (STRING, VALUE, JBLK, TABLES)                  USTRNG      3
CD -------------------------------------------------------------------  USTRNG      4
CD                                                                      USTRNG      5
CD              *****     USTRNG  ROUTINE   *****                       USTRNG      6
CD                                                                      USTRNG      7
CD -------------------------------------------------------------------  USTRNG      8
CD                                                                      USTRNG      9
CD       PURPOSE:  Compares the variable "STRING" with the list of      USTRNG     10
CD                 known character string constants, searching only     USTRNG     11
CD                 the tables indicated. If a match is found, it        USTRNG     12
CD                 returns the numeric equivalent of the string.        USTRNG     13
CD                                                                      USTRNG     14
CD                                                                      USTRNG     15
CD       DEFINITION OF LOCAL VARIABLES:                                 USTRNG     16
CD          (P)    JBLK    -  udc block containing the input string.    USTRNG     17
CD                 FOUND  -  indicates that search was successful.      USTRNG     18
CD                 I      - 'Do' loop index.                            USTRNG     19
CD                 II     -  index value.                               USTRNG     20
CD                 J      - 'Do' loop index.                            USTRNG     21
CD                 JJ     -  index value.                               USTRNG     22
CD          (P)    STRING -  input character string.                    USTRNG     23
CD          (P)    TABLES -  the tables to be searched.                 USTRNG     24
CD          (P)    VALUE  -  equivalent real value.                     USTRNG     25
CD                 RUNMOD -  converts interface character output into   USTRNG     26
CD                           its numeric equivalent.                    USTRNG     27
CD                 CONVRT -  converts initial mode character string intoUSTRNG     28
CD                           its numeric equivalent.                    USTRNG     29
CD                 INTMOD -  converts run mode character string into itsUSTRNG     30
CD                           numeric equivalent.                        USTRNG     31
CD                                                                      USTRNG     32
CD ---------------------------------------------------------------------USTRNG     33
      INCLUDE 'CNUNIT.INS'                                              USTRNG     34
      INCLUDE 'CNMSG.INS'                                               USTRNG     35
      INCLUDE 'PARX.INS'                                                USTRNG     36
      INCLUDE 'UDCA.INS'                                                USTRNG     37
C                                                                       USTRNG     38
      DIMENSION       CONVRT(7,7), CONVRR(10,10)                        USTRNG     39
C                                                                       USTRNG     40
      LOGICAL       FOUND                                               USTRNG     41
C                                                                       USTRNG     42
      CHARACTER*72  STRING, WORD                                        USTRNG     43
      CHARACTER*20  SUBNAM                                              USTRNG     44
      CHARACTER*8   RUNMOD(10)                                          USTRNG     45
      CHARACTER*3   TABLES                                              USTRNG     46
      CHARACTER*2   INTMOD(10)                                          USTRNG     47
C                                                                       USTRNG     48
C                                                                       USTRNG     49
      DATA          INTMOD    /                                         USTRNG     50
     1   'VD'      ,   'ID'      ,   'AL'      ,   'GA'      ,          USTRNG     51
     2   'PA'      ,   'QA'      ,   'AT'      ,   'BY'      ,          USTRNG     52
     3   'CF'      ,   'BK'      /                                      USTRNG     53
C                                                                       USTRNG     54
C                                                                       USTRNG     55
      DATA          RUNMOD    /                                         USTRNG     56
     1   'VOLTAGE' ,   'CURRENT' ,   'ALPHA'   ,   'GAMMA'   ,          USTRNG     57
     2   ' '       ,   ' '       ,   ' '       ,   'BYPASS'  ,          USTRNG     58
     3   'COMFAIL' ,   'BLOCK'   /                                      USTRNG     59
C                                                                       USTRNG     60
      DATA CONVRT /  0,    11,    12,    13,    14,    15,    16,       USTRNG     61
     1              11,     0,    17,    18,    19,    20,    21,       USTRNG     62
     2              12,    17,     0,    22,    23,    24,    25,       USTRNG     63
     3              13,    18,    22,     0,    26,    27,    28,       USTRNG     64
     4              14,    19,    23,    26,     0,    29,    30,       USTRNG     65
     5              15,    20,    24,    27,    29,     0,    31,       USTRNG     66
     6              16,    21,    25,    28,    30,    31,     0  /     USTRNG     67
C                                                                       USTRNG     68
      DATA CONVRR /  0,   0,  11,  12,   0,   0,   0,   8,   9,  10,    USTRNG     69
     1               0,   0,  13,  14,   0,   0,   0,   8,   9,  10,    USTRNG     70
     2              11,  13,   0,  15,   0,   0,   0,   8,   9,  10,    USTRNG     71
     3              12,  14,  15,   0,   0,   0,   0,   8,   9,  10,    USTRNG     72
     4               1,   2,   3,   4,   0,   0,   0,   8,   9,  10,    USTRNG     73
     5               1,   2,   3,   4,   0,   0,   0,   8,   9,  10,    USTRNG     74
     6               1,   2,   3,   4,   0,   0,   0,   8,   9,  10,    USTRNG     75
     7               8,   8,   8,   8,   0,   0,   0,   8,   9,  10,    USTRNG     76
     8               9,   9,   9,   9,   0,   0,   0,   8,   9,  10,    USTRNG     77
     9              10,  10,  10,  10,   0,   0,   0,   8,   9,  10 /   USTRNG     78
C                                                                       USTRNG     79
C---------------------------------------------------------------------  USTRNG     80
C                                                                       USTRNG     81
      IF (SDBG) THEN                                                    USTRNG     82
         SUBNAM = 'USTRNG ROUTINE.'                                     USTRNG     83
      ELSE                                                              USTRNG     84
         SUBNAM = ' '                                                   USTRNG     85
      END IF                                                            USTRNG     86
C                                                                       USTRNG     87
      WORD = STRING                                                     USTRNG     88
C                                                                       USTRNG     89
C     Remove the quotes from the input string.                          USTRNG     90
C                                                                       USTRNG     91
      IF (WORD(1:1) .EQ. '''') THEN                                     USTRNG     92
         WORD(1:71) = WORD(2:72)                                        USTRNG     93
         WORD(72:72) = ' '                                              USTRNG     94
C                                                                       USTRNG     95
         DO 20 II = 1, 72                                               USTRNG     96
            IF (WORD(II:II) .EQ. '''') THEN                             USTRNG     97
               WORD(II:II) = ' '                                        USTRNG     98
            END IF                                                      USTRNG     99
20       CONTINUE                                                       USTRNG    100
      END IF                                                            USTRNG    101
C                                                                       USTRNG    102
C                                                                       USTRNG    103
      FOUND = .FALSE.                                                   USTRNG    104
C                                                                       USTRNG    105
      IF (TABLES(1:1) .NE. ' ') THEN                                    USTRNG    106
C                                                                       USTRNG    107
C        Compare the input string to the list of initial modes. (This   USTRNG    108
C        is a two part comparison.)                                     USTRNG    109
C                                                                       USTRNG    110
         II = 0                                                         USTRNG    111
         DO 40 I = 1, 7                                                 USTRNG    112
            IF (WORD(1:2) .EQ. INTMOD(I)) THEN                          USTRNG    113
               II = I                                                   USTRNG    114
            END IF                                                      USTRNG    115
40       CONTINUE                                                       USTRNG    116
C                                                                       USTRNG    117
         JJ = 0                                                         USTRNG    118
         DO 60 J = 1, 7                                                 USTRNG    119
            IF (WORD(3:4) .EQ. INTMOD(J)) THEN                          USTRNG    120
               JJ = J                                                   USTRNG    121
            END IF                                                      USTRNG    122
60       CONTINUE                                                       USTRNG    123
C                                                                       USTRNG    124
         KK = 0                                                         USTRNG    125
         DO 70 K = 1, 7                                                 USTRNG    126
            IF (WORD(5:6) .EQ. INTMOD(K)) THEN                          USTRNG    127
               KK = K                                                   USTRNG    128
            END IF                                                      USTRNG    129
70       CONTINUE                                                       USTRNG    130
C                                                                       USTRNG    131
         IF (II .NE. 0 .AND. JJ .NE. 0) THEN                            USTRNG    132
            VALUE = REAL (CONVRT(II,JJ)) + 100 * KK                     USTRNG    133
            FOUND = .TRUE.                                              USTRNG    134
         END IF                                                         USTRNG    135
      END IF                                                            USTRNG    136
C                                                                       USTRNG    137
      IF (TABLES(2:2) .NE. ' ' .AND. .NOT. FOUND) THEN                  USTRNG    138
C                                                                       USTRNG    139
C        Compare the string to the list of running modes.               USTRNG    140
C                                                                       USTRNG    141
         II = 0                                                         USTRNG    142
         DO 80 I = 1, 10                                                USTRNG    143
            IF (WORD(1:8) .EQ. RUNMOD(I)) THEN                          USTRNG    144
               II = I                                                   USTRNG    145
            END IF                                                      USTRNG    146
80       CONTINUE                                                       USTRNG    147
C                                                                       USTRNG    148
         JJ = 0                                                         USTRNG    149
         DO 90 J = 1, 10                                                USTRNG    150
            IF (WORD(9:16) .EQ. RUNMOD(J)) THEN                         USTRNG    151
               JJ = J                                                   USTRNG    152
            END IF                                                      USTRNG    153
90       CONTINUE                                                       USTRNG    154
C                                                                       USTRNG    155
         IF (II .NE. 0) THEN                                            USTRNG    156
            IF(JJ .EQ. 0) THEN                                          USTRNG    157
               VALUE = REAL(II)                                         USTRNG    158
            ELSE                                                        USTRNG    159
               VALUE = REAL(CONVRR(II,JJ))                              USTRNG    160
            ENDIF                                                       USTRNG    161
            FOUND = .TRUE.                                              USTRNG    162
         END IF                                                         USTRNG    163
      END IF                                                            USTRNG    164
C                                                                       USTRNG    165
      IF (TABLES(3:3) .NE. ' ' .AND. .NOT. FOUND) THEN                  USTRNG    166
C                                                                       USTRNG    167
C        Compare the string to the breaker status values.               USTRNG    168
C                                                                       USTRNG    169
         IF (WORD .EQ. 'OPEN' .OR.                                      USTRNG    170
     1       WORD .EQ. 'OPENED') THEN                                   USTRNG    171
            VALUE = REAL(IOPEND)                                        USTRNG    172
            FOUND = .TRUE.                                              USTRNG    173
         ELSE IF (WORD .EQ. 'CLOSED') THEN                              USTRNG    174
            VALUE = REAL(ICLOSE)                                        USTRNG    175
            FOUND = .TRUE.                                              USTRNG    176
         ELSE IF (WORD .EQ. 'OPENING') THEN                             USTRNG    177
            VALUE = REAL(IOPENG)                                        USTRNG    178
            FOUND = .TRUE.                                              USTRNG    179
         END IF                                                         USTRNG    180
C                                                                       USTRNG    181
      END IF                                                            USTRNG    182
C                                                                       USTRNG    183
      IF (.NOT. FOUND) THEN                                             USTRNG    184
C                                                                       USTRNG    185
C        If the string has not been recognized by this point            USTRNG    186
C        there is an error.                                             USTRNG    187
C                                                                       USTRNG    188
         WRITE(MSG(1),9002) SUBNAM                                      USTRNG    189
         WRITE(MSG(3),9004) UDNAME(JBLK)                                USTRNG    190
         WRITE(MSG(4),9005) WORD                                        USTRNG    191
         WRITE(MSG(2),9003)                                             USTRNG    192
         WRITE(MSG(5),9006)                                             USTRNG    193
         CALL PRTMSG(5)                                                 USTRNG    194
         VALUE = 0.0                                                    USTRNG    195
      END IF                                                            USTRNG    196
C                                                                       USTRNG    197
C                                                                       USTRNG    198
C---------------------------------------------------------------------- USTRNG    199
C                                                                       USTRNG    200
      RETURN                                                            USTRNG    201
C                                                                       USTRNG    202
C---------------------------------------------------------------------- USTRNG    203
C                                                                       USTRNG    204
9002  FORMAT(' *** MTDC WARNING', 5X, A)                                USTRNG    205
9003  FORMAT(14X,'DURING THE READING OF UDC BLOCKS, BLOCK')             USTRNG    206
9004  FORMAT(14X,'"', A, '" CONTAINS THE STRING')                       USTRNG    207
9005  FORMAT(1X,'"',A, '".')                                            USTRNG    208
9006  FORMAT(14X,'IS THIS AN ERROR IN THE UDC INPUT FILE?')             USTRNG    209
C                                                                       USTRNG    210
C---------------------------------------------------------------------- USTRNG    211
C                                                                       USTRNG    212
      END                                                               USTRNG    213
