CFPRIME URSTRC                                                          URSTRC      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  URSTRC                                                URSTRC      3
CD                                                                      URSTRC      4
CD              *****     URSTRCD ROUTINE   *****                       URSTRC      5
CD                                                                      URSTRC      6
CD -------------------------------------------------------------------  URSTRC      7
CD                                                                      URSTRC      8
CD       PURPOSE:  Reads a udc block of type STRUCTURE.  Depending on   URSTRC      9
CD                 the subtype, the corresponding group of blocks are   URSTRC     10
CD                 that were saved are read.  These block names are     URSTRC     11
CD                 expanded to include this udc block name.  When       URSTRC     12
CD                 required data has not been saved, hte values are     URSTRC     13
CD                 read from the input file.                            URSTRC     14
CD                                                                      URSTRC     15
CD                                                                      URSTRC     16
CD       DEFINITION OF LOCAL VARIABLES:                                 URSTRC     17
CD                 FLAG   -  unused flag which is needed in the call    URSTRC     18
CD                           to a routine.                              URSTRC     19
CD                 FOUND  -  search for data was successful.            URSTRC     20
CD                 I      - 'do' loop index.                            URSTRC     21
CD                 II     - 'do' loop index.                            URSTRC     22
CD                 NAME   -  title used for printing.                   URSTRC     23
CD                 SUBNAM -  subroutine name.                           URSTRC     24
CD                                                                      URSTRC     25
CD -------------------------------------------------------------------  URSTRC     26
      INCLUDE 'CNUNIT.INS'                                              URSTRC     27
      INCLUDE 'CNMSG.INS'                                               URSTRC     28
      INCLUDE 'PARX.INS'                                                URSTRC     29
      INCLUDE 'UDCA.INS'                                                URSTRC     30
      INCLUDE 'UDCH.INS'                                                URSTRC     31
      INCLUDE 'UDCI.INS'                                                URSTRC     32
C                                                                       URSTRC     33
      LOGICAL       FOUND, FLAG, VALID                                  URSTRC     34
C                                                                       URSTRC     35
      CHARACTER*72  NAME                                                URSTRC     36
      CHARACTER*20  SUBNAM                                              URSTRC     37
C                                                                       URSTRC     38
C---------------------------------------------------------------------  URSTRC     39
C                                                                       URSTRC     40
      IF (SDBG) THEN                                                    URSTRC     41
         SUBNAM = 'URSTRC ROUTINE.'                                     URSTRC     42
      ELSE                                                              URSTRC     43
         SUBNAM = ' '                                                   URSTRC     44
      END IF                                                            URSTRC     45
C                                                                       URSTRC     46
      IF (DEFINE) THEN                                                  URSTRC     47
C                                                                       URSTRC     48
C        A strcuture definition cannot be nested.  A structure block    URSTRC     49
C        cannot exist definition.                                       URSTRC     50
C                                                                       URSTRC     51
         EXPAND = .FALSE.                                               URSTRC     52
         WRITE (MSG(1),9000) SUBNAM                                     URSTRC     53
         WRITE(MSG(2),9001) SBSTRC(NMSTRC)                              URSTRC     54
         WRITE(MSG(3),9002) UDNAME(IUDC)                                URSTRC     55
         WRITE(MSG(4),9003)                                             URSTRC     56
         CALL PRTMSG(4)                                                 URSTRC     57
         IUDC = IUDC - 1                                                URSTRC     58
         IERCNT = IERCNT + 1                                            URSTRC     59
      ELSE                                                              URSTRC     60
C                                                                       URSTRC     61
C        This block has been added to the udc block list when it is     URSTRC     62
C        really a name of an expanded  structure.  Remove it from the   URSTRC     63
C        udc block list and begin the expansion of the structure.       URSTRC     64
C                                                                       URSTRC     65
         SRNAME = ' '                                                   URSTRC     66
         SRNAME = UDNAME(IUDC)                                          URSTRC     67
         ISRLEN = IUDLEN(IUDC)                                          URSTRC     68
         IUDC = IUDC - 1                                                URSTRC     69
C                                                                       URSTRC     70
C        Check if the subtype is defined.                               URSTRC     71
C                                                                       URSTRC     72
         ENDBLK = .FALSE.                                               URSTRC     73
         CALL URGETC (NAME, FOUND)                                      URSTRC     74
         IF (FOUND) THEN                                                URSTRC     75
            FOUND = .FALSE.                                             URSTRC     76
            ISRNUM = 0                                                  URSTRC     77
            DO 20 I = 1, NMSTRC                                         URSTRC     78
               IF (NAME .EQ. SBSTRC(I)) THEN                            URSTRC     79
                  ISRNUM = I                                            URSTRC     80
                  FOUND = .TRUE.                                        URSTRC     81
               END IF                                                   URSTRC     82
20          CONTINUE                                                    URSTRC     83
         END IF                                                         URSTRC     84
C                                                                       URSTRC     85
         IF (.NOT. FOUND) THEN                                          URSTRC     86
            WRITE (MSG(1),9000) SUBNAM                                  URSTRC     87
            WRITE(MSG(2),9004) SRNAME                                   URSTRC     88
            WRITE(MSG(3),9005) NAME(1:32)                               URSTRC     89
            WRITE(MSG(4),9010)                                          URSTRC     90
            CALL PRTMSG(4)                                              URSTRC     91
            EXPAND = .FALSE.                                            URSTRC     92
            IERCNT = IERCNT + 1                                         URSTRC     93
         ELSE                                                           URSTRC     94
            EXPAND = .TRUE.                                             URSTRC     95
         END IF                                                         URSTRC     96
      END IF                                                            URSTRC     97
C                                                                       URSTRC     98
C                                                                       URSTRC     99
      IF (EXPAND) THEN                                                  URSTRC    100
C                                                                       URSTRC    101
         IBKLAS = ISRTOP(ISRNUM)                                        URSTRC    102
40       IF (IBKLAS .EQ. 0) GO TO 60                                    URSTRC    103
C                                                                       URSTRC    104
C           Expand the generic structure using the specific name.       URSTRC    105
C           Add the "specific.blkname" to the udc system.               URSTRC    106
C                                                                       URSTRC    107
            NAME = ' '                                                  URSTRC    108
            NAME(1:ISRLEN) = SRNAME(1:ISRLEN)                           URSTRC    109
            I = ISRLEN + 1                                              URSTRC    110
            II = ISRLEN + IBKELN(IBKLAS)                                URSTRC    111
            NAME(I:II) = BKNAME(IBKLAS)(1:IBKELN(IBKLAS))               URSTRC    112
C                                                                       URSTRC    113
C                                                                       URSTRC    114
C           Check if block name is unique.                              URSTRC    115
C                                                                       URSTRC    116
            CALL VALNAM (NAME, LEN, 'BLOCK ', VALID, FLAG)              URSTRC    117
C                                                                       URSTRC    118
            IF (VALID) THEN                                             URSTRC    119
C                                                                       URSTRC    120
C              Obtain information for this block.                       URSTRC    121
C                                                                       URSTRC    122
               IUDC = IUDC + 1                                          URSTRC    123
               IF (IUDC .GT. NUDC) THEN                                 URSTRC    124
                  WRITE (MSG(1),9000) SUBNAM                            URSTRC    125
                  WRITE(MSG(2),9006) NUDC                               URSTRC    126
                  WRITE(MSG(3),9011)                                    URSTRC    127
                  CALL PRTMSG(3)                                        URSTRC    128
                  MSG(1)='TERMINATED DUE TO UDC ARRAY DIMENSIONS'       URSTRC    129
                  CALL ASTOP(MSG(1),38)                                 URSTRC    130
               END IF                                                   URSTRC    131
C                                                                       URSTRC    132
               IUDLEN(IUDC) = LEN                                       URSTRC    133
               UDNAME(IUDC) = NAME                                      URSTRC    134
               IUDTYP(IUDC) = IBKTYP(IBKLAS)                            URSTRC    135
               IUDSUB(IUDC) = IBKSUB(IBKLAS)                            URSTRC    136
C                                                                       URSTRC    137
               IF (IUDTYP(IUDC) .EQ. IACSYS) THEN                       URSTRC    138
                  CALL URACSY                                           URSTRC    139
C                                                                       URSTRC    140
               ELSE IF (IUDTYP(IUDC) .EQ. IBINAR) THEN                  URSTRC    141
                  CALL URBIN                                            URSTRC    142
C                                                                       URSTRC    143
               ELSE IF (IUDTYP(IUDC) .EQ. IBREAK) THEN                  URSTRC    144
                  CALL URBRKR                                           URSTRC    145
C                                                                       URSTRC    146
               ELSE IF (IUDTYP(IUDC) .EQ. IFRMAC) THEN                  URSTRC    147
                  CALL URFRAC                                           URSTRC    148
C                                                                       URSTRC    149
               ELSE IF (IUDTYP(IUDC) .EQ. IFRMDC) THEN                  URSTRC    150
                  CALL URFRDC                                           URSTRC    151
C                                                                       URSTRC    152
               ELSE IF (IUDTYP(IUDC) .EQ. INTERF) THEN                  URSTRC    153
                  CALL URINTF                                           URSTRC    154
C                                                                       URSTRC    155
               ELSE IF (IUDTYP(IUDC) .EQ. LIMITR) THEN                  URSTRC    156
                  CALL URLIMT                                           URSTRC    157
C                                                                       URSTRC    158
               ELSE IF (IUDTYP(IUDC) .EQ. LOGIC) THEN                   URSTRC    159
                  CALL URLOGC                                           URSTRC    160
C                                                                       URSTRC    161
               ELSE IF (IUDTYP(IUDC) .EQ. MULTI) THEN                   URSTRC    162
                  CALL URMLTP                                           URSTRC    163
C                                                                       URSTRC    164
               ELSE IF (IUDTYP(IUDC) .EQ. IPRTR) THEN                   URSTRC    165
                  CALL URPRT                                            URSTRC    166
C                                                                       URSTRC    167
               ELSE IF (IUDTYP(IUDC) .EQ. IOTHER) THEN                  URSTRC    168
                  CALL UROTHR                                           URSTRC    169
C                                                                       URSTRC    170
               ELSE IF (IUDTYP(IUDC) .EQ. ISBLCK) THEN                  URSTRC    171
                  CALL URSBLK                                           URSTRC    172
C                                                                       URSTRC    173
               ELSE IF (IUDTYP(IUDC) .EQ. ISETUP) THEN                  URSTRC    174
                  CALL URSETP                                           URSTRC    175
C                                                                       URSTRC    176
               ELSE IF (IUDTYP(IUDC) .EQ. ISOURC) THEN                  URSTRC    177
                  CALL URSRCE                                           URSTRC    178
C                                                                       URSTRC    179
               ELSE IF (IUDTYP(IUDC) .EQ. ISUBSY) THEN                  URSTRC    180
                  CALL URSUBS                                           URSTRC    181
C                                                                       URSTRC    182
               ELSE IF (IUDTYP(IUDC) .EQ. IUNARY) THEN                  URSTRC    183
                  CALL URUNA                                            URSTRC    184
C                                                                       URSTRC    185
               ELSE                                                     URSTRC    186
                  IERCNT = IERCNT + 1                                   URSTRC    187
            WRITE (MSG(1),9000) SUBNAM                                  URSTRC    188
            WRITE(MSG(2),9004) SRNAME(1:ISRLEN)                         URSTRC    189
            WRITE(MSG(3),9007) TPNAME(IUDTYP(IUDC))                     URSTRC    190
            WRITE(MSG(4),9012)                                          URSTRC    191
            CALL PRTMSG(4)                                              URSTRC    192
C                                                                       URSTRC    193
               END IF                                                   URSTRC    194
            END IF                                                      URSTRC    195
            IBKLAS = IBKNEX(IBKLAS)                                     URSTRC    196
            GO TO 40                                                    URSTRC    197
C                                                                       URSTRC    198
60       CONTINUE                                                       URSTRC    199
         EXPAND = .FALSE.                                               URSTRC    200
      END IF                                                            URSTRC    201
C                                                                       URSTRC    202
C                                                                       URSTRC    203
C                                                                       URSTRC    204
      IF (.NOT. ENDBLK) THEN                                            URSTRC    205
C                                                                       URSTRC    206
C        Extra data was found for the structure udc block.              URSTRC    207
C                                                                       URSTRC    208
            WRITE (MSG(1),9000) SUBNAM                                  URSTRC    209
            WRITE(MSG(2),9004) SBSTRC(NMSTRC)                           URSTRC    210
            WRITE(MSG(3),9008)                                          URSTRC    211
            CALL PRTMSG(3)                                              URSTRC    212
         IERCNT = IERCNT + 1                                            URSTRC    213
80       IF (ENDBLK) GO TO 100                                          URSTRC    214
            CALL URGETC (NAME, FOUND)                                   URSTRC    215
            GO TO 80                                                    URSTRC    216
100      CONTINUE                                                       URSTRC    217
      END IF                                                            URSTRC    218
C                                                                       URSTRC    219
C                                                                       URSTRC    220
C---------------------------------------------------------------------  URSTRC    221
C                                                                       URSTRC    222
      RETURN                                                            URSTRC    223
C                                                                       URSTRC    224
C---------------------------------------------------------------------  URSTRC    225
C                                                                       URSTRC    226
9000  FORMAT (' *** ERROR', 5X, A)                                      URSTRC    227
9001  FORMAT(11X,'DURING THE DEFINITION OF A UDC STRUCTURE SUBTYPE "',  URSTRC    228
     2        A, '"')                                                   URSTRC    229
9002  FORMAT(11X,'A STRUCTURE BLOCK "', A, '" WAS FOUND.',              URSTRC    230
     3        '  STRUCTURES')                                           URSTRC    231
9003  FORMAT(11X,'CANNOT BE NESTED.  ALL DATA ',                        URSTRC    232
     4        'FOR THIS BLOCK IS IGNORED.')                             URSTRC    233
9004  FORMAT(11X,'DURING THE READING OF A UDC STRUCTURE BLOCK "',A,'"') URSTRC    234
9005  FORMAT(11X,'HAS AN INVALID SUBTYPE OF "', A, '".  ALL ')          URSTRC    235
9010  FORMAT(11X,'INFORMATION FOR THIS BLOCK WILL BE IGNORED.')         URSTRC    236
9006  FORMAT(11X,'THE MAXIMUM NUMBER OF UDC BLOCKS ', I4, ' HAS BEEN ', URSTRC    237
     2        'EXCEEDED.')                                              URSTRC    238
9011  FORMAT(11X,'CHANGE THE VALUE OF PARAMETER, ',                     URSTRC    239
     3        'NUDC, FOUND IN INCLUDE PARX.')                           URSTRC    240
9007  FORMAT(11X,'CONTAINS A BLOCK OF TYPE "', A, '" WITHIN THE')       URSTRC    241
9012  FORMAT(11X,'STRUCTURE DEFINITION.  THIS TYPE CANNOT ',            URSTRC    242
     4        'BE USED WITHIN A STRUCTURE.')                            URSTRC    243
9008  FORMAT(11X,'EXTRA DATA WAS FOUND, DATA IS IGNORED.')              URSTRC    244
C                                                                       URSTRC    245
C---------------------------------------------------------------------  URSTRC    246
C                                                                       URSTRC    247
      END                                                               URSTRC    248
