CFPRIME URDEFN                                                          URDEFN      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  URDEFN                                                URDEFN      3
CD -------------------------------------------------------------------  URDEFN      4
CD                                                                      URDEFN      5
CD              *****     URDEFN  ROUTINE   *****                       URDEFN      6
CD                                                                      URDEFN      7
CD -------------------------------------------------------------------  URDEFN      8
CD                                                                      URDEFN      9
CD       PURPOSE:  Defines all the block names with an internal         URDEFN     10
CD                 number.                                              URDEFN     11
CD                                                                      URDEFN     12
CD                                                                      URDEFN     13
CD       DEFINITION OF LOCAL VARIABLES:                                 URDEFN     14
CD                 FOUND  -  indicates a successful search for block    URDEFN     15
CD                           name.                                      URDEFN     16
CD                 I      - 'do' loop index.                            URDEFN     17
CD                 J      - 'do' loop index.                            URDEFN     18
CD                 K      - 'do' loop index.                            URDEFN     19
CD                 LEN    -  length of udc block name.                  URDEFN     20
CD                 NEXT   -  pointer to current entry in linked list.   URDEFN     21
CD                 SUBNAM -  subroutine name.                           URDEFN     22
CD                                                                      URDEFN     23
CD -------------------------------------------------------------------  URDEFN     24
      INCLUDE 'CNUNIT.INS'                                              URDEFN     25
      INCLUDE 'PARX.INS'                                                URDEFN     26
      INCLUDE 'UDCA.INS'                                                URDEFN     27
      INCLUDE 'UDCB.INS'                                                URDEFN     28
      INCLUDE 'UDCD.INS'                                                URDEFN     29
      INCLUDE 'UDCE.INS'                                                URDEFN     30
      INCLUDE 'UDCH.INS'                                                URDEFN     31
      INCLUDE 'CNFLAG.INS'                                              URDEFN     32
      INCLUDE 'CNMSG.INS'                                               URDEFN     33
C                                                                       URDEFN     34
      LOGICAL       FOUND                                               URDEFN     35
C                                                                       URDEFN     36
      CHARACTER*20  SUBNAM                                              URDEFN     37
C                                                                       URDEFN     38
C---------------------------------------------------------------------  URDEFN     39
C                                                                       URDEFN     40
      LDEB=((JDEB(301).NE.0).AND.(JDEB(305).NE.0))                      URDEFN     41
C                                                                       URDEFN     42
      IF (SDBG) THEN                                                    URDEFN     43
         SUBNAM = 'URDEFN ROUTINE.'                                     URDEFN     44
      ELSE                                                              URDEFN     45
         SUBNAM = ' '                                                   URDEFN     46
      END IF                                                            URDEFN     47
C                                                                       URDEFN     48
C                                                                       URDEFN     49
      DO 160 I = 1, IUDC                                                URDEFN     50
C                                                                       URDEFN     51
         K = IUNIPT(I)                                                  URDEFN     52
20       IF (K .EQ. 0) GO TO 60                                         URDEFN     53
C                                                                       URDEFN     54
            IF (UIDENT(K) .NE. ' ' .AND.                                URDEFN     55
     1          UIDENT(K) .NE. STARS(1:17)) THEN                        URDEFN     56
               FOUND = .FALSE.                                          URDEFN     57
C                                                                       URDEFN     58
               DO 40 J = 1, IUDC                                        URDEFN     59
                  IF (UIDENT(K) .EQ. UDNAME(J)) THEN                    URDEFN     60
                     FOUND = .TRUE.                                     URDEFN     61
                     IUDINT(K) = J                                      URDEFN     62
                  END IF                                                URDEFN     63
40             CONTINUE                                                 URDEFN     64
C                                                                       URDEFN     65
               IF (.NOT. FOUND) THEN                                    URDEFN     66
                  LEN = IUDLEN(I)                                       URDEFN     67
                  WRITE (MSG(1),9002) SUBNAM                            URDEFN     68
                  WRITE(MSG(2),9003)                                    URDEFN     69
                  WRITE(MSG(3),9005) UIDENT(K)                          URDEFN     70
                  WRITE(MSG(4),9006) UDNAME(I)(1:LEN)                   URDEFN     71
                  WRITE(MSG(5),9007)                                    URDEFN     72
                  CALL PRTMSG(5)                                        URDEFN     73
                  IERCNT = IERCNT + 1                                   URDEFN     74
               END IF                                                   URDEFN     75
C                                                                       URDEFN     76
            END IF                                                      URDEFN     77
            K = IUDINX(K)                                               URDEFN     78
            GO TO 20                                                    URDEFN     79
60       CONTINUE                                                       URDEFN     80
C                                                                       URDEFN     81
C                                                                       URDEFN     82
         K = IUDRPT(I)                                                  URDEFN     83
80       IF (K .EQ. 0)  GO TO 140                                       URDEFN     84
            IF (UDBLK1(K) .NE. ' ' .AND. IUDBNM(K) .GE. 0 .AND.         URDEFN     85
     1          UDBLK1(K) .NE. STARS) THEN                              URDEFN     86
               FOUND = .FALSE.                                          URDEFN     87
               DO 100 J = 1, IUDC                                       URDEFN     88
                  IF (UDBLK1(K) .EQ. UDNAME(J)) THEN                    URDEFN     89
                     FOUND = .TRUE.                                     URDEFN     90
                     IUDBNM(K) = J                                      URDEFN     91
                  END IF                                                URDEFN     92
100            CONTINUE                                                 URDEFN     93
               IF (.NOT. FOUND) THEN                                    URDEFN     94
                  LEN = IUDLEN(I)                                       URDEFN     95
                  WRITE (MSG(1),9002) SUBNAM                            URDEFN     96
                  WRITE(MSG(2),9003)                                    URDEFN     97
                  WRITE(MSG(3),9005) UDBLK1(K)                          URDEFN     98
                  WRITE(MSG(4),9006) UDNAME(I)(1:LEN)                   URDEFN     99
                  WRITE(MSG(5),9007)                                    URDEFN    100
                  CALL PRTMSG(5)                                        URDEFN    101
                  IERCNT = IERCNT + 1                                   URDEFN    102
               END IF                                                   URDEFN    103
            END IF                                                      URDEFN    104
C                                                                       URDEFN    105
            IF (UDBLK2(K) .NE. ' ' .AND. JUDBNM(K) .GE. 0 .AND.         URDEFN    106
     1          UDBLK2(K) .NE. STARS) THEN                              URDEFN    107
               FOUND = .FALSE.                                          URDEFN    108
               DO 120 J = 1, IUDC                                       URDEFN    109
                  IF (UDBLK2(K) .EQ. UDNAME(J)) THEN                    URDEFN    110
                     FOUND = .TRUE.                                     URDEFN    111
                     JUDBNM(K) = J                                      URDEFN    112
                  END IF                                                URDEFN    113
120            CONTINUE                                                 URDEFN    114
               IF (.NOT. FOUND) THEN                                    URDEFN    115
                  LEN = IUDLEN(I)                                       URDEFN    116
                  WRITE (MSG(1),9002) SUBNAM                            URDEFN    117
                  WRITE(MSG(2),9003)                                    URDEFN    118
                  WRITE(MSG(3),9005) UDBLK2(K)                          URDEFN    119
                  WRITE(MSG(4),9006) UDNAME(I)(1:LEN)                   URDEFN    120
                  WRITE(MSG(5),9007)                                    URDEFN    121
                  CALL PRTMSG(5)                                        URDEFN    122
                  IERCNT = IERCNT + 1                                   URDEFN    123
               END IF                                                   URDEFN    124
            END IF                                                      URDEFN    125
C                                                                       URDEFN    126
C                                                                       URDEFN    127
            K = IUDRNX(K)                                               URDEFN    128
            GO TO 80                                                    URDEFN    129
C                                                                       URDEFN    130
140      CONTINUE                                                       URDEFN    131
160   CONTINUE                                                          URDEFN    132
C                                                                       URDEFN    133
C---------------------------------------------------------------------  URDEFN    134
C                                                                       URDEFN    135
C     Define all block names that are on the START list, and the        URDEFN    136
C     subsystem list as their numerical equivalents.                    URDEFN    137
C                                                                       URDEFN    138
      NEXT = IFXSTR                                                     URDEFN    139
180   IF (NEXT .EQ. 0) GO TO 240                                        URDEFN    140
         IF (FXNAM1(NEXT) .NE. ' ') THEN                                URDEFN    141
            FOUND = .FALSE.                                             URDEFN    142
            DO 200 J = 1, IUDC                                          URDEFN    143
               IF (FXNAM1(NEXT) .EQ. UDNAME(J)) THEN                    URDEFN    144
                  FOUND = .TRUE.                                        URDEFN    145
                  IFXNUM(NEXT) = J                                      URDEFN    146
               END IF                                                   URDEFN    147
200         CONTINUE                                                    URDEFN    148
            IF (.NOT. FOUND) THEN                                       URDEFN    149
                  WRITE (MSG(1),9002) SUBNAM                            URDEFN    150
                  WRITE(MSG(2),9003)                                    URDEFN    151
                  WRITE(MSG(3),9005) FXNAM1(NEXT)                       URDEFN    152
                  WRITE(MSG(4),9007)                                    URDEFN    153
                  CALL PRTMSG(4)                                        URDEFN    154
               IERCNT = IERCNT + 1                                      URDEFN    155
            END IF                                                      URDEFN    156
         END IF                                                         URDEFN    157
         IF (FXNAM2(NEXT) .NE. ' ') THEN                                URDEFN    158
            FOUND = .FALSE.                                             URDEFN    159
            DO 220 J = 1, IUDC                                          URDEFN    160
               IF (FXNAM2(NEXT) .EQ. UDNAME(J)) THEN                    URDEFN    161
                  FOUND = .TRUE.                                        URDEFN    162
                  JFXNUM(NEXT) = J                                      URDEFN    163
               END IF                                                   URDEFN    164
220         CONTINUE                                                    URDEFN    165
            IF (.NOT. FOUND) THEN                                       URDEFN    166
                  WRITE (MSG(1),9002) SUBNAM                            URDEFN    167
                  WRITE(MSG(2),9003)                                    URDEFN    168
                  WRITE(MSG(3),9005) FXNAM2(NEXT)                       URDEFN    169
                  WRITE(MSG(4),9007)                                    URDEFN    170
                  CALL PRTMSG(4)                                        URDEFN    171
               IERCNT = IERCNT + 1                                      URDEFN    172
            END IF                                                      URDEFN    173
         END IF                                                         URDEFN    174
         NEXT = IFXNEX(NEXT)                                            URDEFN    175
         GO TO 180                                                      URDEFN    176
240   CONTINUE                                                          URDEFN    177
C                                                                       URDEFN    178
C                                                                       URDEFN    179
C     Resolve the block names on the run mode block list.               URDEFN    180
C                                                                       URDEFN    181
      NEXT = IFXRMO                                                     URDEFN    182
260   IF (NEXT .EQ. 0) GO TO 300                                        URDEFN    183
         IF (FXINAM(NEXT) .NE. ' ') THEN                                URDEFN    184
            FOUND = .FALSE.                                             URDEFN    185
            DO 280 J = 1, IUDC                                          URDEFN    186
               IF (FXINAM(NEXT) .EQ. UDNAME(J)) THEN                    URDEFN    187
                  FOUND = .TRUE.                                        URDEFN    188
                  IFINUM(NEXT) = J                                      URDEFN    189
               END IF                                                   URDEFN    190
280         CONTINUE                                                    URDEFN    191
            IF (.NOT. FOUND) THEN                                       URDEFN    192
                  WRITE (MSG(1),9002) SUBNAM                            URDEFN    193
                  WRITE(MSG(2),9003)                                    URDEFN    194
                  WRITE(MSG(3),9005) FXINAM(NEXT)                       URDEFN    195
                  WRITE(MSG(4),9007)                                    URDEFN    196
                  CALL PRTMSG(4)                                        URDEFN    197
               IERCNT = IERCNT + 1                                      URDEFN    198
            END IF                                                      URDEFN    199
         END IF                                                         URDEFN    200
         NEXT = IFXNEX(NEXT)                                            URDEFN    201
         GO TO 260                                                      URDEFN    202
300   CONTINUE                                                          URDEFN    203
C                                                                       URDEFN    204
C                                                                       URDEFN    205
C                                                                       URDEFN    206
      NEXT = IFXSUB                                                     URDEFN    207
320   IF (NEXT .EQ. 0) GO TO 400                                        URDEFN    208
         IF (FXINAM(NEXT) .NE. ' ') THEN                                URDEFN    209
            FOUND = .FALSE.                                             URDEFN    210
            DO 340 J = 1, IUDC                                          URDEFN    211
               IF (FXINAM(NEXT) .EQ. UDNAME(J)) THEN                    URDEFN    212
                  FOUND = .TRUE.                                        URDEFN    213
                  IFINUM(NEXT) = J                                      URDEFN    214
               END IF                                                   URDEFN    215
340         CONTINUE                                                    URDEFN    216
            IF (.NOT. FOUND) THEN                                       URDEFN    217
                  WRITE (MSG(1),9002) SUBNAM                            URDEFN    218
                  WRITE(MSG(2),9003)                                    URDEFN    219
                  WRITE(MSG(3),9005) FXINAM(NEXT)                       URDEFN    220
                  WRITE(MSG(4),9007)                                    URDEFN    221
                  CALL PRTMSG(4)                                        URDEFN    222
               IERCNT = IERCNT + 1                                      URDEFN    223
            END IF                                                      URDEFN    224
         END IF                                                         URDEFN    225
         IF (FXNAM1(NEXT) .NE. ' ') THEN                                URDEFN    226
            FOUND = .FALSE.                                             URDEFN    227
            DO 360 J = 1, IUDC                                          URDEFN    228
               IF (FXNAM1(NEXT) .EQ. UDNAME(J)) THEN                    URDEFN    229
                  FOUND = .TRUE.                                        URDEFN    230
                  IFXNUM(NEXT) = J                                      URDEFN    231
               END IF                                                   URDEFN    232
360         CONTINUE                                                    URDEFN    233
            IF (.NOT. FOUND) THEN                                       URDEFN    234
                  WRITE (MSG(1),9002) SUBNAM                            URDEFN    235
                  WRITE(MSG(2),9003)                                    URDEFN    236
                  WRITE(MSG(3),9005) FXNAM1(NEXT)                       URDEFN    237
                  WRITE(MSG(4),9007)                                    URDEFN    238
                  CALL PRTMSG(4)                                        URDEFN    239
               IERCNT = IERCNT + 1                                      URDEFN    240
            END IF                                                      URDEFN    241
         END IF                                                         URDEFN    242
         IF (FXNAM2(NEXT) .NE. ' ') THEN                                URDEFN    243
            FOUND = .FALSE.                                             URDEFN    244
            DO 380 J = 1, IUDC                                          URDEFN    245
               IF (FXNAM2(NEXT) .EQ. UDNAME(J)) THEN                    URDEFN    246
                  FOUND = .TRUE.                                        URDEFN    247
                  JFXNUM(NEXT) = J                                      URDEFN    248
               END IF                                                   URDEFN    249
380         CONTINUE                                                    URDEFN    250
            IF (.NOT. FOUND) THEN                                       URDEFN    251
                  WRITE (MSG(1),9002) SUBNAM                            URDEFN    252
                  WRITE(MSG(2),9003)                                    URDEFN    253
                  WRITE(MSG(3),9005) FXNAM2(NEXT)                       URDEFN    254
                  WRITE(MSG(4),9007)                                    URDEFN    255
                  CALL PRTMSG(4)                                        URDEFN    256
               IERCNT = IERCNT + 1                                      URDEFN    257
            END IF                                                      URDEFN    258
         END IF                                                         URDEFN    259
         NEXT = IFXNEX(NEXT)                                            URDEFN    260
         GO TO 320                                                      URDEFN    261
400   CONTINUE                                                          URDEFN    262
C                                                                       URDEFN    263
C                                                                       URDEFN    264
C     Resolve the block names that are on the Fortran block output      URDEFN    265
C     list.                                                             URDEFN    266
C                                                                       URDEFN    267
      NUMDUM = IDUMNX - 1                                               URDEFN    268
      IF (NUMDUM .GT. IDUMAX) NUMDUM = IDUMAX                           URDEFN    269
      DO 415 I = 1, NUMDUM                                              URDEFN    270
         FOUND = .FALSE.                                                URDEFN    271
         DO 410 J = 1, IUDC                                             URDEFN    272
            IF (DUMNAM(I) .EQ. UDNAME(J)) THEN                          URDEFN    273
               IDUMBK(I) = J                                            URDEFN    274
               FOUND = .TRUE.                                           URDEFN    275
            END IF                                                      URDEFN    276
410      CONTINUE                                                       URDEFN    277
         IF (.NOT. FOUND) THEN                                          URDEFN    278
                  WRITE (MSG(1),9002) SUBNAM                            URDEFN    279
                  WRITE(MSG(2),9003)                                    URDEFN    280
                  WRITE(MSG(3),9005) DUMNAM(I)                          URDEFN    281
                  WRITE(MSG(4),9007)                                    URDEFN    282
                  CALL PRTMSG(4)                                        URDEFN    283
            IERCNT = IERCNT + 1                                         URDEFN    284
         END IF                                                         URDEFN    285
415   CONTINUE                                                          URDEFN    286
C                                                                       URDEFN    287
C                                                                       URDEFN    288
C---------------------------------------------------------------------  URDEFN    289
C                                                                       URDEFN    290
      IF (IERCNT .EQ. 0) THEN                                           URDEFN    291
C                                                                       URDEFN    292
C        Initialize the solution ordering linked lists.                 URDEFN    293
C                                                                       URDEFN    294
         DO 420 I = 1, IUDC                                             URDEFN    295
            IUDPRM(I) = 0                                               URDEFN    296
            IUDINV(I) = 0                                               URDEFN    297
420      CONTINUE                                                       URDEFN    298
C                                                                       URDEFN    299
C        Initialize the loop linked list.                               URDEFN    300
C                                                                       URDEFN    301
         DO 440 I = 1, NUDC                                             URDEFN    302
            LPTOP(I) = 0                                                URDEFN    303
            LPLEAD(I) = 0                                               URDEFN    304
            LPSUBS(I) = 0                                               URDEFN    305
440      CONTINUE                                                       URDEFN    306
C                                                                       URDEFN    307
         LPMAX = 0                                                      URDEFN    308
         LPFREE = 1                                                     URDEFN    309
         DO 460 I = 1, NUDC5                                            URDEFN    310
            LPNAME(I) = STARS                                           URDEFN    311
            LPNUM(I) = 0                                                URDEFN    312
            LPNEXT(I) = I + 1                                           URDEFN    313
460      CONTINUE                                                       URDEFN    314
         LPNEXT(NUDC5) = 0                                              URDEFN    315
C                                                                       URDEFN    316
C        Construct the input ordering lists and print them.             URDEFN    317
C                                                                       URDEFN    318
         CALL URLIST                                                    URDEFN    319
         IF (LDEB) CALL URPRNT ('***  INPUT ORDERING OF BLOCKS  ***')   URDEFN    320
      END IF                                                            URDEFN    321
C                                                                       URDEFN    322
C                                                                       URDEFN    323
C---------------------------------------------------------------------  URDEFN    324
C                                                                       URDEFN    325
      RETURN                                                            URDEFN    326
C                                                                       URDEFN    327
C---------------------------------------------------------------------  URDEFN    328
C                                                                       URDEFN    329
9002  FORMAT (' *** MTDC ERROR', 5X, A)                                 URDEFN    330
9003  FORMAT(11X,'DURING THE ORDERING OF THE UDC BLOCKS, BLOCK ')       URDEFN    331
9005  FORMAT(11X,'"', A, '" WAS NOT DEFINED IN THE UDC SYSTEM.')        URDEFN    332
9006  FORMAT(11X,'IS USED BY THE DEFINITION FOR UDC BLOCK "', A,        URDEFN    333
     4        '".')                                                     URDEFN    334
9007  FORMAT(11X,'CHECK YOUR UDC INPUT FILE FOR ERRORS.')               URDEFN    335
C                                                                       URDEFN    336
C---------------------------------------------------------------------  URDEFN    337
C                                                                       URDEFN    338
      END                                                               URDEFN    339
