CFPRIME RRESDA                                                          RRESDA      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 RRESDA(FILENA,LENPAR,IUX,IUY)                          RRESDA      3
CD                                                                      RRESDA      4
CD    THIS ROUTINE IS THE MAIN DRIVER FOR READING IN THE USER SPECIFIED RRESDA      5
CD    OUTPUT ANALYSIS DATA FILE.                                        RRESDA      6
CD                                                                      RRESDA      7
      INCLUDE 'PARX.INS'                                                RRESDA      8
      INCLUDE 'CNPT.INS'                                                RRESDA      9
      INCLUDE 'CNREC1.INS'                                              RRESDA     10
      INCLUDE 'CNIPTR.INS'                                              RRESDA     11
      INCLUDE 'CNFLAG.INS'                                              RRESDA     12
      INCLUDE 'CNPARX.INS'                                              RRESDA     13
      INCLUDE 'CNMNEW.INS'                                              RRESDA     14
      INCLUDE 'CNMDAT.INS'                                              RRESDA     15
      INCLUDE 'CNREN.INS'                                               RRESDA     16
      INCLUDE 'CNLFDA.INS'                                              RRESDA     17
      INCLUDE 'CNINTE.INS'                                              RRESDA     18
      INCLUDE 'CNRAN.INS'                                               RRESDA     19
      INCLUDE 'CNSTP.INS'                                               RRESDA     20
C                                                                       RRESDA     21
      INCLUDE 'CNLSTA.INS'                                              RRESDA     22
      INCLUDE 'CNLUN.INS'                                               RRESDA     23
      INCLUDE 'CNUNIT.INS'                                              RRESDA     24
      INCLUDE 'CNMSG.INS'                                               RRESDA     25
      INCLUDE 'CNFRUN.INS'                                              RRESDA     26
C                                                                       RRESDA     27
      CHARACTER*80 PMSG,EMSG,STRING                                     RRESDA     28
      CHARACTER*50 FILENA, LFILE                                        RRESDA     29
C                                                                       RRESDA     30
      CHARACTER*12 BNAME1                                               RRESDA     31
      CHARACTER*2 UID,UID1                                              RRESDA     32
      DIMENSION INVBS(5),ICNV(27)                                       RRESDA     33
      CHARACTER*32  CNAME                                               RRESDA     34
      CHARACTER*24  INTFNM                                              RRESDA     35
      CHARACTER*20  UDNAME                                              RRESDA     36
      CHARACTER*8   DCNAME                                              RRESDA     37
      CHARACTER*7 SUBPMT                                                RRESDA     38
      INTEGER       KNAME(8)                                            RRESDA     39
      EQUIVALENCE (CNAME,UDNAME,DCNAME,KNAME(1))                        RRESDA     40
C                                                                       RRESDA     41
      DATA ICNV/1,2,3,4,5,6,7,8,9,10,                                   RRESDA     42
     &11,12,17,16,13,14,15,18,19,20,                                    RRESDA     43
     &21,22,23,24,25,26,27/                                             RRESDA     44
C                                                                       RRESDA     45
      LDEB=(JDEB(30).NE.0)                                              RRESDA     46
      JINTER=0                                                          RRESDA     47
      IPOS=0                                                            RRESDA     48
C                                                                       RRESDA     49
      MEMOUT=0                                                          RRESDA     50
      SUBPMT='RRESDA '                                                  RRESDA     51
   10 CONTINUE                                                          RRESDA     52
C                                                                       RRESDA     53
C                                                                       RRESDA     54
C                                                     Control file run  RRESDA     55
      IF (CFLRUN) THEN                                                  RRESDA     56
        IF (FILENA(1:1) .EQ. ' ') GOTO 110                              RRESDA     57
        CALL PARSIU (FILENA, LEN, IU, LO)                               RRESDA     58
        IF (IU .LT. 0) RETURN                                           RRESDA     59
        IF (IU .GT. 0) THEN                                             RRESDA     60
          LFILE = FILENA(1:LO)                                          RRESDA     61
          FILENA = LFILE                                                RRESDA     62
          IU53 = IU                                                     RRESDA     63
          CALL FBOKEP (IU53, IBACK)                                     RRESDA     64
          IF (IBACK .LT. 0) RETURN                                      RRESDA     65
        ENDIF                                                           RRESDA     66
        LO = INDEX (FILENA, ' ')                                        RRESDA     67
        IKEY = 1                                                        RRESDA     68
        CALL OPENRE (IU53, FILENA, JLENG, IKEY, ISTAT, LO)              RRESDA     69
        IF (ISTAT .NE. 0) THEN                                          RRESDA     70
          MSG(1) = ' *** ERROR OPENING OUTPUT SPECIFICATION FILE.'      RRESDA     71
          CALL PRTMSG(1)                                                RRESDA     72
          RETURN                                                        RRESDA     73
        ELSE                                                            RRESDA     74
          LUNITS(IU53)=.TRUE.                                           RRESDA     75
        ENDIF                                                           RRESDA     76
        GOTO 100                                                        RRESDA     77
      ENDIF                                                             RRESDA     78
C                                                                       RRESDA     79
      MEMOUT=MEMOUT+1                                                   RRESDA     80
      IF(MEMOUT.GT.4)RETURN                                             RRESDA     81
C  ...............................................................      RRESDA     82
C  : Ask for file name if it's not given on the command line     :      RRESDA     83
      PMSG='DO YOU HAVE AN EXISTING OUTPUT SPECIFICATION FILE ? (Y/N)'  RRESDA     84
      WRITE(LOUT,*)                                                     RRESDA     85
      CALL REDLIN(LOUT,LIN,IOERR,58,PMSG,SUBPMT,'RR1',STRING,           RRESDA     86
     &RECORD,IREC,KLAYER,KEND,KREAD,PLAYBA)                             RRESDA     87
      IF(IOERR.LT.0)THEN                                                RRESDA     88
      IF(PLAYBA)CALL PSTOP                                              RRESDA     89
      GOTO 10                                                           RRESDA     90
      ENDIF                                                             RRESDA     91
      IF(KLAYER.LT.0) RETURN                                            RRESDA     92
      IF(STRING(1:1).EQ.'N'.OR.STRING(1:1).EQ.'n') GOTO 150             RRESDA     93
      IF(STRING(1:1).NE.'Y'.AND.STRING(1:1).NE.'y')THEN                 RRESDA     94
       KREAD=.TRUE.                                                     RRESDA     95
       GOTO 10                                                          RRESDA     96
      ENDIF                                                             RRESDA     97
C    :........................................................:         RRESDA     98
C                                                                       RRESDA     99
      IKEY=1                                                            RRESDA    100
      JLENG=0                                                           RRESDA    101
      PMSG='ENTER OUTPUT SPECIFICATION FILE NAME:'                      RRESDA    102
      EMSG='ERROR IN OPENING OUTPUT SPECIFICATION FILE'                 RRESDA    103
      LMSG=36                                                           RRESDA    104
      LEMSG=42                                                          RRESDA    105
      WRITE(LOUT,*)                                                     RRESDA    106
      CALL FILEMG(IU53,LMSG,PMSG,LEMSG,EMSG,SUBPMT,IKEY,JLENG,IEBK)     RRESDA    107
      IF(IEBK.NE.0)THEN                                                 RRESDA    108
      IF(PLAYBA)CALL PSTOP                                              RRESDA    109
      RETURN                                                            RRESDA    110
      ENDIF                                                             RRESDA    111
C                                                                       RRESDA    112
 100  IUX=IU53                                                          RRESDA    113
      IF(KLFO.EQ.0) THEN                                                RRESDA    114
        CALL NRRESD(IUX,IUY,IPOS)                                       RRESDA    115
      ELSE                                                              RRESDA    116
        CALL ARRESD(IUX,IUY,IPOS)                                       RRESDA    117
      ENDIF                                                             RRESDA    118
C                                                                       RRESDA    119
      CALL CLOSEF(IUX)                                                  RRESDA    120
C                                                                       RRESDA    121
110   IF (CFLRUN) THEN                                                  RRESDA    122
        IF (IFSPTR(IOUTPT) .NE. 0) THEN                                 RRESDA    123
          IUX = 0                                                       RRESDA    124
          IF (KLFO .EQ. 0) THEN                                         RRESDA    125
            CALL NRRESD (IUX, IUY, IPOS)                                RRESDA    126
          ELSE                                                          RRESDA    127
            CALL ARRESD (IUX, IUY, IPOS)                                RRESDA    128
          ENDIF                                                         RRESDA    129
        ENDIF                                                           RRESDA    130
        RETURN                                                          RRESDA    131
      ENDIF                                                             RRESDA    132
C                                                                       RRESDA    133
*IF MIBM                                                                RRESDA    134
*ENDIF                                                                  RRESDA    136
 140  WRITE(LOUT,*)                                                     RRESDA    137
      PMSG='ENTER MORE OUTPUT QUANTITIES ? (Y/N)'                       RRESDA    138
      CALL REDLIN(LOUT,LIN,JERR,36,PMSG,SUBPMT,'RR2',STRING,            RRESDA    139
     &RECORD,IREC,KLAYER,KEND,KREAD,PLAYBA)                             RRESDA    140
      IF(JERR.LT.0)THEN                                                 RRESDA    141
      IF(PLAYBA)CALL PSTOP                                              RRESDA    142
      GOTO 140                                                          RRESDA    143
      ENDIF                                                             RRESDA    144
      IF(KLAYER.LT.0) RETURN                                            RRESDA    145
      IF(STRING(1:1).EQ.'N'.OR.STRING(1:1).EQ.'n') RETURN               RRESDA    146
      IF(STRING(1:1).NE.'Y'.AND.STRING(1:1).NE.'y')THEN                 RRESDA    147
      IF(PLAYBA)CALL PSTOP                                              RRESDA    148
      GOTO 140                                                          RRESDA    149
      ENDIF                                                             RRESDA    150
C    ..........................................................         RRESDA    151
C    :GET ITEM TO BE CHANGE                                   :         RRESDA    152
 150  CONTINUE                                                          RRESDA    153
      WRITE(LOUT,5000)                                                  RRESDA    154
      WRITE(LOUT,5020)                                                  RRESDA    155
      PMSG='SELECT AN ITEM BY THE NUMBER (Q TO QUIT):'                  RRESDA    156
      CALL REDLIN(LOUT,LIN,JERR,41,PMSG,SUBPMT,'RR3',STRING,            RRESDA    157
     &RECORD,IREC,KLAYER,KEND,KREAD,PLAYBA)                             RRESDA    158
      IF(JERR.LT.0)THEN                                                 RRESDA    159
      IF(PLAYBA)CALL PSTOP                                              RRESDA    160
      GOTO 150                                                          RRESDA    161
      ENDIF                                                             RRESDA    162
      IF(KLAYER.LT.0) RETURN                                            RRESDA    163
      IF(STRING(1:1).EQ.'Q'.OR.STRING(1:1).EQ.'q') GOTO 1200            RRESDA    164
      READ(STRING,*,IOSTAT=IOS) JSEM                                    RRESDA    165
      IF ((JSEM.LE.0).OR.(JSEM.GT.26).OR.IOS.NE.0) THEN                 RRESDA    166
         KREAD=.TRUE.                                                   RRESDA    167
         IF(PLAYBA)CALL PSTOP                                           RRESDA    168
         GOTO 150                                                       RRESDA    169
      ENDIF                                                             RRESDA    170
C    :........................................................:         RRESDA    171
C                                                                       RRESDA    172
      IPOS=IPOS+2                                                       RRESDA    173
      JPOS=IPOS                                                         RRESDA    174
      NOPDAT(JPOS-1)=ICNV(JSEM)                                         RRESDA    175
      JITEM=0                                                           RRESDA    176
C              1      2      3      4      5      6      7      8      9RRESDA    177
C          'AGEO','BGEO','CGEO','GCOS','GOVV','GENS','GYVA','AMOT','BMOTRRESDA    178
      GOTO(  200 ,  200 ,  200 ,  200 ,  200 ,  220 ,  220 ,  200 ,  200RRESDA    179
C             10     11     12     13     14     15     16     17       RRESDA    180
C           'ASVO','CONV','UDCO', 'DVOL' 'MVBS','ALOA','LINE','SLIN',   RRESDA    181
     &,      200 ,  400 ,  500 ,  900,    800,  300 ,  700 ,  600       RRESDA    182
C             18     19     20     21     22     23     24     25     26RRESDA    183
C           'UEXC','UPSS','UEXL','UGOV','USVC','URAN','USTC','USPS','USDRRESDA    184
     &,      220 ,  220 ,  220 ,  220 ,  355 ,  740 ,  740 ,  740 ,  350RRESDA    185
C             27                                                        RRESDA    186
C           ' END'                                                      RRESDA    187
     &,      1200),JSEM                                                 RRESDA    188
C                                                                       RRESDA    189
 200  CONTINUE                                                          RRESDA    190
      IF(JSEM.EQ.8.OR.JSEM.EQ.9)THEN                                    RRESDA    191
        ICODE=2                                                         RRESDA    192
      ELSEIF(JSEM.EQ.10)THEN                                            RRESDA    193
        ICODE=1                                                         RRESDA    194
      ELSE                                                              RRESDA    195
        ICODE=0                                                         RRESDA    196
      ENDIF                                                             RRESDA    197
C                                                                       RRESDA    198
C  READ IN GENERATORS, SVC'C OR INDUCTION MOTORS                        RRESDA    199
C                                                                       RRESDA    200
      CALL BUSCID(ICODE,NLF,BNAME1,UID,KLFO)                            RRESDA    201
      IF(ICODE.EQ.0)THEN                                                RRESDA    202
      NOPDAT(IPOS+1)=NLF                                                RRESDA    203
      CALL PACK(UID,0,ITFK)                                             RRESDA    204
      NOPDAT(IPOS+2)=ITFK                                               RRESDA    205
      IPOS=IPOS+2                                                       RRESDA    206
      JITEM=JITEM+1                                                     RRESDA    207
      GOTO 200                                                          RRESDA    208
      ELSE                                                              RRESDA    209
      NOPDAT(JPOS)=JITEM                                                RRESDA    210
      GOTO 150                                                          RRESDA    211
      ENDIF                                                             RRESDA    212
C                                                                       RRESDA    213
 220  CONTINUE                                                          RRESDA    214
C                                                                       RRESDA    215
C  READ IN GENERATORS NEED THE STATES OR GYVA OUTPUT                    RRESDA    216
C                                                                       RRESDA    217
      ICODE=1                                                           RRESDA    218
      CALL BUCVAR(ICODE,NLF,BNAME1,UID,KLFO,KSTCOU,INVBS)               RRESDA    219
      IF(ICODE.EQ.0)THEN                                                RRESDA    220
      NOPDAT(IPOS+1)=NLF                                                RRESDA    221
      CALL PACK(UID,0,ITFK)                                             RRESDA    222
      NOPDAT(IPOS+2)=ITFK                                               RRESDA    223
      NOPDAT(IPOS+3)=KSTCOU                                             RRESDA    224
      IPOS=IPOS+3                                                       RRESDA    225
      DO 230 LK=1,KSTCOU                                                RRESDA    226
 230  NOPDAT(IPOS+LK)=INVBS(LK)                                         RRESDA    227
      IPOS=IPOS+KSTCOU                                                  RRESDA    228
      JITEM=JITEM+1                                                     RRESDA    229
      GOTO 220                                                          RRESDA    230
      ELSE                                                              RRESDA    231
      NOPDAT(JPOS)=JITEM                                                RRESDA    232
      GOTO 150                                                          RRESDA    233
      ENDIF                                                             RRESDA    234
C                                                                       RRESDA    235
 300  CONTINUE                                                          RRESDA    236
C                                                                       RRESDA    237
C   READ IN LOAD OUTPUT SPECIFICATIONS                                  RRESDA    238
C                                                                       RRESDA    239
      CALL BNOVAR(ICODE,NLF,BNAME1,KLFO)                                RRESDA    240
      IF(ICODE.EQ.0)THEN                                                RRESDA    241
      NOPDAT(IPOS+1)=NLF                                                RRESDA    242
      IPOS=IPOS+1                                                       RRESDA    243
      JITEM=JITEM+1                                                     RRESDA    244
      GOTO 300                                                          RRESDA    245
      ELSE                                                              RRESDA    246
      NOPDAT(JPOS)=JITEM                                                RRESDA    247
      GOTO 150                                                          RRESDA    248
      ENDIF                                                             RRESDA    249
C                                                                       RRESDA    250
 350  CONTINUE                                                          RRESDA    251
C                                                                       RRESDA    252
C  READ IN USVC AND USDB THAT NEEDS THE BLOCK OUTPUT                    RRESDA    253
C                                                                       RRESDA    254
      CALL BUSVAR(ICODE,NLF,BNAME1,KLFO,KSTCOU,INVBS)                   RRESDA    255
      IF(ICODE.EQ.0)THEN                                                RRESDA    256
      NOPDAT(IPOS+1)=NLF                                                RRESDA    257
      NOPDAT(IPOS+2)=KSTCOU                                             RRESDA    258
      IPOS=IPOS+2                                                       RRESDA    259
      DO 360 LK=1,KSTCOU                                                RRESDA    260
      NSTNO=INVBS(LK)                                                   RRESDA    261
      NOPDAT(IPOS+LK)=NSTNO                                             RRESDA    262
 360  CONTINUE                                                          RRESDA    263
      IPOS=IPOS+KSTCOU                                                  RRESDA    264
      JITEM=JITEM+1                                                     RRESDA    265
      GOTO 350                                                          RRESDA    266
      ELSE                                                              RRESDA    267
      NOPDAT(JPOS)=JITEM                                                RRESDA    268
      GOTO 150                                                          RRESDA    269
      ENDIF                                                             RRESDA    270
C                                                                       RRESDA    271
 355  CONTINUE                                                          RRESDA    272
C                                                                       RRESDA    273
C  READ IN USVC THAT NEEDS THE BLOCK OUTPUT                             RRESDA    274
C                                                                       RRESDA    275
      ICODE=2                                                           RRESDA    276
      CALL BUCVAR (ICODE,NLF,BNAME1,UID,KLFO,KSTOU,INVBS)               RRESDA    277
      IF(ICODE.EQ.0)THEN                                                RRESDA    278
        NOPDAT(IPOS+1)=NLF                                              RRESDA    279
        CALL PACK(UID,KSTCOU,ITFK)                                      RRESDA    280
        NOPDAT(IPOS+2)=ITFK                                             RRESDA    281
        IPOS=IPOS+2                                                     RRESDA    282
        DO 365 LK=1,KSTCOU                                              RRESDA    283
          NOPDAT(IPOS+LK)=INVBS(LK)                                     RRESDA    284
365     CONTINUE                                                        RRESDA    285
        IPOS=IPOS+KSTCOU                                                RRESDA    286
        JITEM=JITEM+1                                                   RRESDA    287
        GOTO 355                                                        RRESDA    288
      ELSE                                                              RRESDA    289
        NOPDAT(JPOS)=JITEM                                              RRESDA    290
        GOTO 150                                                        RRESDA    291
      ENDIF                                                             RRESDA    292
C                                                                       RRESDA    293
 400  CONTINUE                                                          RRESDA    294
C                                                                       RRESDA    295
C  READ IN CONVERTERS TO BE OUTPUT                                      RRESDA    296
C                                                                       RRESDA    297
      CALL COVNAM(ICODE,CNAME)                                          RRESDA    298
      IF(ICODE.EQ.0)THEN                                                RRESDA    299
      NOPDAT(IPOS+1)=KNAME(1)                                           RRESDA    300
      NOPDAT(IPOS+2)=KNAME(2)                                           RRESDA    301
      NOPDAT(IPOS+3)=KNAME(3)                                           RRESDA    302
      NOPDAT(IPOS+4)=KNAME(4)                                           RRESDA    303
      NOPDAT(IPOS+5)=KNAME(5)                                           RRESDA    304
      NOPDAT(IPOS+6)=KNAME(6)                                           RRESDA    305
      NOPDAT(IPOS+7)=KNAME(7)                                           RRESDA    306
      NOPDAT(IPOS+8)=KNAME(8)                                           RRESDA    307
      IPOS=IPOS+8                                                       RRESDA    308
      JITEM=JITEM+1                                                     RRESDA    309
      GOTO 400                                                          RRESDA    310
      ELSE                                                              RRESDA    311
      NOPDAT(JPOS)=JITEM                                                RRESDA    312
      GOTO 150                                                          RRESDA    313
      ENDIF                                                             RRESDA    314
C                                                                       RRESDA    315
 500  CONTINUE                                                          RRESDA    316
C                                                                       RRESDA    317
C  READ IN UDC BLOCKS TO BE OUTPUT                                      RRESDA    318
C                                                                       RRESDA    319
      CALL UDCNAM(ICODE,UDNAME)                                         RRESDA    320
      IF(ICODE.EQ.0)THEN                                                RRESDA    321
      NOPDAT(IPOS+1)=KNAME(1)                                           RRESDA    322
      NOPDAT(IPOS+2)=KNAME(2)                                           RRESDA    323
      NOPDAT(IPOS+3)=KNAME(3)                                           RRESDA    324
      NOPDAT(IPOS+4)=KNAME(4)                                           RRESDA    325
      NOPDAT(IPOS+5)=KNAME(5)                                           RRESDA    326
      IPOS=IPOS+5                                                       RRESDA    327
      JITEM=JITEM+1                                                     RRESDA    328
      GOTO 500                                                          RRESDA    329
      ELSE                                                              RRESDA    330
      NOPDAT(JPOS)=JITEM                                                RRESDA    331
      GOTO 150                                                          RRESDA    332
      ENDIF                                                             RRESDA    333
C                                                                       RRESDA    334
C  INTERFACE LINE FLOW                                                  RRESDA    335
C                                                                       RRESDA    336
 600  CONTINUE                                                          RRESDA    337
      KITERM=0                                                          RRESDA    338
C                                                                       RRESDA    339
C  READ MONITERED LINE DATA                                             RRESDA    340
C                                                                       RRESDA    341
 610  CONTINUE                                                          RRESDA    342
      NPFLX=NPFL                                                        RRESDA    343
      CALL EMLNDA(SUBPMT,IUX,IUY,IEBK)                                  RRESDA    344
      NITEM=NPFL-NPFLX                                                  RRESDA    345
      IF(NITEM.EQ.0)THEN                                                RRESDA    346
      NOPDAT(JPOS)=KITERM                                               RRESDA    347
      GOTO 150                                                          RRESDA    348
      ENDIF                                                             RRESDA    349
      KITERM=KITERM+1                                                   RRESDA    350
      JINTER=JINTER+1                                                   RRESDA    351
      NOPDAT(IPOS+1)=JINTER                                             RRESDA    352
      NOPDAT(IPOS+2)=NITEM                                              RRESDA    353
      IPOS=IPOS+2                                                       RRESDA    354
 615  WRITE(LOUT,*)                                                     RRESDA    355
      PMSG='ENTER ;INTERFACE NAME:'                                     RRESDA    356
      CALL PMTRED(LOUT,LIN,JERR,22,PMSG,'RR4',STRING,KREAD,PLAYBA)      RRESDA    357
      IF (RECORD) WRITE(IREC,'(A)')STRING                               RRESDA    358
      I1=INDEX(STRING,';')                                              RRESDA    359
      IF(I1.EQ.0)THEN                                                   RRESDA    360
        IF(PLAYBA)CALL PSTOP                                            RRESDA    361
        GOTO 615                                                        RRESDA    362
      ENDIF                                                             RRESDA    363
      INTFNM=STRING(I1+1:I1+24)                                         RRESDA    364
      READ(INTFNM,5070) (KNTERF(LL,JINTER),LL=1,6)                      RRESDA    365
      DO 620 I=NPFLX+1,NPFL                                             RRESDA    366
        IPOS=IPOS+1                                                     RRESDA    367
        NOPDAT(IPOS)=I                                                  RRESDA    368
 620  CONTINUE                                                          RRESDA    369
      GOTO 610                                                          RRESDA    370
C                                                                       RRESDA    371
 700  CONTINUE                                                          RRESDA    372
C                                                                       RRESDA    373
C  READ MONITERED LINE DATA                                             RRESDA    374
C                                                                       RRESDA    375
      NPFLX=NPFL                                                        RRESDA    376
      CALL EMLNDA(SUBPMT,IUX,IUY,IEBK)                                  RRESDA    377
      NITEM=NPFL-NPFLX                                                  RRESDA    378
      NOPDAT(JPOS)=NITEM                                                RRESDA    379
      DO 710 I=NPFLX+1,NPFL                                             RRESDA    380
      IPOS=IPOS+1                                                       RRESDA    381
      NOPDAT(IPOS)=I                                                    RRESDA    382
 710  CONTINUE                                                          RRESDA    383
      GOTO 150                                                          RRESDA    384
C                                                                       RRESDA    385
 740  CONTINUE                                                          RRESDA    386
C                                                                       RRESDA    387
C  READ RANI AND USTC AND SPS MONITERING DATA                           RRESDA    388
C                                                                       RRESDA    389
      CALL FTNVAR(ICODE,NLFF,NLFT,UID,KLFO,KSTCOU,INVBS)                RRESDA    390
      IF(ICODE.EQ.0)THEN                                                RRESDA    391
      ASSIGN 750 TO I750                                                RRESDA    392
      IF(JSEM.EQ.23)THEN                                                RRESDA    393
      GOTO 2200                                                         RRESDA    394
      ELSE                                                              RRESDA    395
      GOTO 2220                                                         RRESDA    396
      ENDIF                                                             RRESDA    397
C                                                                       RRESDA    398
 750  CONTINUE                                                          RRESDA    399
      NOPDAT(IPOS+1)=ITHDEV                                             RRESDA    400
      NOPDAT(IPOS+2)=KSTCOU                                             RRESDA    401
      IPOS=IPOS+2                                                       RRESDA    402
      DO 760 LK=1,KSTCOU                                                RRESDA    403
      NSTNO=INVBS(LK)                                                   RRESDA    404
 760  NOPDAT(IPOS+LK)=NSTNO                                             RRESDA    405
      IPOS=IPOS+KSTCOU                                                  RRESDA    406
      JITEM=JITEM+1                                                     RRESDA    407
      GOTO 740                                                          RRESDA    408
      ELSE                                                              RRESDA    409
      NOPDAT(JPOS)=JITEM                                                RRESDA    410
      GOTO 150                                                          RRESDA    411
      ENDIF                                                             RRESDA    412
C                                                                       RRESDA    413
 800  CONTINUE                                                          RRESDA    414
C                                                                       RRESDA    415
C  READ MONITERED BUS DATA                                              RRESDA    416
C                                                                       RRESDA    417
      CALL BNOVAR(ICODE,NLF,BNAME1,KLFO)                                RRESDA    418
      IF(ICODE.EQ.0)THEN                                                RRESDA    419
      NVBS=NVBS+1                                                       RRESDA    420
      MVBUS(NVBS)=NLF                                                   RRESDA    421
      JITEM=JITEM+1                                                     RRESDA    422
      IPOS=IPOS+1                                                       RRESDA    423
      NOPDAT(IPOS)=NLF                                                  RRESDA    424
      GOTO 800                                                          RRESDA    425
      ELSE                                                              RRESDA    426
      NOPDAT(JPOS)=JITEM                                                RRESDA    427
      GOTO 150                                                          RRESDA    428
      ENDIF                                                             RRESDA    429
C                                                                       RRESDA    430
 900  CONTINUE                                                          RRESDA    431
C                                                                       RRESDA    432
C  READ IN DC BUS TO BE OUTPUT                                          RRESDA    433
C                                                                       RRESDA    434
      CALL UDCNAM(ICODE,UDNAME)                                         RRESDA    435
      IF(ICODE.EQ.0)THEN                                                RRESDA    436
      NOPDAT(IPOS+1)=KNAME(1)                                           RRESDA    437
      NOPDAT(IPOS+2)=KNAME(2)                                           RRESDA    438
      IPOS=IPOS+2                                                       RRESDA    439
      JITEM=JITEM+1                                                     RRESDA    440
      GOTO 900                                                          RRESDA    441
      ELSE                                                              RRESDA    442
      NOPDAT(JPOS)=JITEM                                                RRESDA    443
      GOTO 150                                                          RRESDA    444
      ENDIF                                                             RRESDA    445
C                                                                       RRESDA    446
 1200 CONTINUE                                                          RRESDA    447
      NOPDAT(IPOS+1)=0                                                  RRESDA    448
      NOPDAT(IPOS+2)=0                                                  RRESDA    449
C                                                                       RRESDA    450
      RETURN                                                            RRESDA    451
C                                                                       RRESDA    452
C   MATCHING THE RANI                                                   RRESDA    453
C                                                                       RRESDA    454
 2200  CONTINUE                                                         RRESDA    455
         ITHDEV=0                                                       RRESDA    456
         DO 2210 K=1,NRANI                                              RRESDA    457
         JR=JRDAT(K)                                                    RRESDA    458
         NJ=IDDAT(JR+1)                                                 RRESDA    459
         IF(NLFF.EQ.NJ)THEN                                             RRESDA    460
            NK=IDDAT(JR+2)                                              RRESDA    461
            IF(NLFT.EQ.NK)THEN                                          RRESDA    462
               ITFK=IDDAT(JR+3)                                         RRESDA    463
               CALL UNPACK(UID1,JJJ,ITFK)                               RRESDA    464
               IF(UID.EQ.UID1)THEN                                      RRESDA    465
               ITHDEV=K                                                 RRESDA    466
               GOTO I750                                                RRESDA    467
               ENDIF                                                    RRESDA    468
            ENDIF                                                       RRESDA    469
         ENDIF                                                          RRESDA    470
 2210    CONTINUE                                                       RRESDA    471
         IF(ITHDEV.EQ.0)THEN                                            RRESDA    472
         WRITE(LOUT,5060)                                               RRESDA    473
         GOTO 740                                                       RRESDA    474
         ENDIF                                                          RRESDA    475
         GOTO I750                                                      RRESDA    476
C                                                                       RRESDA    477
C   MATCHING THE USTC AND USPS                                          RRESDA    478
C                                                                       RRESDA    479
 2220  CONTINUE                                                         RRESDA    480
         ITHDEV=0                                                       RRESDA    481
         DO 2230 K=1,NTCPS                                              RRESDA    482
         JR=JTPDAT(K)                                                   RRESDA    483
         NJ=IDDAT(JR+1)                                                 RRESDA    484
         IF(NLFF.EQ.NJ)THEN                                             RRESDA    485
            NK=IDDAT(JR+2)                                              RRESDA    486
            IF(NLFT.EQ.NK)THEN                                          RRESDA    487
               ITFK=IDDAT(JR+3)                                         RRESDA    488
               CALL UNPACK(UID1,JJJ,ITFK)                               RRESDA    489
               IF(UID.EQ.UID1)THEN                                      RRESDA    490
               ITHDEV=K                                                 RRESDA    491
               GOTO I750                                                RRESDA    492
               ENDIF                                                    RRESDA    493
            ENDIF                                                       RRESDA    494
         ENDIF                                                          RRESDA    495
 2230    CONTINUE                                                       RRESDA    496
         IF(ITHDEV.EQ.0)THEN                                            RRESDA    497
         WRITE(LOUT,5060)                                               RRESDA    498
         GOTO 740                                                       RRESDA    499
         ENDIF                                                          RRESDA    500
       GOTO I750                                                        RRESDA    501
C                                                                       RRESDA    502
C                                                                       RRESDA    503
 5000 FORMAT(//,6X,'SPECIFICATION OF OUTPUT QUANTITIES',/,              RRESDA    504
     1          6X,'----------------------------------',//,             RRESDA    505
     21X,' (1) BASIC GENERATOR OUTPUTS',T41,                            RRESDA    506
     3   ' (2) COMMON GENERATOR OUTPUTS',/,                             RRESDA    507
     41X,' (3) DETAILED GENERATOR OUTPUTS',T41,                         RRESDA    508
     5   ' (4) GENERATOR CONTROL SIGNALS',/,                            RRESDA    509
     61X,' (5) GOVERNOR VARIABLES',T41,                                 RRESDA    510
     7   ' (6) GENERATOR AND CONTROL STATES',/,                         RRESDA    511
     81X,' (7) GENERATOR AND CONTROL Y VARIABLES',T41,                  RRESDA    512
     9   ' (8) BASIC INDUCTION MOTOR OUTPUTS',/,                        RRESDA    513
     *1X,' (9) DETAILED INDUCTION MOTOR OUTPUTS',T41,                   RRESDA    514
     1   '(10) SVC OUTPUTS',/,                                          RRESDA    515
     21X,'(11) CONVERTER OUTPUTS',T41,                                  RRESDA    516
     3   '(12) CONVERTER CONTROL BLOCK OUTPUTS',/,                      RRESDA    517
     41X,'(13) DC BUS VOLTAGES',T41,                                    RRESDA    518
     5   '(14) AC BUS VOLTAGES',/,                                      RRESDA    519
     61X,'(15) NONLINEAR LOAD OUTPUTS',T41,                             RRESDA    520
     7   '(16) LINE FLOWS',/,                                           RRESDA    521
     81X,'(17) INTERFACE FLOWS',T41,                                    RRESDA    522
     9   '(18) UD EXCITER BLOCK OUTPUTS')                               RRESDA    523
5020  FORMAT(                                                           RRESDA    524
     11X,'(19) UD STABILIZER BLOCK OUTPUTS',T41,                        RRESDA    525
     2   '(20) UD UEL OR OEL BLOCK OUTPUTS',/,                          RRESDA    526
     31X,'(21) UD GOVERNOR BLOCK OUTPUTS',T41,                          RRESDA    527
     4   '(22) UD SVC BLOCK OUTPUTS',/,                                 RRESDA    528
     51X,'(23) UD RANI BLOCK OUTPUTS',T41,                              RRESDA    529
     6   '(24) UD STC BLOCK OUTPUTS',/,                                 RRESDA    530
     71X,'(25) UD SPS BLOCK OUTPUTS',T41,                               RRESDA    531
     8   '(26) UD SDB BOLCK OUTPUTS',/)                                 RRESDA    532
 5060 FORMAT(' *** ERROR NO SUCH DEVICE')                               RRESDA    533
 5070 FORMAT(6A4)                                                       RRESDA    534
C                                                                       RRESDA    535
       END                                                              RRESDA    536
