CFPRIME MCGEDA                                                          MCGEDA      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 MIFBDA                                               MCGEDA      3
CD                                                                      MCGEDA      4
CD    THIS IS A DUMMY ROUTINE. WHEN IMPLEMENTED, IT WILL ENABLE USER    MCGEDA      5
CD    TO MODIFY INFINITE BUS DATA INTERACTIVELY.                        MCGEDA      6
CD                                                                      MCGEDA      7
        RETURN                                                          MCGEDA      8
        END                                                             MCGEDA      9
        SUBROUTINE MIMODA                                               MCGEDA     10
CD                                                                      MCGEDA     11
CD    THIS IS A DUMMY ROUTINE. WHEN IMPLEMENTED, IT WILL ENABLE USER    MCGEDA     12
CD    TO MODIFY INDUCTION MOTOR DATA INTERACTIVELY.                     MCGEDA     13
CD                                                                      MCGEDA     14
        RETURN                                                          MCGEDA     15
        END                                                             MCGEDA     16
        SUBROUTINE MNLBDA                                               MCGEDA     17
CD                                                                      MCGEDA     18
CD    THIS IS A DUMMY ROUTINE, WHEN IMPLEMENTED, IT WILL ENABLE USER TO MCGEDA     19
CD    MODIFY NONLINEAR LOAD DATA INTERACTIVELY.                         MCGEDA     20
CD                                                                      MCGEDA     21
        RETURN                                                          MCGEDA     22
        END                                                             MCGEDA     23
C                                                                       MCGEDA     24
        SUBROUTINE MRANDA                                               MCGEDA     25
C                                                                       MCGEDA     26
      INCLUDE 'PARX.INS'                                                MCGEDA     27
      INCLUDE 'CNFLAG.INS'                                              MCGEDA     28
      INCLUDE 'CNB19.INS'                                               MCGEDA     29
      INCLUDE 'CNMNEW.INS'                                              MCGEDA     30
      INCLUDE 'CNJPT.INS'                                               MCGEDA     31
      INCLUDE 'CNJDAT.INS'                                              MCGEDA     32
      INCLUDE 'CNTMDA.INS'                                              MCGEDA     33
      INCLUDE 'CNUNIT.INS'                                              MCGEDA     34
      INCLUDE 'CNMSG.INS'                                               MCGEDA     35
      INCLUDE 'CNPARX.INS'                                              MCGEDA     36
      INCLUDE 'CNLSTA.INS'                                              MCGEDA     37
      CHARACTER*2 CLD                                                   MCGEDA     38
      CHARACTER*80 EMSG,STRING                                          MCGEDA     39
      CHARACTER*12 CFBUS,CTBUS                                          MCGEDA     40
      EQUIVALENCE (IFBUS(1),CFBUS),(ITBUS(1),CTBUS)                     MCGEDA     41
      INTEGER*4 IFBUS(3),ITBUS(3)                                       MCGEDA     42
C                                                                       MCGEDA     43
      LDEB=.FALSE.                                                      MCGEDA     44
C                                                                       MCGEDA     45
      CALL LINEID(IOS,I1,I2,CFBUS,CTBUS,CLD,KLFO)                       MCGEDA     46
      CALL PACK(CLD,0,LID)                                              MCGEDA     47
      DO 400 JN=1, JRANI                                                MCGEDA     48
      IF(KLFO.EQ.0) THEN                                                MCGEDA     49
        IF(I1.EQ.ITDDAT(JJRDAT(JN)+1)                                   MCGEDA     50
     &  .AND.I2.EQ.ITDDAT(JJRDAT(JN)+2)                                 MCGEDA     51
     &  .AND.LID.EQ.ITDDAT(JJRDAT(JN)+3)) THEN                          MCGEDA     52
          NSTAT=1                                                       MCGEDA     53
          JE=JJRDAT(JN)                                                 MCGEDA     54
          GOTO 700                                                      MCGEDA     55
        ENDIF                                                           MCGEDA     56
      ELSE                                                              MCGEDA     57
        IF(IFBUS(1).EQ.ITDDAT(JJRDAT(JN)+1)                             MCGEDA     58
     &  .AND.IFBUS(2).EQ.ITDDAT(JJRDAT(JN)+2)                           MCGEDA     59
     &  .AND.IFBUS(3).EQ.ITDDAT(JJRDAT(JN)+3)) THEN                     MCGEDA     60
           IF(ITBUS(1).EQ.ITDDAT(JJRDAT(JN)+4)                          MCGEDA     61
     &     .AND.ITBUS(2).EQ.ITDDAT(JJRDAT(JN)+5)                        MCGEDA     62
     &     .AND.ITBUS(3).EQ.ITDDAT(JJRDAT(JN)+6)) THEN                  MCGEDA     63
              IF(LID.EQ.ITDDAT(JJRDAT(JN)+3)) THEN                      MCGEDA     64
                 NSTAT=1                                                MCGEDA     65
                 JE=JJRDAT(JN)                                          MCGEDA     66
                 GOTO 700                                               MCGEDA     67
              ENDIF                                                     MCGEDA     68
           ENDIF                                                        MCGEDA     69
        ENDIF                                                           MCGEDA     70
      ENDIF                                                             MCGEDA     71
 400  CONTINUE                                                          MCGEDA     72
      WRITE(LOUT,5800)                                                  MCGEDA     73
      WRITE(LOUT,'(A)') ' SPECIFIED RANI IS NOT IN THE SYSTEM.'         MCGEDA     74
      EMSG='DO YOU LIKE TO ADD ONE? (Y/N)'                              MCGEDA     75
 550  CALL REDLIN(LOUT,LIN,IOERR,29,EMSG,'XXX','UDF',STRING,RECORD      MCGEDA     76
     *              ,IREC,KLAYER,KEND,KREAD,PLAYBA)                     MCGEDA     77
      IF(IOERR.LT.0)THEN                                                MCGEDA     78
      IF(PLAYBA)CALL PSTOP                                              MCGEDA     79
      GOTO 550                                                          MCGEDA     80
      ENDIF                                                             MCGEDA     81
      IF(STRING(1:1).EQ.'N'.OR.STRING(1:1).EQ.'n') RETURN               MCGEDA     82
      IF(STRING(1:1).NE.'Y'.AND.STRING(1:1).NE.'y')THEN                 MCGEDA     83
      IF(PLAYBA)CALL PSTOP                                              MCGEDA     84
      GOTO 550                                                          MCGEDA     85
      ENDIF                                                             MCGEDA     86
 555  IF(KLFO.EQ.1) THEN                                                MCGEDA     87
          CALL CHKBUS(CFBUS,I1)                                         MCGEDA     88
          CALL CHKBUS(CTBUS,I2)                                         MCGEDA     89
      ENDIF                                                             MCGEDA     90
      IF(I1.NE.0) NPBNOI=MNEW(I1)                                       MCGEDA     91
      IF(I2.NE.0) NPBN2=MNEW(I2)                                        MCGEDA     92
      IF(I1.EQ.0.OR.I2.EQ.0.OR.NPBNOI.EQ.0.OR.NPBN2.EQ.0) THEN          MCGEDA     93
          IF(NPBNOI.EQ.0) WRITE (LOUT,5124) I1                          MCGEDA     94
          IF(NPBN2.EQ.0)  WRITE (LOUT,5124) I2                          MCGEDA     95
          EMSG=                                                         MCGEDA     96
     &   ' *** DATA ERROR:  DO YOU WANT TO REENTER THE DATA? (Y/N)'     MCGEDA     97
 560      CALL REDLIN(LOUT,LIN,IOERR,60,EMSG,'XXX','UDF',STRING,        MCGEDA     98
     &        RECORD,IREC,KLAYER,KEND,KREAD,PLAYBA)                     MCGEDA     99
          IF(IOERR.NE.0)THEN                                            MCGEDA    100
          IF(PLAYBA)CALL PSTOP                                          MCGEDA    101
          GOTO 560                                                      MCGEDA    102
          ENDIF                                                         MCGEDA    103
          IF(STRING.EQ.'Y'.OR.STRING.EQ.'y') GOTO 565                   MCGEDA    104
          IF(STRING.NE.'N'.AND.STRING.NE.'n')THEN                       MCGEDA    105
          IF(PLAYBA)CALL PSTOP                                          MCGEDA    106
          GOTO 560                                                      MCGEDA    107
          ENDIF                                                         MCGEDA    108
          RETURN                                                        MCGEDA    109
 565      CALL LINEID(IOS,I1,I2,CFBUS,CTBUS,CLD,KLFO)                   MCGEDA    110
          CALL PACK(CLD,0,LID)                                          MCGEDA    111
          GOTO 555                                                      MCGEDA    112
       ELSE                                                             MCGEDA    113
          NSTAT=0                                                       MCGEDA    114
          JRANI=JRANI+1                                                 MCGEDA    115
          JJRDAT(JRANI)=JTLN                                            MCGEDA    116
          JE=JJRDAT(JRANI)                                              MCGEDA    117
          IF(KLFO.EQ.0) THEN                                            MCGEDA    118
             ITDDAT(JTLN+1)=I1                                          MCGEDA    119
             ITDDAT(JTLN+2)=I2                                          MCGEDA    120
             ITDDAT(JTLN+3)=LID                                         MCGEDA    121
             ITDDAT(JTLN+4)=50                                          MCGEDA    122
          ELSE                                                          MCGEDA    123
             ITDDAT(JTLN+1)=IFBUS(1)                                    MCGEDA    124
             ITDDAT(JTLN+2)=IFBUS(2)                                    MCGEDA    125
             ITDDAT(JTLN+3)=IFBUS(3)                                    MCGEDA    126
             ITDDAT(JTLN+4)=ITBUS(1)                                    MCGEDA    127
             ITDDAT(JTLN+5)=ITBUS(2)                                    MCGEDA    128
             ITDDAT(JTLN+6)=ITBUS(3)                                    MCGEDA    129
             ITDDAT(JTLN+7)=LID                                         MCGEDA    130
             ITDDAT(JTLN+8)=50                                          MCGEDA    131
           ENDIF                                                        MCGEDA    132
      ENDIF                                                             MCGEDA    133
 700    NUF=6                                                           MCGEDA    134
        CALL MDUDMD(NUF,NLF,JG,JE,KN,NSTAT,JTLN1)                       MCGEDA    135
        RETURN                                                          MCGEDA    136
 5124 FORMAT(/,1X,' *** ERROR BUS NUMBER',I5,'  IS NOT IN               MCGEDA    137
     & THE BASE LOADFLOW')                                              MCGEDA    138
 5800 FORMAT(1X)                                                        MCGEDA    139
        END                                                             MCGEDA    140
C                                                                       MCGEDA    141
        SUBROUTINE MSDBDA                                               MCGEDA    142
C                                                                       MCGEDA    143
      INCLUDE 'PARX.INS'                                                MCGEDA    144
      INCLUDE 'CNFLAG.INS'                                              MCGEDA    145
      INCLUDE 'CNMNEW.INS'                                              MCGEDA    146
      INCLUDE 'CNJPT.INS'                                               MCGEDA    147
      INCLUDE 'CNJDAT.INS'                                              MCGEDA    148
      INCLUDE 'CNTMDA.INS'                                              MCGEDA    149
      INCLUDE 'CNUNIT.INS'                                              MCGEDA    150
      INCLUDE 'CNMSG.INS'                                               MCGEDA    151
      INCLUDE 'CNPARX.INS'                                              MCGEDA    152
      INCLUDE 'CNLSTA.INS'                                              MCGEDA    153
      CHARACTER*80 EMSG,STRING                                          MCGEDA    154
      CHARACTER*12 BUSNAM                                               MCGEDA    155
C                                                                       MCGEDA    156
      LDEB=.FALSE.                                                      MCGEDA    157
C                                                                       MCGEDA    158
 100    CALL BNOVAR(IOS,NLF,BUSNAM,KLFO)                                MCGEDA    159
        IF(IOS.NE.0)THEN                                                MCGEDA    160
        IF(PLAYBA)CALL PSTOP                                            MCGEDA    161
        GOTO 100                                                        MCGEDA    162
        ENDIF                                                           MCGEDA    163
        IF(KLFO.EQ.0) THEN                                              MCGEDA    164
           IF(NLF.NE.0) NPBNOI=MNEW(NLF)                                MCGEDA    165
           IF(NLF.EQ.0.OR.NPBNOI.EQ.0) THEN                             MCGEDA    166
             WRITE (LOUT,5124) NLF                                      MCGEDA    167
             EMSG='PRESS ENTER KEY TO CONTINUE   >Q TO QUIT'            MCGEDA    168
             CALL REDLIN(LOUT,LIN,JERR,36,EMSG,'XX','UDF',STRING,       MCGEDA    169
     &          RECORD,IREC,KLAYER,KEND,KREAD,PLAYBA)                   MCGEDA    170
             IF(STRING(1:1).EQ.'Q'.OR.STRING(1:1).EQ.'q') RETURN        MCGEDA    171
             GOTO 100                                                   MCGEDA    172
           ENDIF                                                        MCGEDA    173
        ELSE                                                            MCGEDA    174
           CALL CHKBUS(BUSNAM,NLF)                                      MCGEDA    175
           IF (NLF.EQ.0) THEN                                           MCGEDA    176
             WRITE (LOUT,5114) BUSNAM                                   MCGEDA    177
             EMSG='PRESS ENTER KEY TO CONTINUE   >Q TO QUIT'            MCGEDA    178
             CALL REDLIN(LOUT,LIN,JERR,36,EMSG,'XX','UDF',STRING,       MCGEDA    179
     &          RECORD,IREC,KLAYER,KEND,KREAD,PLAYBA)                   MCGEDA    180
             IF(STRING(1:1).EQ.'Q'.OR.STRING(1:1).EQ.'q') RETURN        MCGEDA    181
             GOTO 100                                                   MCGEDA    182
           ELSE                                                         MCGEDA    183
             NPBNOI=MNEW(NLF)                                           MCGEDA    184
           ENDIF                                                        MCGEDA    185
        ENDIF                                                           MCGEDA    186
        KN=NPBNOI*8                                                     MCGEDA    187
        DO 200 I=1,JSDB                                                 MCGEDA    188
           IF(NLF.EQ.ITDDAT(JSDBDA(I)+1)) THEN                          MCGEDA    189
              NSTAT=1                                                   MCGEDA    190
              JE=JSDBDA(I)                                              MCGEDA    191
              GOTO 300                                                  MCGEDA    192
           ENDIF                                                        MCGEDA    193
 200    CONTINUE                                                        MCGEDA    194
        WRITE(LOUT,5800)                                                MCGEDA    195
        WRITE(LOUT,'(A)') ' SPECIFIED SDB IS NOT IN THE SYSTEM.'        MCGEDA    196
        EMSG='DO YOU LIKE TO ADD ONE? (Y/N)'                            MCGEDA    197
 350    CONTINUE                                                        MCGEDA    198
        CALL REDLIN(LOUT,LIN,IOERR,29,EMSG,'XXX','UDF',STRING,RECORD    MCGEDA    199
     *              ,IREC,KLAYER,KEND,KREAD,PLAYBA)                     MCGEDA    200
        IF(IOERR.LT.0)THEN                                              MCGEDA    201
        IF(PLAYBA)CALL PSTOP                                            MCGEDA    202
        GOTO 350                                                        MCGEDA    203
        ENDIF                                                           MCGEDA    204
        IF(STRING(1:1).EQ.'N'.OR.STRING(1:1).EQ.'n') RETURN             MCGEDA    205
        IF(STRING(1:1).NE.'Y'.AND.STRING(1:1).NE.'y')THEN               MCGEDA    206
        IF(PLAYBA)CALL PSTOP                                            MCGEDA    207
        GOTO 350                                                        MCGEDA    208
        ENDIF                                                           MCGEDA    209
        NSTAT=0                                                         MCGEDA    210
        JSDB=JSDB+1                                                     MCGEDA    211
        IF(JSDB.GT.NXSDB) THEN                                          MCGEDA    212
           WRITE (MSG(1),5130) NLF,NXSDB                                MCGEDA    213
           WRITE(MSG(2),5131)                                           MCGEDA    214
           CALL PRTMSG(2)                                               MCGEDA    215
           IF(PLAYBA)CALL PSTOP                                         MCGEDA    216
           IEBK=1                                                       MCGEDA    217
           RETURN                                                       MCGEDA    218
        ENDIF                                                           MCGEDA    219
        JSDBDA(JSDB)=JTLN                                               MCGEDA    220
        JE=JTLN                                                         MCGEDA    221
        ITDDAT(JE+1)=NLF                                                MCGEDA    222
        ITDDAT(JE+2)=50                                                 MCGEDA    223
 300    NUF=9                                                           MCGEDA    224
        CALL MDUDMD(NUF,NLF,JG,JE,KN,NSTAT,JTLN1)                       MCGEDA    225
        RETURN                                                          MCGEDA    226
 5114 FORMAT (/,1X,' *** ERROR BUS ',A12,' IS NOT IN THE LOADFLOW')     MCGEDA    227
 5124 FORMAT(/,1X,' *** ERROR BUS NUMBER',I5,'  IS NOT IN               MCGEDA    228
     & THE BASE LOADFLOW')                                              MCGEDA    229
 5130 FORMAT(1X,'*** ERROR SDB ON BUS ',I4                              MCGEDA    230
     &,'EXCEEDS THE LIMIT OF ',I4)                                      MCGEDA    231
 5131 FORMAT(11X,'INCREASE NXSDB IN PARX.INS')                          MCGEDA    232
 5800 FORMAT(1X)                                                        MCGEDA    233
        END                                                             MCGEDA    234
C                                                                       MCGEDA    235
C                                                                       MCGEDA    236
        SUBROUTINE MSVCDA                                               MCGEDA    237
C                                                                       MCGEDA    238
C                                                                       MCGEDA    239
      INCLUDE 'PARX.INS'                                                MCGEDA    240
      INCLUDE 'CNPARX.INS'                                              MCGEDA    241
      INCLUDE 'CNFLAG.INS'                                              MCGEDA    242
      INCLUDE 'CNB19.INS'                                               MCGEDA    243
      INCLUDE 'CNMNEW.INS'                                              MCGEDA    244
      INCLUDE 'CNPT.INS'                                                MCGEDA    245
      INCLUDE 'CNJPT.INS'                                               MCGEDA    246
      INCLUDE 'CNJDAT.INS'                                              MCGEDA    247
      INCLUDE 'CNTMDA.INS'                                              MCGEDA    248
      INCLUDE 'CNUNIT.INS'                                              MCGEDA    249
      INCLUDE 'CNLSTA.INS'                                              MCGEDA    250
      INCLUDE 'CNTGED.INS'                                              MCGEDA    251
      INCLUDE 'CNMSG.INS'                                               MCGEDA    252
      INCLUDE 'CNLFDA.INS'                                              MCGEDA    253
      CHARACTER*80 STRING,EMSG                                          MCGEDA    254
      CHARACTER*12 BRSNAM,CFBUS,CTBUS                                   MCGEDA    255
      CHARACTER*2 ICKT,MCKT                                             MCGEDA    256
      CHARACTER*7 SUBPMT                                                MCGEDA    257
      DATA SUBPMT/' MDSVC '/                                            MCGEDA    258
C                                                                       MCGEDA    259
      LDEB=.FALSE.                                                      MCGEDA    260
C                                                                       MCGEDA    261
 100  ICODE=2                                                           MCGEDA    262
      CALL BUSCID(ICODE,NLF,BRSNAM,ICKT,KLFO)                           MCGEDA    263
      IF(ICODE.LT.0)THEN                                                MCGEDA    264
      IF(PLAYBA)CALL PSTOP                                              MCGEDA    265
      GOTO 100                                                          MCGEDA    266
      ENDIF                                                             MCGEDA    267
      IF(NLF.NE.0) NPBNOI=MNEW(NLF)                                     MCGEDA    268
      IF(NLF.EQ.0.OR.NPBNOI.EQ.0)THEN                                   MCGEDA    269
 200   EMSG=                                                            MCGEDA    270
     & ' *** BUS ENTER ERROR:  DO YOU WANT TO REENTER THE DATA? (Y/N)'  MCGEDA    271
        CALL REDLIN(LOUT,LIN,JERR,36,EMSG,'XX','UDF',                   MCGEDA    272
     &     STRING,RECORD,IREC,KLAYER,KEND,KREAD,PLAYBA)                 MCGEDA    273
       IF(JERR.NE.0)THEN                                                MCGEDA    274
       IF(PLAYBA)CALL PSTOP                                             MCGEDA    275
       GOTO 200                                                         MCGEDA    276
       ENDIF                                                            MCGEDA    277
       IF(STRING.EQ.'Y'.OR.STRING.EQ.'y') GOTO 100                      MCGEDA    278
       IF(STRING.NE.'N'.AND.STRING.NE.'n')THEN                          MCGEDA    279
       IF(PLAYBA)CALL PSTOP                                             MCGEDA    280
       GOTO 200                                                         MCGEDA    281
       ENDIF                                                            MCGEDA    282
       RETURN                                                           MCGEDA    283
      ENDIF                                                             MCGEDA    284
      KN=NPBNOI*8                                                       MCGEDA    285
      NSTAT=0                                                           MCGEDA    286
      DO 300  JN=1, JSVC                                                MCGEDA    287
      MCKT=SVCID(JN)(3:4)                                               MCGEDA    288
      CALL LOGEN(ICKT,MCKT,JFOUND)                                      MCGEDA    289
      IF(NLF.EQ.JSAB(JN).AND.JFOUND.EQ.1) THEN                          MCGEDA    290
        NSTAT=2                                                         MCGEDA    291
        NRTYPX=ITDDAT(JJSDAT(JN)+9)                                     MCGEDA    292
        IF((NRTYPX.GE.1.AND.NRTYPX.LE.3).OR.NRTYPX.EQ.6.                MCGEDA    293
     *     OR.NRTYPX.EQ.50) THEN                                        MCGEDA    294
            NSTAT=1                                                     MCGEDA    295
            GOTO 500                                                    MCGEDA    296
        ELSE                                                            MCGEDA    297
            GOTO 310                                                    MCGEDA    298
        ENDIF                                                           MCGEDA    299
      ENDIF                                                             MCGEDA    300
 300  CONTINUE                                                          MCGEDA    301
 310  WRITE(LOUT,5800)                                                  MCGEDA    302
      WRITE(LOUT,'(A)') ' SPECIFIED SVC IS NOT IN THE SYSTEM.'          MCGEDA    303
      EMSG='DO YOU LIKE TO ADD ONE? (Y/N)'                              MCGEDA    304
 350  CALL REDLIN(LOUT,LIN,IOERR,29,EMSG,'XX','XXX',STRING,RECORD       MCGEDA    305
     *              ,IREC,KLAYER,KEND,KREAD,PLAYBA)                     MCGEDA    306
      IF(IOERR.LT.0)THEN                                                MCGEDA    307
      IF(PLAYBA)CALL PSTOP                                              MCGEDA    308
      GOTO 350                                                          MCGEDA    309
      ENDIF                                                             MCGEDA    310
      IF(STRING(1:1).EQ.'N'.OR.STRING(1:1).EQ.'n') RETURN               MCGEDA    311
      IF(STRING(1:1).NE.'Y'.AND.STRING(1:1).NE.'y')THEN                 MCGEDA    312
      IF(PLAYBA)CALL PSTOP                                              MCGEDA    313
      GOTO 350                                                          MCGEDA    314
      ENDIF                                                             MCGEDA    315
 400  EMSG='ENTER THE TYPE (50 FOR USER DEFINED MODEL) Q> TO QUIT'      MCGEDA    316
      CALL REDLIN(LOUT,LIN,IOERR,60,EMSG,'XX','XXX',STRING,RECORD       MCGEDA    317
     *              ,IREC,KLAYER,KEND,KREAD,PLAYBA)                     MCGEDA    318
      IF(STRING(1:1).EQ.'Q'.OR.STRING(1:1).EQ.'q') RETURN               MCGEDA    319
      READ(STRING,*,IOSTAT=IOS) NRTYPX                                  MCGEDA    320
      IF((NRTYPX.GE.1.AND.NRTYPX.LE.3).OR.NRTYPX.EQ.6.OR.               MCGEDA    321
     *  NRTYPX.EQ.50) THEN                                              MCGEDA    322
        GOTO 410                                                        MCGEDA    323
      ELSE                                                              MCGEDA    324
        WRITE(LOUT,'(A)') ' *** DATA ERROR: SVC TYPE'                   MCGEDA    325
        GOTO 400                                                        MCGEDA    326
      ENDIF                                                             MCGEDA    327
 410  IF(NSTAT.EQ.0) THEN                                               MCGEDA    328
        IF((JSVC+1).GT.NXSR) THEN                                       MCGEDA    329
          WRITE(LOUT, 5000) NLF,NXSR                                    MCGEDA    330
          IF(PLAYBA)CALL PSTOP                                          MCGEDA    331
          RETURN                                                        MCGEDA    332
        ENDIF                                                           MCGEDA    333
        JSVC=JSVC+1                                                     MCGEDA    334
        JN=JSVC                                                         MCGEDA    335
      ENDIF                                                             MCGEDA    336
      NSTAT=0                                                           MCGEDA    337
      JSAB(JN)=NLF                                                      MCGEDA    338
      SVCID(JN)(1:2)='  '                                               MCGEDA    339
      SVCID(JN)=SVCID(JN)(1:2)//MCKT                                    MCGEDA    340
      JJSDAT(JN)=JTLN                                                   MCGEDA    341
      ITDDAT(JTLN+9)=NRTYPX                                             MCGEDA    342
      ITDDAT(JTLN+10)=0                                                 MCGEDA    343
      ITDDAT(JTLN+11)=100                                               MCGEDA    344
      ITDDAT(JTLN+12)=1                                                 MCGEDA    345
      JTLN=JTLN+56                                                      MCGEDA    346
Cfor checking                                                           MCGEDA    347
c     JPQ=0                                                             MCGEDA    348
c     JTHGSR=0                                                          MCGEDA    349
c     IF(NGSREC.NE.0)THEN                                               MCGEDA    350
c         CALL ADFGEN(1,JTHGSR,NGSREC,NLF,ICKT,LFGEN,XGEID,NSORDE)      MCGEDA    351
c         IF(JTHGSR.LE.0)THEN                                           MCGEDA    352
c              JTHGSR=0                                                 MCGEDA    353
c              JDSTAT=3                                                 MCGEDA    354
c         ELSE                                                          MCGEDA    355
c              JPQ=1                                                    MCGEDA    356
c              JDSTAT=IGENST(JTHGSR)                                    MCGEDA    357
c              JTHGSR=NSORDE(JTHGSR)                                    MCGEDA    358
c         ENDIF                                                         MCGEDA    359
c     ELSE                                                              MCGEDA    360
c         JDSTAT=1                                                      MCGEDA    361
c     ENDIF                                                             MCGEDA    362
c     JSTHGS(JSVC)=JTHGSR                                               MCGEDA    363
c     JDSSAB(JSVC)=JDSTAT                                               MCGEDA    364
c     IF(JPQ.EQ.0)THEN                                                  MCGEDA    365
c         ITDDAT(JTLN+11)=0                                             MCGEDA    366
c     ELSE                                                              MCGEDA    367
c         TDDAT(JTLN+11)=GSRCD(2,JTHGSR)                                MCGEDA    368
c         IGENST(JTHGSR)=IGENST(JTHGSR)*I16B                            MCGEDA    369
c     ENDIF                                                             MCGEDA    370
C                                                                       MCGEDA    371
 500   JE=JJSDAT(JN)                                                    MCGEDA    372
       IF(NRTYPX.EQ.50) THEN                                            MCGEDA    373
       NUF=5                                                            MCGEDA    374
       CALL MDUDMD(NUF,NLF,JN,JE,KN,NSTAT,JTLN1)                        MCGEDA    375
        IF(NUF.EQ.0) THEN                                               MCGEDA    376
          ITDDAT(JE+9)=0                                                MCGEDA    377
        ELSE                                                            MCGEDA    378
          ITDDAT(JE+9)=50                                               MCGEDA    379
        ENDIF                                                           MCGEDA    380
        JJSDAT(JN)=JE                                                   MCGEDA    381
        RETURN                                                          MCGEDA    382
      ENDIF                                                             MCGEDA    383
 800  WRITE(LOUT,5010) NLF,NAMES(KN-2),NAMES(KN-1),NAMES(KN)            MCGEDA    384
     *                 ,SVCID(JN)(3:4)                                  MCGEDA    385
      IF(ITDDAT(JE+10).EQ.0) THEN                                       MCGEDA    386
        ITDDAT(JE+10)=NLF                                               MCGEDA    387
        KR=KN                                                           MCGEDA    388
      ELSE                                                              MCGEDA    389
        NPBNOI=MNEW(ITDDAT(JE+10))                                      MCGEDA    390
        KR=NPBNOI*8                                                     MCGEDA    391
      ENDIF                                                             MCGEDA    392
      GOTO (1100, 1200, 1300, 900, 900, 1600) NRTYPX                    MCGEDA    393
 900  WRITE(LOUT,'(A)') ' *** INVALID NUMBER'                           MCGEDA    394
         EMSG= 'PRESS ENTER KEY TO CONTINUE'                            MCGEDA    395
         CALL REDLIN(LOUT,LIN,JERR,36,EMSG,'XX','UDF',                  MCGEDA    396
     &         STRING,RECORD,IREC,KLAYER,KEND,KREAD,PLAYBA)             MCGEDA    397
      GOTO 400                                                          MCGEDA    398
 1100 CONTINUE                                                          MCGEDA    399
      WRITE(LOUT,5020) ITDDAT(JE+9),ITDDAT(JE+10),NAMES(KR-2)           MCGEDA    400
     * ,NAMES(KR-1),NAMES(KR),ITDDAT(JE+11),ITDDAT(JE+12)               MCGEDA    401
      WRITE(LOUT,5030) (TDDAT(JE+LI),LI=1,8)                            MCGEDA    402
      MSIEM=3                                                           MCGEDA    403
      GOTO 2000                                                         MCGEDA    404
 1200 CONTINUE                                                          MCGEDA    405
      WRITE(LOUT,5020) ITDDAT(JE+9),ITDDAT(JE+10),NAMES(KR-2)           MCGEDA    406
     * ,NAMES(KR-1),NAMES(KR),ITDDAT(JE+11),ITDDAT(JE+12)               MCGEDA    407
      WRITE(LOUT,5040) (TDDAT(JE+LI),LI=1,7),                           MCGEDA    408
     *                 (TDDAT(JE+LI),LI=13,19),                         MCGEDA    409
     *                 (TDDAT(JE+LI),LI=21,27)                          MCGEDA    410
      MSIEM=3                                                           MCGEDA    411
      GOTO 2000                                                         MCGEDA    412
 1300 CONTINUE                                                          MCGEDA    413
      WRITE(LOUT,5020) ITDDAT(JE+9),ITDDAT(JE+10),NAMES(KR-2)           MCGEDA    414
     * ,NAMES(KR-1),NAMES(KR),ITDDAT(JE+11),ITDDAT(JE+12)               MCGEDA    415
      MT1=ITDDAT(JE+28)                                                 MCGEDA    416
      IF(MT1.EQ.0) THEN                                                 MCGEDA    417
        KFB=0                                                           MCGEDA    418
        KTB=0                                                           MCGEDA    419
        IF(ITDDAT(JE+30).NE.0) KFB=MNEW(ITDDAT(JE+30))*8                MCGEDA    420
        IF(ITDDAT(JE+31).NE.0) KTB=MNEW(ITDDAT(JE+31))*8                MCGEDA    421
        IF(KFB.EQ.0.OR.KTB.EQ.0) THEN                                   MCGEDA    422
         ITDDAT(JE+30)=0                                                MCGEDA    423
         ITDDAT(JE+31)=0                                                MCGEDA    424
         ITDDAT(JE+32)=0                                                MCGEDA    425
         WRITE(LOUT,5531) ITDDAT(JE+28),ITDDAT(JE+29)                   MCGEDA    426
     *     ,ITDDAT(JE+30),ITDDAT(JE+31),ITDDAT(JE+32)                   MCGEDA    427
        ELSE                                                            MCGEDA    428
         CALL UNPACK(ICKT,LLL,ITDDAT(JE+32))                            MCGEDA    429
         WRITE(LOUT,5031) ITDDAT(JE+28),ITDDAT(JE+29)                   MCGEDA    430
     *     ,ITDDAT(JE+30),NAMES(KFB-2),NAMES(KFB-1),NAMES(KFB)          MCGEDA    431
     *     ,ITDDAT(JE+31),NAMES(KTB-2),NAMES(KTB-1),NAMES(KTB),ICKT     MCGEDA    432
        ENDIF                                                           MCGEDA    433
      ELSEIF(MT1.EQ.1) THEN                                             MCGEDA    434
        KTB=0                                                           MCGEDA    435
        IF(ITDDAT(JE+31).NE.0) KTB=MNEW(ITDDAT(JE+31))*8                MCGEDA    436
        IF(KTB.EQ.0) THEN                                               MCGEDA    437
         ITDDAT(JE+31)=0                                                MCGEDA    438
         WRITE(LOUT,5532) ITDDAT(JE+28),ITDDAT(JE+29)                   MCGEDA    439
     *,ITDDAT(JE+31),TDDAT(JE+30)                                       MCGEDA    440
        ELSE                                                            MCGEDA    441
         WRITE(LOUT,5032) ITDDAT(JE+28),ITDDAT(JE+29),ITDDAT(JE+31)     MCGEDA    442
     *,NAMES(KTB-2),NAMES(KTB-1),NAMES(KTB),TDDAT(JE+30)                MCGEDA    443
        ENDIF                                                           MCGEDA    444
      ELSEIF(MT1.EQ.2) THEN                                             MCGEDA    445
        KTB=0                                                           MCGEDA    446
        IF(ITDDAT(JE+30).NE.0) KTB=MNEW(ITDDAT(JE+30))*8                MCGEDA    447
        IF(KTB.EQ.0) THEN                                               MCGEDA    448
         ITDDAT(JE+30)=0                                                MCGEDA    449
         ITDDAT(JE+31)=0                                                MCGEDA    450
          WRITE(LOUT,5533) ITDDAT(JE+28),ITDDAT(JE+29)                  MCGEDA    451
     *     ,ITDDAT(JE+30),ITDDAT(JE+31)                                 MCGEDA    452
        ELSE                                                            MCGEDA    453
          CALL UNPACK(ICKT,LLL,ITDDAT(JE+31))                           MCGEDA    454
          WRITE(LOUT,5033) ITDDAT(JE+28),ITDDAT(JE+29)                  MCGEDA    455
     *     ,ITDDAT(JE+30),NAMES(KTB-2),NAMES(KTB-1),NAMES(KTB),ICKT     MCGEDA    456
        ENDIF                                                           MCGEDA    457
      ENDIF                                                             MCGEDA    458
      WRITE(LOUT,5040) (TDDAT(JE+LI),LI=1,7),                           MCGEDA    459
     *                 (TDDAT(JE+LI),LI=13,19),                         MCGEDA    460
     *                 (TDDAT(JE+LI),LI=21,27)                          MCGEDA    461
      WRITE(LOUT,5050) (TDDAT(JE+LI),LI=33,43)                          MCGEDA    462
      MSIEM=5                                                           MCGEDA    463
      GOTO 2000                                                         MCGEDA    464
 1600 CONTINUE                                                          MCGEDA    465
      WRITE(LOUT,5021) ITDDAT(JE+9),ITDDAT(JE+11)                       MCGEDA    466
      WRITE(LOUT,5060) (TDDAT(JE+LI),LI=1,4)                            MCGEDA    467
      MSIEM=2                                                           MCGEDA    468
 2000 WRITE(LOUT,6110)                                                  MCGEDA    469
      EMSG='ENTER ITEM# TO MODIFY OR SELECT THE ITEM; Q> QUIT'          MCGEDA    470
      CALL REDLIN(LOUT,LIN,JERR,74,EMSG,SUBPMT,'XXX',STRING             MCGEDA    471
     *,RECORD,IREC,KLAYER,KEND,KREAD,PLAYBA)                            MCGEDA    472
      IF(JERR.LT.0)THEN                                                 MCGEDA    473
      IF(PLAYBA)CALL PSTOP                                              MCGEDA    474
      GOTO 2000                                                         MCGEDA    475
      ENDIF                                                             MCGEDA    476
      IF(KLAYER.LT.0) RETURN                                            MCGEDA    477
      IF(STRING(1:1).EQ.'Q'.OR.STRING(1:1).EQ.'q') THEN                 MCGEDA    478
        EMSG= 'PRESS ENTER KEY TO CONTINUE'                             MCGEDA    479
        IF(NRTYPX.EQ.1) THEN                                            MCGEDA    480
          IF (TDDAT(JE+1).LE.0.) THEN                                   MCGEDA    481
             WRITE(LOUT,5320)                                           MCGEDA    482
             IF(PLAYBA)CALL PSTOP                                       MCGEDA    483
             CALL REDLIN(LOUT,LIN,JERR,36,EMSG,'XX','UDF',              MCGEDA    484
     &           STRING,RECORD,IREC,KLAYER,KEND,KREAD,PLAYBA)           MCGEDA    485
             GOTO 800                                                   MCGEDA    486
          ELSEIF (TDDAT(JE+2).LE.0.OR.                                  MCGEDA    487
     &        TDDAT(JE+3).LT.0.) THEN                                   MCGEDA    488
             WRITE(LOUT,5321)                                           MCGEDA    489
             IF(PLAYBA)CALL PSTOP                                       MCGEDA    490
             CALL REDLIN(LOUT,LIN,JERR,36,EMSG,'XX','UDF',              MCGEDA    491
     &           STRING,RECORD,IREC,KLAYER,KEND,KREAD,PLAYBA)           MCGEDA    492
             GOTO 800                                                   MCGEDA    493
          ENDIF                                                         MCGEDA    494
        ELSEIF(NRTYPX.EQ.2.OR.NRTYPX.EQ.3) THEN                         MCGEDA    495
          ITDDAT(JE+8)=0                                                MCGEDA    496
          IF (TDDAT(JE+14).LE.0.OR.TDDAT(JE+17).LT.0) THEN              MCGEDA    497
             WRITE(LOUT,5321)                                           MCGEDA    498
             IF(PLAYBA)CALL PSTOP                                       MCGEDA    499
             CALL REDLIN(LOUT,LIN,JERR,36,EMSG,'XX','UDF',              MCGEDA    500
     &           STRING,RECORD,IREC,KLAYER,KEND,KREAD,PLAYBA)           MCGEDA    501
             GOTO 800                                                   MCGEDA    502
          ENDIF                                                         MCGEDA    503
          IF(NRTYPX.EQ.3) THEN                                          MCGEDA    504
            IF(MT1.LT.0.OR.MT1.GT.2) THEN                               MCGEDA    505
               WRITE(LOUT,'(A)') ' *** INVALID MT1'                     MCGEDA    506
               IF(PLAYBA)CALL PSTOP                                     MCGEDA    507
               CALL REDLIN(LOUT,LIN,JERR,36,EMSG,'XX','UDF',            MCGEDA    508
     &           STRING,RECORD,IREC,KLAYER,KEND,KREAD,PLAYBA)           MCGEDA    509
               GOTO 800                                                 MCGEDA    510
            ELSEIF((MT1.EQ.0.AND.KFB.EQ.0).OR.KTB.EQ.0) THEN            MCGEDA    511
               WRITE(LOUT,'(A)') ' *** INVALID BUS NUMBER'              MCGEDA    512
               IF(PLAYBA)CALL PSTOP                                     MCGEDA    513
               CALL REDLIN(LOUT,LIN,JERR,36,EMSG,'XX','UDF',            MCGEDA    514
     &           STRING,RECORD,IREC,KLAYER,KEND,KREAD,PLAYBA)           MCGEDA    515
               GOTO 800                                                 MCGEDA    516
            ENDIF                                                       MCGEDA    517
            IF(ITDDAT(JE+37).EQ.0) THEN                                 MCGEDA    518
               WRITE(LOUT,5322)                                         MCGEDA    519
               IF(PLAYBA)CALL PSTOP                                     MCGEDA    520
               CALL REDLIN(LOUT,LIN,JERR,36,EMSG,'XX','UDF',            MCGEDA    521
     &           STRING,RECORD,IREC,KLAYER,KEND,KREAD,PLAYBA)           MCGEDA    522
               GOTO 800                                                 MCGEDA    523
            ENDIF                                                       MCGEDA    524
           ENDIF                                                        MCGEDA    525
        ENDIF                                                           MCGEDA    526
        RETURN                                                          MCGEDA    527
      ENDIF                                                             MCGEDA    528
      READ(STRING,*,IOSTAT=IOS) ITEM                                    MCGEDA    529
      IF(ITEM.EQ.98) THEN                                               MCGEDA    530
        ITDDAT(JE+9)=0                                                  MCGEDA    531
        RETURN                                                          MCGEDA    532
      ELSEIF(ITEM.EQ.99) THEN                                           MCGEDA    533
          WRITE(LOUT,5305)                                              MCGEDA    534
          EMSG='DO YOU WANT TO PROCEED? (Y/N)'                          MCGEDA    535
 2100     CALL REDLIN(LOUT,LIN,IOERR,30,EMSG,'XX','XXX',STRING          MCGEDA    536
     *        ,RECORD,IREC,KLAYER,KEND,KREAD,PLAYBA)                    MCGEDA    537
          IF(IOERR.LT.0) GOTO 2100                                      MCGEDA    538
          IF(STRING(1:1).EQ.'N'.OR.STRING(1:1).EQ.'n') GOTO 800         MCGEDA    539
          IF(STRING(1:1).NE.'Y'.AND.STRING(1:1).NE.'y') GOTO 2100       MCGEDA    540
          ITDDAT(JE+10)=0                                               MCGEDA    541
          ITDDAT(JE+11)=100                                             MCGEDA    542
          ITDDAT(JE+12)=1                                               MCGEDA    543
          DO 2301  I=1,8                                                MCGEDA    544
 2301     TDDAT(JE+I)=0.                                                MCGEDA    545
          IF(NRTYPX.EQ.2.OR.NRTYPX.EQ.3) THEN                           MCGEDA    546
            DO 2312  I=13,19                                            MCGEDA    547
 2312       TDDAT(JE+I)=0.                                              MCGEDA    548
            IF(NRTYPX.EQ.3) THEN                                        MCGEDA    549
              IF(ITDDAT(JE+28).EQ.1) TDDAT(JE+30)=0.                    MCGEDA    550
              DO 2303  I=33,43                                          MCGEDA    551
 2303         TDDAT(JE+I)=0.                                            MCGEDA    552
            ENDIF                                                       MCGEDA    553
          ENDIF                                                         MCGEDA    554
       GOTO 800                                                         MCGEDA    555
      ELSEIF(ITEM.EQ.97) THEN                                           MCGEDA    556
       WRITE (LOUT,5005)                                                MCGEDA    557
         EMSG= 'PRESS ENTER KEY TO CONTINUE'                            MCGEDA    558
         CALL REDLIN(LOUT,LIN,JERR,36,EMSG,'XX','UDF',                  MCGEDA    559
     &         STRING,RECORD,IREC,KLAYER,KEND,KREAD,PLAYBA)             MCGEDA    560
       GOTO 800                                                         MCGEDA    561
      ELSE                                                              MCGEDA    562
       EMSG= 'ENTER THE NEW VALUE:'                                     MCGEDA    563
       IF(NRTYPX.EQ.3.AND.ITEM.EQ.6) THEN                               MCGEDA    564
         IF(MT1.EQ.0) THEN                                              MCGEDA    565
           CALL LINEID(IOS,IP,IP2,CFBUS,CTBUS,ICKT,KLFO)                MCGEDA    566
           IF(IOS.NE.0)THEN                                             MCGEDA    567
           IF(PLAYBA)CALL PSTOP                                         MCGEDA    568
           GOTO 800                                                     MCGEDA    569
           ENDIF                                                        MCGEDA    570
           IF(KLFO.EQ.0) THEN                                           MCGEDA    571
             IF(IP.NE.0) NPBNOI=MNEW(IP)                                MCGEDA    572
             IF(IP2.NE.0) NPBN2=MNEW(IP2)                               MCGEDA    573
             IF(IP.EQ.0.OR.IP2.EQ.0.OR.NPBNOI.EQ.0.OR.NPBN2.EQ.0) THEN  MCGEDA    574
              IF(NPBNOI.EQ.0) WRITE (LOUT,5124) IP                      MCGEDA    575
              IF(NPBN2.EQ.0)  WRITE (LOUT,5124) IP2                     MCGEDA    576
              EMSG= 'PRESS ENTER KEY TO CONTINUE'                       MCGEDA    577
              CALL REDLIN(LOUT,LIN,JERR,36,EMSG,'XX','UDF',             MCGEDA    578
     &         STRING,RECORD,IREC,KLAYER,KEND,KREAD,PLAYBA)             MCGEDA    579
              GOTO 800                                                  MCGEDA    580
             ELSE                                                       MCGEDA    581
              ITDDAT(JE+30)=IP                                          MCGEDA    582
              ITDDAT(JE+31)=IP2                                         MCGEDA    583
             ENDIF                                                      MCGEDA    584
           ELSE                                                         MCGEDA    585
             CALL CHKBUS(CFBUS,IP)                                      MCGEDA    586
             CALL CHKBUS(CTBUS,IP2)                                     MCGEDA    587
             IF(IP.NE.0.AND.IP2.NE.0) THEN                              MCGEDA    588
              ITDDAT(JE+30)=IP                                          MCGEDA    589
              ITDDAT(JE+31)=IP2                                         MCGEDA    590
             ELSE                                                       MCGEDA    591
              WRITE(LOUT,'(A)') ' *** INVALID BUS NAME'                 MCGEDA    592
              EMSG= 'PRESS ENTER KEY TO CONTINUE'                       MCGEDA    593
              CALL REDLIN(LOUT,LIN,JERR,36,EMSG,'XX','UDF',             MCGEDA    594
     &         STRING,RECORD,IREC,KLAYER,KEND,KREAD,PLAYBA)             MCGEDA    595
             ENDIF                                                      MCGEDA    596
           ENDIF                                                        MCGEDA    597
           CALL PACK(ICKT,0,ITDDAT(JE+32))                              MCGEDA    598
           GOTO 800                                                     MCGEDA    599
         ELSEIF(MT1.EQ.2) THEN                                          MCGEDA    600
           ICODE=2                                                      MCGEDA    601
           CALL BUSCID(ICODE,IP,BRSNAM,ICKT,KLFO)                       MCGEDA    602
           IF(ICODE.LT.0)THEN                                           MCGEDA    603
           IF(PLAYBA)CALL PSTOP                                         MCGEDA    604
           GOTO 100                                                     MCGEDA    605
           ENDIF                                                        MCGEDA    606
           IF(IP.NE.0) NPBNOI=MNEW(IP)                                  MCGEDA    607
           IF(IP.EQ.0.OR.NPBNOI.EQ.0)THEN                               MCGEDA    608
             WRITE (LOUT,5124)                                          MCGEDA    609
             EMSG= 'PRESS ENTER KEY TO CONTINUE'                        MCGEDA    610
             CALL REDLIN(LOUT,LIN,JERR,36,EMSG,'XX','UDF',              MCGEDA    611
     &         STRING,RECORD,IREC,KLAYER,KEND,KREAD,PLAYBA)             MCGEDA    612
           ELSE                                                         MCGEDA    613
             ITDDAT(JE+30)=IP                                           MCGEDA    614
             CALL PACK(ICKT,0,ITDDAT(JE+31))                            MCGEDA    615
           ENDIF                                                        MCGEDA    616
           GOTO 800                                                     MCGEDA    617
         ENDIF                                                          MCGEDA    618
       ELSEIF((NRTYPX.EQ.1.AND.ITEM.GE.10.AND.ITEM.LE.17).OR.           MCGEDA    619
     &     ((NRTYPX.EQ.2.OR.NRTYPX.EQ.3).AND.                           MCGEDA    620
     &     ((ITEM.GE.10.AND.ITEM.LE.16).OR.                             MCGEDA    621
     &     (ITEM.GE.22.AND.ITEM.LE.36))).OR.                            MCGEDA    622
     &     (NRTYPX.EQ.3.AND.((ITEM.GE.42.AND.ITEM.LE.52).OR.            MCGEDA    623
     &      ITEM.EQ.39)).OR.                                            MCGEDA    624
     &     (NRTYPX.EQ.6.AND.ITEM.GE.10.AND.ITEM.LE.13)) THEN            MCGEDA    625
          CALL REDLIN(LOUT,LIN,JERR,41,EMSG,'XX','UDF',STRING,          MCGEDA    626
     &     RECORD,IREC,KLAYER,KEND,KREAD,PLAYBA)                        MCGEDA    627
          READ(STRING,*,IOSTAT=IOS) VALUE                               MCGEDA    628
          IF (IOS.EQ.0) TDDAT(JE+ITEM-9)=VALUE                          MCGEDA    629
          GOTO 800                                                      MCGEDA    630
       ELSEIF(NRTYPX.GE.1.AND.NRTYPX.LE.3.AND.ITEM.EQ.1.OR.             MCGEDA    631
     &    (NRTYPX.EQ.3.AND.MT1.EQ.1.AND.ITEM.EQ.7)) THEN                MCGEDA    632
        ITD=0                                                           MCGEDA    633
        CALL BNOVAR(IOS,ITD,BRSNAM,KLFO)                                MCGEDA    634
        IF(IOS.NE.0)THEN                                                MCGEDA    635
        IF(PLAYBA)CALL PSTOP                                            MCGEDA    636
        GOTO 800                                                        MCGEDA    637
        ENDIF                                                           MCGEDA    638
        IF(ITD.NE.0) NPBNOI=MNEW(ITD)                                   MCGEDA    639
        IF(ITD.EQ.0.OR.NPBNOI.EQ.0) THEN                                MCGEDA    640
           IF(ITEM.EQ.7) THEN                                           MCGEDA    641
            WRITE(LOUT,'(A)') ' *** BUS NUMBER ERROR'                   MCGEDA    642
            ITDDAT(JE+31)=0                                             MCGEDA    643
           ELSE                                                         MCGEDA    644
            WRITE(LOUT,5310)                                            MCGEDA    645
            ITDDAT(JE+10)=0                                             MCGEDA    646
           ENDIF                                                        MCGEDA    647
           EMSG= 'PRESS ENTER KEY TO CONTINUE'                          MCGEDA    648
           CALL REDLIN(LOUT,LIN,JERR,36,EMSG,'XX','UDF',                MCGEDA    649
     &         STRING,RECORD,IREC,KLAYER,KEND,KREAD,PLAYBA)             MCGEDA    650
         GOTO 800                                                       MCGEDA    651
        ENDIF                                                           MCGEDA    652
        IF(ITEM.EQ.7) THEN                                              MCGEDA    653
         ITDDAT(JE+31)=ITD                                              MCGEDA    654
        ELSE                                                            MCGEDA    655
         ITDDAT(JE+10)=ITD                                              MCGEDA    656
        ENDIF                                                           MCGEDA    657
        GOTO 800                                                        MCGEDA    658
       ELSEIF(ITEM.GE.2.AND.ITEM.LE.MSIEM) THEN                         MCGEDA    659
          CALL REDLIN(LOUT,LIN,JERR,41,EMSG,'XX','UDF',STRING,          MCGEDA    660
     &     RECORD,IREC,KLAYER,KEND,KREAD,PLAYBA)                        MCGEDA    661
          READ(STRING,*,IOSTAT=IOS) J                                   MCGEDA    662
          IF(NRTYPX.EQ.3.AND.ITEM.GE.4) THEN                            MCGEDA    663
           ITDDAT(JE+ITEM+24)=J                                         MCGEDA    664
           IF(ITEM.EQ.4) THEN                                           MCGEDA    665
             IF(ITDDAT(JE+28).GE.0.AND.ITDDAT(JE+28).LE.2) THEN         MCGEDA    666
               ITDDAT(JE+30)=0                                          MCGEDA    667
               IF (J.EQ.2) TDDAT(JE+30)=0.                              MCGEDA    668
               ITDDAT(JE+31)=0                                          MCGEDA    669
               ITDDAT(JE+32)=0                                          MCGEDA    670
             ELSE                                                       MCGEDA    671
               WRITE(LOUT,'(A)') ' *** INVALID NUMBER'                  MCGEDA    672
               EMSG= 'PRESS ENTER KEY TO CONTINUE'                      MCGEDA    673
               CALL REDLIN(LOUT,LIN,JERR,36,EMSG,'XX','UDF',            MCGEDA    674
     &          STRING,RECORD,IREC,KLAYER,KEND,KREAD,PLAYBA)            MCGEDA    675
               ITDDAT(JE+28)=0                                          MCGEDA    676
               GOTO 800                                                 MCGEDA    677
             ENDIF                                                      MCGEDA    678
           ENDIF                                                        MCGEDA    679
          ELSE                                                          MCGEDA    680
           ITDDAT(JE+ITEM+9)=J                                          MCGEDA    681
           IF(ITDDAT(JE+12).LT.1) ITDDAT(JE+12)=1                       MCGEDA    682
          ENDIF                                                         MCGEDA    683
          GOTO 800                                                      MCGEDA    684
       ENDIF                                                            MCGEDA    685
         WRITE(LOUT,5300)                                               MCGEDA    686
         EMSG= 'PRESS ENTER KEY TO CONTINUE'                            MCGEDA    687
         CALL REDLIN(LOUT,LIN,JERR,36,EMSG,'XX','UDF',                  MCGEDA    688
     &         STRING,RECORD,IREC,KLAYER,KEND,KREAD,PLAYBA)             MCGEDA    689
         GOTO 800                                                       MCGEDA    690
      ENDIF                                                             MCGEDA    691
 5000 FORMAT(1X,'*** ERROR SVC/SATURABLE REACTOR ON BUS ',I4            MCGEDA    692
     *,'EXCEEDS THE LIMIT OF ',I4)                                      MCGEDA    693
 5005 FORMAT(/,1X,' *** THIS FEATURE IS NOT IMPLEMENTED IN              MCGEDA    694
     & THIS VERSION')                                                   MCGEDA    695
 5010 FORMAT(//                                                         MCGEDA    696
     *,/,' BUS#:',I5,' BUS NAME: ',3A4                                  MCGEDA    697
     *,'   GID : ',A2 )                                                 MCGEDA    698
 5020 FORMAT(/,'      SVC TYPE: ',I2,                                   MCGEDA    699
     * //,'      1> SENSING BUS         2> IQF             3> IDIV',/   MCGEDA    700
     * ,5X,I5,' [',3A4,']',6X,I4,15X,I5)                                MCGEDA    701
 5021 FORMAT(/,'      SVC TYPE: ',I2,                                   MCGEDA    702
     * //,'          2> IQF',/                                          MCGEDA    703
     * ,11X,I5)                                                         MCGEDA    704
 5030 FORMAT(/,'      10> K    11> QL    12> QC    13> T1    14> T2'    MCGEDA    705
     *,/,1X,5F10.4,//                                                   MCGEDA    706
     *,        '     15> T3    16> T4    17> T5'                        MCGEDA    707
     *,/,1X,3F10.4,/)                                                   MCGEDA    708
 5031 FORMAT(/,'      4> MT1  5> MT2      6> FROM BUS'                  MCGEDA    709
     *,'             TO BUS             CKT'                            MCGEDA    710
     *,/,10X,I2,3X,I5,3X,2(2X,I5,' [',3A4,']')                          MCGEDA    711
     *,3X,A2)                                                           MCGEDA    712
 5032 FORMAT(/,'      4> MT1  5> MT2       7> NBUS'                     MCGEDA    713
     *,'                 39> TF'                                        MCGEDA    714
     *,/,10X,I2,3X,I5,5X,I5,' [',3A4,']',2X,F10.4)                      MCGEDA    715
 5033 FORMAT(/,'      4> MT1  5> MT2      6> NGBUS               GID'   MCGEDA    716
     *,/,10X,I2,3X,I5,5X,I5,' [',3A4,']',5X,A2)                         MCGEDA    717
 5040 FORMAT(/,'    10> TS1 11> VEMAX   12> TS2   13> TS3   14> TS4'    MCGEDA    718
     *,         '   15> TS5  16> KSVC',/,1X,7F10.4,//                   MCGEDA    719
     *,        '    22> KSD    23> QL  24> BMAX  25> BMIN    26> QC'    MCGEDA    720
     *,         '   27> TS6    28> DV',/,1X,7F10.4,//                   MCGEDA    721
     *,        '   30> VMAX  31> VMIN 32> VEMIN  33> BIAS   34> DV2'    MCGEDA    722
     *,         ' 35>BSHUNT    36> TD',/,1X,7F10.4,/)                   MCGEDA    723
 5050 FORMAT('    42> KS1   43> TS7   44> TS8   45> TS9  46> TS13'      MCGEDA    724
     *,         '   47> KS3 48>VSCMAX',/,1X,7F10.4,//                   MCGEDA    725
     *,        '    49> KS2  50> TS10  51> TS11  52> TS12'              MCGEDA    726
     *,/,1X,4F10.4,/)                                                   MCGEDA    727
 5060 FORMAT(/,'     10> V1    11> V2    12> G1    13> G2'              MCGEDA    728
     *,/,1X,4F10.4,/)                                                   MCGEDA    729
 5124 FORMAT(/,1X,' *** ERROR BUS NUMBER',I5,'  IS NOT IN               MCGEDA    730
     & THE BASE LOADFLOW')                                              MCGEDA    731
 5305 FORMAT(/,' *** WARNING: ALL DATA WILL BE LOST')                   MCGEDA    732
 5300 FORMAT(/,' *** SELECTION NOT VALID')                              MCGEDA    733
 5310 FORMAT(/,1X,'*** BUS NUMBER ERROR; DEFAULT VALUE WILL BE USED.')  MCGEDA    734
 5320 FORMAT(/,1X,'*** DATA ERROR: K MUST BE LARGER THAN ZERO')         MCGEDA    735
 5321 FORMAT(/,1X,'*** DATA ERROR: QL MUST BE LARGER THAN ZERO',        MCGEDA    736
     * ', AND QC BE NON-NEGATIVE')                                      MCGEDA    737
 5322 FORMAT(/,1X,'*** DATA ERROR: TS13 MUST BE LARGER THAN ZERO')      MCGEDA    738
 5531 FORMAT(/,'      4> MT1  5> MT2      6> FROM BUS'                  MCGEDA    739
     *,'             TO BUS             CKT'                            MCGEDA    740
     *,/,10X,I2,3X,I5,12X,I2,20X,I2,14X,I2)                             MCGEDA    741
 5532 FORMAT(/,'      4> MT1  5> MT2       7> NBUS'                     MCGEDA    742
     *,'                 31> TF'                                        MCGEDA    743
     *,/,10X,I2,3X,I5,12X,I2,13X,F10.4)                                 MCGEDA    744
 5533 FORMAT(/,'      4> MT1  5> MT2      6> NGBUS               GID'   MCGEDA    745
     *,/,10X,I2,3X,I5,12X,I2,16X,I2)                                    MCGEDA    746
 5800 FORMAT(1X)                                                        MCGEDA    747
 6110 FORMAT(1X,'97> RETRIEVE DATA FROM DATABASE;',                     MCGEDA    748
     *'   98> REMOVE THE SVC;       99> ENTER NEW DATA',/)              MCGEDA    749
        END                                                             MCGEDA    750
C                                                                       MCGEDA    751
        SUBROUTINE MSTPDA                                               MCGEDA    752
C                                                                       MCGEDA    753
      INCLUDE 'PARX.INS'                                                MCGEDA    754
      INCLUDE 'CNFLAG.INS'                                              MCGEDA    755
      INCLUDE 'CNB19.INS'                                               MCGEDA    756
      INCLUDE 'CNMNEW.INS'                                              MCGEDA    757
      INCLUDE 'CNJPT.INS'                                               MCGEDA    758
      INCLUDE 'CNJDAT.INS'                                              MCGEDA    759
      INCLUDE 'CNTMDA.INS'                                              MCGEDA    760
      INCLUDE 'CNUNIT.INS'                                              MCGEDA    761
      INCLUDE 'CNMSG.INS'                                               MCGEDA    762
      INCLUDE 'CNPARX.INS'                                              MCGEDA    763
      INCLUDE 'CNLSTA.INS'                                              MCGEDA    764
      INCLUDE 'CNLFDA.INS'                                              MCGEDA    765
      CHARACTER*7 SUBPMT                                                MCGEDA    766
      CHARACTER*2 CLD                                                   MCGEDA    767
      CHARACTER*80 EMSG,STRING                                          MCGEDA    768
      CHARACTER*12 CFBUS,CTBUS                                          MCGEDA    769
      EQUIVALENCE (IFBUS(1),CFBUS),(ITBUS(1),CTBUS)                     MCGEDA    770
      INTEGER*4 IFBUS(3),ITBUS(3)                                       MCGEDA    771
      REAL TABIMP(40)                                                   MCGEDA    772
      DATA SUBPMT/' MSTPDA'/                                            MCGEDA    773
C                                                                       MCGEDA    774
      LDEB=.FALSE.                                                      MCGEDA    775
C                                                                       MCGEDA    776
      NSTAT=0                                                           MCGEDA    777
      NSTAT1=0                                                          MCGEDA    778
      NSTAT2=0                                                          MCGEDA    779
      CALL LINEID(IOS,I1,I2,CFBUS,CTBUS,CLD,KLFO)                       MCGEDA    780
      CALL PACK(CLD,0,LID)                                              MCGEDA    781
      IF(KLFO.EQ.1) THEN                                                MCGEDA    782
          CALL CHKBUS(CFBUS,I1)                                         MCGEDA    783
          CALL CHKBUS(CTBUS,I2)                                         MCGEDA    784
      ENDIF                                                             MCGEDA    785
      DO 400 JN=1, JTCPS                                                MCGEDA    786
        IF(I1.EQ.ITDDAT(JJTPDA(JN)+1)                                   MCGEDA    787
     &  .AND.I2.EQ.ITDDAT(JJTPDA(JN)+2)                                 MCGEDA    788
     &  .AND.LID.EQ.ITDDAT(JJTPDA(JN)+3)) THEN                          MCGEDA    789
          NSTAT=1                                                       MCGEDA    790
          IF(ITDDAT(JJTPDA(JN)+4).EQ.50.OR.                             MCGEDA    791
     &       ITDDAT(JJTPDA(JN)+5).EQ.50) THEN                           MCGEDA    792
              JG=JJTPDA(JN)                                             MCGEDA    793
              NPBNOI=MNEW(I1)                                           MCGEDA    794
              NPBN2=MNEW(I2)                                            MCGEDA    795
              IF(ITDDAT(JG+4).EQ.50)  NSTAT1=1                          MCGEDA    796
              IF(ITDDAT(JG+5).EQ.50)  NSTAT2=1                          MCGEDA    797
              GOTO 700                                                  MCGEDA    798
          ENDIF                                                         MCGEDA    799
          GOTO 401                                                      MCGEDA    800
        ENDIF                                                           MCGEDA    801
 400  CONTINUE                                                          MCGEDA    802
 401  WRITE(LOUT,5800)                                                  MCGEDA    803
      WRITE(LOUT,'(A)') ' SPECIFIED STC/STP IS NOT IN THE SYSTEM.'      MCGEDA    804
      EMSG='DO YOU LIKE TO ADD ONE? (Y/N)'                              MCGEDA    805
 550  CALL REDLIN(LOUT,LIN,IOERR,29,EMSG,'XXX','UDF',STRING,RECORD      MCGEDA    806
     *              ,IREC,KLAYER,KEND,KREAD,PLAYBA)                     MCGEDA    807
      IF(IOERR.LT.0)THEN                                                MCGEDA    808
      IF(PLAYBA)CALL PSTOP                                              MCGEDA    809
      GOTO 550                                                          MCGEDA    810
      ENDIF                                                             MCGEDA    811
      IF(STRING(1:1).EQ.'N'.OR.STRING(1:1).EQ.'n') RETURN               MCGEDA    812
      IF(STRING(1:1).NE.'Y'.AND.STRING(1:1).NE.'y')THEN                 MCGEDA    813
      IF(PLAYBA)CALL PSTOP                                              MCGEDA    814
      GOTO 550                                                          MCGEDA    815
      ENDIF                                                             MCGEDA    816
      IF(NSTAT.EQ.1) GOTO 570                                           MCGEDA    817
 555  IF(I1.NE.0) NPBNOI=MNEW(I1)                                       MCGEDA    818
      IF(I2.NE.0) NPBN2=MNEW(I2)                                        MCGEDA    819
      IF(I1.EQ.0.OR.I2.EQ.0.OR.NPBNOI.EQ.0.OR.NPBN2.EQ.0) THEN          MCGEDA    820
          IF(NPBNOI.EQ.0) WRITE (LOUT,5124) I1                          MCGEDA    821
          IF(NPBN2.EQ.0)  WRITE (LOUT,5124) I2                          MCGEDA    822
          EMSG=                                                         MCGEDA    823
     &   ' *** DATA ERROR:  DO YOU WANT TO REENTER THE DATA? (Y/N)'     MCGEDA    824
 560      CALL REDLIN(LOUT,LIN,IOERR,60,EMSG,'XXX','UDF',STRING,        MCGEDA    825
     &        RECORD,IREC,KLAYER,KEND,KREAD,PLAYBA)                     MCGEDA    826
          IF(IOERR.NE.0) GOTO 560                                       MCGEDA    827
          IF(STRING.EQ.'Y'.OR.STRING.EQ.'y') GOTO 565                   MCGEDA    828
          IF(STRING.NE.'N'.AND.STRING.NE.'n') GOTO 560                  MCGEDA    829
          RETURN                                                        MCGEDA    830
 565      CALL LINEID(IOS,I1,I2,CFBUS,CTBUS,CLD,KLFO)                   MCGEDA    831
          CALL PACK(CLD,0,LID)                                          MCGEDA    832
          IF(KLFO.EQ.1) THEN                                            MCGEDA    833
            CALL CHKBUS(CFBUS,I1)                                       MCGEDA    834
            CALL CHKBUS(CTBUS,I2)                                       MCGEDA    835
          ENDIF                                                         MCGEDA    836
          GOTO 555                                                      MCGEDA    837
      ENDIF                                                             MCGEDA    838
      JTCPS=JTCPS+1                                                     MCGEDA    839
      JN=JTCPS                                                          MCGEDA    840
      LDSTAT=JBSTAT(NPBNOI)                                             MCGEDA    841
      IF(LDSTAT.LT.3) LDSTAT=JBSTAT(NPBN2)                              MCGEDA    842
      JSTTP(JTCPS)=LDSTAT                                               MCGEDA    843
 570  EMSG='ENTER  STC TYPE, SPS TYPE'                                  MCGEDA    844
      CALL REDLIN(LOUT,LIN,IOERR,60,EMSG,'XXX','UDF',STRING,            MCGEDA    845
     &        RECORD,IREC,KLAYER,KEND,KREAD,PLAYBA)                     MCGEDA    846
      IF(IOERR.NE.0)THEN                                                MCGEDA    847
      IF(PLAYBA)CALL PSTOP                                              MCGEDA    848
      GOTO 570                                                          MCGEDA    849
      ENDIF                                                             MCGEDA    850
      READ(STRING,*,IOSTAT=IOS) NTTYP,NPTYP                             MCGEDA    851
      IF(IOS.NE.0)THEN                                                  MCGEDA    852
      IF(PLAYBA)CALL PSTOP                                              MCGEDA    853
      GOTO 570                                                          MCGEDA    854
      ENDIF                                                             MCGEDA    855
      IF(NTTYP.NE.50) NTTYP=0                                           MCGEDA    856
      IF(NPTYP.NE.50) NPTYP=0                                           MCGEDA    857
      IF(NTTYP.EQ.0.AND.NPTYP.EQ.0) THEN                                MCGEDA    858
            WRITE(LOUT,'(A)') ' *** INVALID TYPE'                       MCGEDA    859
            IF(PLAYBA)CALL PSTOP                                        MCGEDA    860
            EMSG= 'PRESS ENTER KEY TO CONTINUE'                         MCGEDA    861
            CALL REDLIN(LOUT,LIN,JERR,36,EMSG,'XX','UDF',               MCGEDA    862
     &         STRING,RECORD,IREC,KLAYER,KEND,KREAD,PLAYBA)             MCGEDA    863
            GOTO 570                                                    MCGEDA    864
      ENDIF                                                             MCGEDA    865
      IF(NTTYP.EQ.50) THEN                                              MCGEDA    866
            EMSG=                                                       MCGEDA    867
     &'ENTER  NUMBER OF POINTS IN IMPEDANCE CORRECTION TABLE OF STC'    MCGEDA    868
 580        CALL REDLIN(LOUT,LIN,IOERR,65,EMSG,'XXX','UDF',STRING,      MCGEDA    869
     &        RECORD,IREC,KLAYER,KEND,KREAD,PLAYBA)                     MCGEDA    870
            IF(IOERR.NE.0)THEN                                          MCGEDA    871
            IF(PLAYBA)CALL PSTOP                                        MCGEDA    872
            GOTO 580                                                    MCGEDA    873
            ENDIF                                                       MCGEDA    874
            READ(STRING,*,IOSTAT=IOS) NP1                               MCGEDA    875
            IF(IOS.NE.0.OR.NP1.LT.0.OR.NP1.GT.20) GOTO 580              MCGEDA    876
      ENDIF                                                             MCGEDA    877
      IF(NPTYP.EQ.50) THEN                                              MCGEDA    878
            EMSG=                                                       MCGEDA    879
     &'ENTER  NUMBER OF POINTS IN IMPEDANCE CORRECTION TABLE OF SPS'    MCGEDA    880
 590        CALL REDLIN(LOUT,LIN,IOERR,65,EMSG,'XXX','UDF',STRING,      MCGEDA    881
     &        RECORD,IREC,KLAYER,KEND,KREAD,PLAYBA)                     MCGEDA    882
            IF(IOERR.NE.0)THEN                                          MCGEDA    883
            IF(PLAYBA)CALL PSTOP                                        MCGEDA    884
            GOTO 590                                                    MCGEDA    885
            ENDIF                                                       MCGEDA    886
            READ(STRING,*,IOSTAT=IOS) NP2                               MCGEDA    887
            IF(IOS.NE.0.OR.NP2.LT.0.OR.NP2.GT.20)THEN                   MCGEDA    888
            IF(PLAYBA)CALL PSTOP                                        MCGEDA    889
            GOTO 590                                                    MCGEDA    890
            ENDIF                                                       MCGEDA    891
      ENDIF                                                             MCGEDA    892
      JJTPDA(JN)=JTLN                                                   MCGEDA    893
      JG=JJTPDA(JN)                                                     MCGEDA    894
      ITDDAT(JG+1)=I1                                                   MCGEDA    895
      ITDDAT(JG+2)=I2                                                   MCGEDA    896
      ITDDAT(JG+3)=LID                                                  MCGEDA    897
      ITDDAT(JG+4)=NTTYP                                                MCGEDA    898
      ITDDAT(JG+5)=NPTYP                                                MCGEDA    899
      ITDDAT(JG+6)=NP1                                                  MCGEDA    900
      ITDDAT(JG+7)=NP2                                                  MCGEDA    901
      ITDDAT(JG+20)=1                                                   MCGEDA    902
      JTLN=JTLN+20+2*ITDDAT(JG+6)+2*ITDDAT(JG+7)                        MCGEDA    903
 700  IF(KLFO.EQ.0) THEN                                                MCGEDA    904
        KN=NPBNOI*8                                                     MCGEDA    905
        WRITE(CFBUS,'(3A4)') NAMES(KN-2),NAMES(KN-1),NAMES(KN)          MCGEDA    906
        KN=NPBN2*8                                                      MCGEDA    907
        WRITE(CTBUS,'(3A4)') NAMES(KN-2),NAMES(KN-1),NAMES(KN)          MCGEDA    908
      ENDIF                                                             MCGEDA    909
      WRITE(LOUT,5000)                                                  MCGEDA    910
      WRITE(LOUT,5006) I1,CFBUS,I2,CTBUS,CLD                            MCGEDA    911
      WRITE(LOUT,5057) ITDDAT(JG+20),(TDDAT(JG+I),I=8,11)               MCGEDA    912
      IF(ITDDAT(JG+4).EQ.50) WRITE(LOUT,5058)                           MCGEDA    913
      IF(ITDDAT(JG+5).EQ.50) WRITE(LOUT,5059)                           MCGEDA    914
      WRITE(LOUT,5800)                                                  MCGEDA    915
      EMSG='ENTER ITEM# TO MODIFY OR SELECT THE ITEM;  Q> QUIT'         MCGEDA    916
      CALL REDLIN(LOUT,LIN,JERR,65,EMSG,SUBPMT,'UDF',STRING             MCGEDA    917
     &  ,RECORD,IREC,KLAYER,KEND,KREAD,PLAYBA)                          MCGEDA    918
      IF(JERR.LT.0)THEN                                                 MCGEDA    919
      IF(PLAYBA)CALL PSTOP                                              MCGEDA    920
      GOTO 700                                                          MCGEDA    921
      ENDIF                                                             MCGEDA    922
      IF(KLAYER.LT.0) RETURN                                            MCGEDA    923
      IF(STRING(1:1).EQ.'Q'.OR.STRING(1:1).EQ.'q') THEN                 MCGEDA    924
        IF(ITDDAT(JG+4).EQ.50.AND.NSTAT1.EQ.0) THEN                     MCGEDA    925
          WRITE(LOUT,5224)                                              MCGEDA    926
          IF(PLAYBA)CALL PSTOP                                          MCGEDA    927
             EMSG='PRESS ENTER KEY TO CONTINUE'                         MCGEDA    928
             CALL REDLIN(LOUT,LIN,JERR,36,EMSG,'XX','UDF',STRING,       MCGEDA    929
     &          RECORD,IREC,KLAYER,KEND,KREAD,PLAYBA)                   MCGEDA    930
          GOTO 700                                                      MCGEDA    931
        ENDIF                                                           MCGEDA    932
        IF(ITDDAT(JG+5).EQ.50.AND.NSTAT2.EQ.0) THEN                     MCGEDA    933
          WRITE(LOUT,5225)                                              MCGEDA    934
          IF(PLAYBA)CALL PSTOP                                          MCGEDA    935
             EMSG='PRESS ENTER KEY TO CONTINUE'                         MCGEDA    936
             CALL REDLIN(LOUT,LIN,JERR,36,EMSG,'XX','UDF',STRING,       MCGEDA    937
     &          RECORD,IREC,KLAYER,KEND,KREAD,PLAYBA)                   MCGEDA    938
          GOTO 700                                                      MCGEDA    939
        ENDIF                                                           MCGEDA    940
        RETURN                                                          MCGEDA    941
      ENDIF                                                             MCGEDA    942
      READ (STRING, *,IOSTAT=IOS) ITEM                                  MCGEDA    943
      IF(IOS.NE.0) THEN                                                 MCGEDA    944
          IF(PLAYBA)CALL PSTOP                                          MCGEDA    945
          KREAD=.TRUE.                                                  MCGEDA    946
          GOTO 700                                                      MCGEDA    947
      ENDIF                                                             MCGEDA    948
      IF(ITEM.GE.7.AND.ITEM.LE.11) THEN                                 MCGEDA    949
          EMSG='ENTER NEW VALUE'                                        MCGEDA    950
          CALL REDLIN(LOUT,LIN,JERR,41,EMSG,'XX','UDF',STRING,          MCGEDA    951
     &  RECORD,IREC,KLAYER,KEND,KREAD,PLAYBA)                           MCGEDA    952
        IF(JERR.LT.0) GOTO 700                                          MCGEDA    953
        IF(KLAYER.LT.0) RETURN                                          MCGEDA    954
        IF(ITEM.EQ.7) THEN                                              MCGEDA    955
          READ(STRING,*,IOSTAT=IOS) J                                   MCGEDA    956
          IF(J.LT.1) J=1                                                MCGEDA    957
          IF(IOS.EQ.0) ITDDAT(JG+20)=J                                  MCGEDA    958
        ELSE                                                            MCGEDA    959
          READ(STRING,*,IOSTAT=IOS) R                                   MCGEDA    960
          IF(IOS.EQ.0) TDDAT(JG+ITEM)=R                                 MCGEDA    961
        ENDIF                                                           MCGEDA    962
        GOTO 700                                                        MCGEDA    963
      ELSEIF(ITEM.EQ.15) THEN                                           MCGEDA    964
        NUF=7                                                           MCGEDA    965
        NPTB=ITDDAT(JG+6)                                               MCGEDA    966
        DO 710 I=1,NPTB*2                                               MCGEDA    967
 710     TABIMP(I)=TDDAT(JG+20+I)                                       MCGEDA    968
        GOTO 950                                                        MCGEDA    969
      ELSEIF(ITEM.EQ.16) THEN                                           MCGEDA    970
        IF(NSTAT1.EQ.1) THEN                                            MCGEDA    971
           JE=JJTDAT(JN)                                                MCGEDA    972
        ELSE                                                            MCGEDA    973
           JE=JTLN                                                      MCGEDA    974
        ENDIF                                                           MCGEDA    975
        NUF=7                                                           MCGEDA    976
        CALL MDUDMD(NUF,NLF,JG,JE,KN,NSTAT1,JTLN1)                      MCGEDA    977
        IF(NUF.EQ.0) THEN                                               MCGEDA    978
            ITDDAT(JG+4)=0                                              MCGEDA    979
            NSTAT1=0                                                    MCGEDA    980
            JJTDAT(JN)=0                                                MCGEDA    981
            IF(ITDDAT(JG+5).EQ.0) RETURN                                MCGEDA    982
        ELSE                                                            MCGEDA    983
            JJTDAT(JN)=JE                                               MCGEDA    984
            NSTAT1=1                                                    MCGEDA    985
        ENDIF                                                           MCGEDA    986
        GOTO 700                                                        MCGEDA    987
      ELSEIF(ITEM.EQ.17) THEN                                           MCGEDA    988
        ITDDAT(JG+4)=0                                                  MCGEDA    989
        NSTAT1=0                                                        MCGEDA    990
        JJTDAT(JN)=0                                                    MCGEDA    991
        IF(ITDDAT(JG+5).EQ.0) RETURN                                    MCGEDA    992
      ELSEIF(ITEM.EQ.18) THEN                                           MCGEDA    993
        NUF=8                                                           MCGEDA    994
        NPTB=ITDDAT(JG+7)                                               MCGEDA    995
        DO 720 I=1,NPTB*2                                               MCGEDA    996
 720     TABIMP(I)=TDDAT(JG+20+2*ITDDAT(JG+6)+I)                        MCGEDA    997
        GOTO 950                                                        MCGEDA    998
      ELSEIF(ITEM.EQ.19) THEN                                           MCGEDA    999
        IF(NSTAT2.EQ.1) THEN                                            MCGEDA   1000
          JE=JJPDAT(JN)                                                 MCGEDA   1001
        ELSE                                                            MCGEDA   1002
          JE=JTLN                                                       MCGEDA   1003
        ENDIF                                                           MCGEDA   1004
        NUF=8                                                           MCGEDA   1005
        CALL MDUDMD(NUF,NLF,JG,JE,KN,NSTAT2,JTLN1)                      MCGEDA   1006
        IF(NUF.EQ.0) THEN                                               MCGEDA   1007
            ITDDAT(JG+5)=0                                              MCGEDA   1008
            NSTAT2=0                                                    MCGEDA   1009
            JJPDAT(JN)=0                                                MCGEDA   1010
            IF(ITDDAT(JG+4).EQ.0) RETURN                                MCGEDA   1011
        ELSE                                                            MCGEDA   1012
            JJPDAT(JN)=JE                                               MCGEDA   1013
            NSTAT2=1                                                    MCGEDA   1014
        ENDIF                                                           MCGEDA   1015
        GOTO 700                                                        MCGEDA   1016
      ELSEIF(ITEM.EQ.20) THEN                                           MCGEDA   1017
        ITDDAT(JG+5)=0                                                  MCGEDA   1018
        NSTAT2=0                                                        MCGEDA   1019
        JJPDAT(JN)=0                                                    MCGEDA   1020
        IF(ITDDAT(JG+4).EQ.0) RETURN                                    MCGEDA   1021
      ENDIF                                                             MCGEDA   1022
      GOTO 700                                                          MCGEDA   1023
 950  WRITE(LOUT,5000)                                                  MCGEDA   1024
      WRITE(LOUT,5715) NPTB                                             MCGEDA   1025
      IF(NUF.EQ.7) THEN                                                 MCGEDA   1026
        WRITE(LOUT,5725) (I*2-1,I, TABIMP(I*2-1),                       MCGEDA   1027
     &    I*2,I,TABIMP(I*2),I=1,NPTB)                                   MCGEDA   1028
      ELSE                                                              MCGEDA   1029
        WRITE(LOUT,5726) (I*2-1,I, TABIMP(I*2-1),                       MCGEDA   1030
     &    I*2,I,TABIMP(I*2),I=1,NPTB)                                   MCGEDA   1031
      ENDIF                                                             MCGEDA   1032
      WRITE(LOUT,5800)                                                  MCGEDA   1033
      EMSG='ENTER ITEM# TO MODIFY THE ITEM;  Q> QUIT'                   MCGEDA   1034
      CALL REDLIN(LOUT,LIN,JERR,65,EMSG,SUBPMT,'UDF',STRING             MCGEDA   1035
     &  ,RECORD,IREC,KLAYER,KEND,KREAD,PLAYBA)                          MCGEDA   1036
      IF(JERR.LT.0)  THEN                                               MCGEDA   1037
        IF(PLAYBA)CALL PSTOP                                            MCGEDA   1038
        GOTO 950                                                        MCGEDA   1039
      ENDIF                                                             MCGEDA   1040
      IF(KLAYER.LT.0) RETURN                                            MCGEDA   1041
      IF(STRING(1:1).EQ.'Q'.OR.STRING(1:1).EQ.'q') THEN                 MCGEDA   1042
        IF(NUF.EQ.7) THEN                                               MCGEDA   1043
          DO 960 I=1,NPTB*2                                             MCGEDA   1044
 960      TDDAT(JG+20+I)=TABIMP(I)                                      MCGEDA   1045
          GOTO 700                                                      MCGEDA   1046
        ELSE                                                            MCGEDA   1047
          DO 970 I=1,NPTB*2                                             MCGEDA   1048
 970      TDDAT(JG+20+2*ITDDAT(JG+6)+I)=TABIMP(I)                       MCGEDA   1049
        ENDIF                                                           MCGEDA   1050
        GOTO 700                                                        MCGEDA   1051
      ENDIF                                                             MCGEDA   1052
      READ (STRING, *,IOSTAT=IOS) ITEM                                  MCGEDA   1053
      IF(IOS.NE.0) THEN                                                 MCGEDA   1054
          IF(PLAYBA)CALL PSTOP                                          MCGEDA   1055
          KREAD=.TRUE.                                                  MCGEDA   1056
          GOTO 950                                                      MCGEDA   1057
      ENDIF                                                             MCGEDA   1058
      IF(ITEM.GE.1.AND.ITEM.LE.NPTB*2) THEN                             MCGEDA   1059
        EMSG='ENTER NEW VALUE'                                          MCGEDA   1060
        CALL REDLIN(LOUT,LIN,JERR,41,EMSG,'XX','UDF',STRING,            MCGEDA   1061
     &    RECORD,IREC,KLAYER,KEND,KREAD,PLAYBA)                         MCGEDA   1062
        IF(JERR.LT.0)THEN                                               MCGEDA   1063
        IF(PLAYBA)CALL PSTOP                                            MCGEDA   1064
        GOTO 950                                                        MCGEDA   1065
        ENDIF                                                           MCGEDA   1066
        IF(KLAYER.LT.0) RETURN                                          MCGEDA   1067
        READ(STRING,*,IOSTAT=IOS) R                                     MCGEDA   1068
        IF(IOS.EQ.0)  TABIMP(ITEM)=R                                    MCGEDA   1069
      ENDIF                                                             MCGEDA   1070
      GOTO 950                                                          MCGEDA   1071
 5000 FORMAT(//,                                                        MCGEDA   1072
     &'-------------------------------------------------'               MCGEDA   1073
     &,'------------------------------')                                MCGEDA   1074
 5006 FORMAT(' FROM BUS: ',I5,' [',A12,']',' TO BUS: ',                 MCGEDA   1075
     & I5,' [',A12,']',' CID: ', A2)                                    MCGEDA   1076
 5057 FORMAT(/,' STATIC TAP CHANGER/PHASE SHIFTER TYPE :'               MCGEDA   1077
     &,' 50 (USER DEFINED MODEL)',//                                    MCGEDA   1078
     &,'  7> IDIVX:  ',I5,3X,'  8> ATT: ',F8.4,3X,                      MCGEDA   1079
     & ' 9> XTT: ',F8.4,/,' 10> ATP: ',F8.4,3X,                         MCGEDA   1080
     & ' 11> XTP: ',F8.4,/)                                             MCGEDA   1081
 5058 FORMAT(' 15> IMPEDANCE CORRECTION TABLE OF STC',/                 MCGEDA   1082
     &,      ' 16> MORE USER DEFINED MODEL DATA FOR STC',/              MCGEDA   1083
     &,      ' 17> REMOVE THE STC')                                     MCGEDA   1084
 5059 FORMAT(' 18> IMPEDANCE CORRECTION TABLE OF SPS',/                 MCGEDA   1085
     &,      ' 19> MORE USER DEFINED MODEL DATA FOR SPS',/              MCGEDA   1086
     &,      ' 20> REMOVE THE SPS')                                     MCGEDA   1087
 5124 FORMAT(/,1X,' *** ERROR BUS NUMBER',I5,'  IS NOT IN               MCGEDA   1088
     & THE BASE LOADFLOW')                                              MCGEDA   1089
 5224 FORMAT(/,1X,' *** ERROR IN STC USER DEFINED MODEL DATA')          MCGEDA   1090
 5225 FORMAT(/,1X,' *** ERROR IN SPS USER DEFINED MODEL DATA')          MCGEDA   1091
 5715 FORMAT(1X,'IMPEDANCE CORRECTION TABLE DATA',//                    MCGEDA   1092
     &,1X,'NUMBER OF POINTS IN IMPEDANCE CORRECTION TABLE: ',I4,/)      MCGEDA   1093
 5725 FORMAT(2(I3,'> TT',I2,F10.4,1X,I3,'> FT',I2,F10.4,1X))            MCGEDA   1094
 5726 FORMAT(2(I3,'> TP',I2,1X,F9.4,1X,I3,'> FP',I2,1X,F9.4,1X))        MCGEDA   1095
 5800 FORMAT(1X)                                                        MCGEDA   1096
      END                                                               MCGEDA   1097
