CFPRIME MODIFY                                                          MODIFY      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 MODIFY (H,IPREF,IBFLAG)                                MODIFY      3
CD                                                                      MODIFY      4
CD    THIS SUBROUTINE IS THE MAIN DRIVER FOR NETWORK CHANGES AND/OR     MODIFY      5
CD    SYSTEM MODIFICATIONS REFLECTED BY THE THE SWITCHING ACTIVITIES.   MODIFY      6
CD                                                                      MODIFY      7
CD    THE MAJOR COMPUTATION STEPS ARE:                                  MODIFY      8
CD                                                                      MODIFY      9
      INCLUDE 'PARX.INS'                                                MODIFY     10
      INCLUDE 'CNPT.INS'                                                MODIFY     11
      INCLUDE 'CNFLAG.INS'                                              MODIFY     12
      INCLUDE 'CNIPTR.INS'                                              MODIFY     13
      INCLUDE 'CNSTN.INS'                                               MODIFY     14
      INCLUDE 'CNB0.INS'                                                MODIFY     15
      INCLUDE 'CNB1.INS'                                                MODIFY     16
      INCLUDE 'CNB3.INS'                                                MODIFY     17
      INCLUDE 'CNB4.INS'                                                MODIFY     18
      INCLUDE 'CNB5.INS'                                                MODIFY     19
      INCLUDE 'CNB6.INS'                                                MODIFY     20
      INCLUDE 'CNMDAT.INS'                                              MODIFY     21
      INCLUDE 'CNB8.INS'                                                MODIFY     22
      INCLUDE 'CNB9.INS'                                                MODIFY     23
      INCLUDE 'CNB10.INS'                                               MODIFY     24
      INCLUDE 'CNB19.INS'                                               MODIFY     25
      INCLUDE 'CNUVAR.INS'                                              MODIFY     26
C      INCLUDE 'CNMON.INS/LIST'                                         MODIFY     27
      INCLUDE 'CNMPAR.INS'                                              MODIFY     28
      INCLUDE 'CNSVS.INS'                                               MODIFY     29
      INCLUDE 'CNAUTO.INS'                                              MODIFY     30
      INCLUDE 'CNPARX.INS'                                              MODIFY     31
      INCLUDE 'CNUNIT.INS'                                              MODIFY     32
      INCLUDE 'CNXSTA.INS'                                              MODIFY     33
      INCLUDE 'CNSPC1.INS'                                              MODIFY     34
C     INCLUDE 'CNSPMC.INS/LIST'                                         MODIFY     35
      INCLUDE 'CNSPVI.INS'                                              MODIFY     36
C                                                                       MODIFY     37
      INCLUDE 'CNSPC0.INS'                                              MODIFY     38
C                                                                       MODIFY     39
      INCLUDE 'CNSPDI.INS'                                              MODIFY     40
      INCLUDE 'CNLKN1.INS'                                              MODIFY     41
      INCLUDE 'CNBRAU.INS'                                              MODIFY     42
      INCLUDE 'CNBRL2.INS'                                              MODIFY     43
      INCLUDE 'CNNETD.INS'                                              MODIFY     44
      INCLUDE 'CNVOLT.INS'                                              MODIFY     45
      INCLUDE 'CNSELI.INS'                                              MODIFY     46
C                                                                       MODIFY     47
      INCLUDE 'CNNNEW.INS'                                              MODIFY     48
      INCLUDE 'CNMSTA.INS'                                              MODIFY     49
      INCLUDE 'CNMYVA.INS'                                              MODIFY     50
      INCLUDE 'CNYVAR.INS'                                              MODIFY     51
C                                                                       MODIFY     52
      INCLUDE 'CNCUR.INS'                                               MODIFY     53
      INCLUDE 'CNULTC.INS'                                              MODIFY     54
C                                                                       MODIFY     55
      INCLUDE 'CNMASK.INS'                                              MODIFY     56
C                                                                       MODIFY     57
      INCLUDE 'CNRED.INS'                                               MODIFY     58
      INCLUDE 'CNMSG.INS'                                               MODIFY     59
C                                                                       MODIFY     60
      COMMON /SCRAT4/INKCUR(NDEV),OVOLT(NB)                             MODIFY     61
C                                                                       MODIFY     62
      COMPLEX CMPLX,TEMPB,OVOLT                                         MODIFY     63
      CHARACTER*2 GCKT                                                  MODIFY     64
      CHARACTER*132 CARD                                                MODIFY     65
      CHARACTER*3 IEND                                                  MODIFY     66
C                                                                       MODIFY     67
C                                                                       MODIFY     68
      LOGICAL JU1,JU2,IPREF,LDEB1,LDEB2                                 MODIFY     69
C                                                                       MODIFY     70
      INCLUDE 'CNLCOM.INS'                                              MODIFY     71
C                                                                       MODIFY     72
      DIMENSION IGROUP(6)                                               MODIFY     73
C                                                                       MODIFY     74
      INCLUDE 'CNISOC.INS'                                              MODIFY     75
      DATA IGROUP/29,32,36,46,48,52/                                    MODIFY     76
C                                                                       MODIFY     77
      DATA IEND/'ESC'/                                                  MODIFY     78
      INCLUDE 'CDLCOM.INS'                                              MODIFY     79
C==                                                                     MODIFY     80
C       INCLUDE 'TIMEHEAD.INS/LIST'                                     MODIFY     81
C       ISR=3                                                           MODIFY     82
C       INCLUDE 'TIMEINIT.INS/LIST'                                     MODIFY     83
C==                                                                     MODIFY     84
      LDEB=(JDEB(39).NE.0)                                              MODIFY     85
      LDEB1=(JDEB(298).NE.0)                                            MODIFY     86
      LDEB2=(JDEB(299).NE.0)                                            MODIFY     87
C==                                                                     MODIFY     88
C                                                                       MODIFY     89
C=                                                                      MODIFY     90
C=  "NETTOP" IS THE NETWORK CHANGE FLAG WHICH SIGNIFIES THE NECESSITY   MODIFY     91
C=  OF RECALLING SUBROUTINE "ORDER".                                    MODIFY     92
C=                                                                      MODIFY     93
C= INITIALED "1",TO BE DETERMINED IN WHAT SITUATION IT CHANGES INTO "0" MODIFY     94
C=                                                                      MODIFY     95
CD   ICRCCT = 0 NO NETWORK SWITCHING                                    MODIFY     96
CD          = 1 NETWORK SWITCHING                                       MODIFY     97
CD                                                                      MODIFY     98
CD   ISTORE = 0 READ THE LOADFLOW NETWORK INFORMATION                   MODIFY     99
CD          = 1 FINISH READING ALL THE LOADFLOW NETWORK INFORMATION     MODIFY    100
CD          = 2 WRITE THE UPDATED LOADFLOW NETWORK INFORMATION INTO IU3 MODIFY    101
CD                                                                      MODIFY    102
CD   ISCARD = NUMBER OF CARDS TO BE READ BY ROUTINE UPYMAT IN ONE       MODIFY    103
CD            SWITCHING EVENT                                           MODIFY    104
CD                                                                      MODIFY    105
CD   LOBUS  = 0 NO LOAD BUS REDUCTION                                   MODIFY    106
CD          = 1 LOAD BUS REDUCTION                                      MODIFY    107
CD                                                                      MODIFY    108
CD   NETTOP = 0 NO NETWORK TOPOLOGICAL CHANGE                           MODIFY    109
CD          = 1 NETWORK HAS BEEN TOPOLOGICALLY CHANGED                  MODIFY    110
CD                                                                      MODIFY    111
CD      IZV = BUS NUMBER OF ZERO POTENTIAL BUS                          MODIFY    112
CD                                                                      MODIFY    113
CD     NCHG = 0 NO NETWORK CHANGE                                       MODIFY    114
CD          = 1 NETWORK CHANGE                                          MODIFY    115
CD                                                                      MODIFY    116
CD    LITER = 0 NO NETWORK ITERATION                                    MODIFY    117
CD          = 1 NETWORK ITERATIVE                                       MODIFY    118
CD                                                                      MODIFY    119
CD                                                                      MODIFY    120
CD   ITSTRN     THE SIMULATION TERMINATING FLAG                         MODIFY    121
CD          = 0 NORMAL CONDITION                                        MODIFY    122
CD          = 1 SET IN GSPCHK WHEN SPEED OF GENERATOR EXCEEDS LIMIT     MODIFY    123
CD          = 2 SET IN NETSOL/IMPINT WHEN VOLTAGE ITERATION EXCEEDS     MODIFY    124
CD              LIMIT                                                   MODIFY    125
CD          = 3 SET IN INITIA WHEN PRE-FAULT NETWORK ITERATION          MODIFY    126
CD              EXCEEDS LIMIT                                           MODIFY    127
CD                                                                      MODIFY    128
C                                                                       MODIFY    129
      ISTORE=0                                                          MODIFY    130
      NETTOP=0                                                          MODIFY    131
      ICRCCT=0                                                          MODIFY    132
      ISCARD=0                                                          MODIFY    133
      IF(IPREF) NETTOP=1                                                MODIFY    134
C=                                                                      MODIFY    135
      IEBK=0                                                            MODIFY    136
      IZV=0                                                             MODIFY    137
      NCHG=0                                                            MODIFY    138
      LITER=0                                                           MODIFY    139
CD                                                                      MODIFY    140
CD    STEP 1. READ NETWORK DATA AND POINTERS FROM FILE IU4              MODIFY    141
CD                                                                      MODIFY    142
      REWIND IU4                                                        MODIFY    143
C                                                                       MODIFY    144
C                                                                       MODIFY    145
      READ(IU4) NLAST,LLNET                                             MODIFY    146
      CALL IFWR(IU4,1,NLAST,LBRI)                                       MODIFY    147
      CALL IFWR(IU4,1,LLNET*2,NELI)                                     MODIFY    148
      CALL IHWR(IU4,1,LLNET*2,KTNO)                                     MODIFY    149
      CALL IFWR(IU4,1,LLNET,IARCCT)                                     MODIFY    150
C                                                                       MODIFY    151
      READ(IU4) NTT                                                     MODIFY    152
      CALL FLWR(IU4,1,NTT,XPD)                                          MODIFY    153
C                                                                       MODIFY    154
      READ(IU4) NLBS,VTHZL,VTHZH                                        MODIFY    155
      IF(NLBS.NE.0) CALL IFWR(IU4,1,NLBS,NLDOLD)                        MODIFY    156
C                                                                       MODIFY    157
      READ(IU4) NVBS,IPNODE,NMOTL,NSVC,IGFD                             MODIFY    158
      CALL IFWR(IU4,1,NLAST,NOLD)                                       MODIFY    159
      CALL IHWR(IU4,1,NB*4,NBTDL)                                       MODIFY    160
C                                                                       MODIFY    161
      IF(NT.NE.0)CALL IHWR(IU4,1,IPNODE,NTHG)                           MODIFY    162
      IF(NMOTL.NE.0)CALL IFWR(IU4,1,NMOTL,NMOLD)                        MODIFY    163
      IF(NSVC.NE.0)CALL IFWR(IU4,1,NSVC,NROLD)                          MODIFY    164
C                                                                       MODIFY    165
      CALL CMPWR(IU4,1,NLAST,STAIRS)                                    MODIFY    166
C                                                                       MODIFY    167
      IF(IGFD.NE.0)THEN                                                 MODIFY    168
       CALL IFWR(IU4,1,IGFD,IMACH1)                                     MODIFY    169
       CALL FLWR(IU4,1,IGFD,TINOLD)                                     MODIFY    170
       DO 100 II=1,IGFD                                                 MODIFY    171
       IMACH=IMACH1(II)                                                 MODIFY    172
       JYG=MYVAR(1,IMACH)                                               MODIFY    173
       TIN(JYG+1)=TINOLD(II)                                            MODIFY    174
       IGFD=0                                                           MODIFY    175
  100  CONTINUE                                                         MODIFY    176
      ENDIF                                                             MODIFY    177
      CALL CMPWR(IU4,1,NLAST,OVOLT)                                     MODIFY    178
CD                                                                      MODIFY    179
CD    STEP 2. WRITE SYSTEM CONDITIONS INTO HISTORY FILE FOR RE-RUN      MODIFY    180
CD                                                                      MODIFY    181
      IF((ITSTRN.NE.0.OR.IDUMP.NE.0).AND.IASWX.EQ.0)THEN                MODIFY    182
      CALL HISTFL                                                       MODIFY    183
C      WRITE(IU17,5800) TS                                              MODIFY    184
      WRITE(IU6,5800) TS                                                MODIFY    185
      ENDIF                                                             MODIFY    186
C                                                                       MODIFY    187
      IF(ITSTRN.NE.0)THEN                                               MODIFY    188
          IF(ITSTRN.GT.2) THEN                                          MODIFY    189
          WRITE(MSG(1),5900)                                            MODIFY    190
          CALL PRTMSG(1)                                                MODIFY    191
          ENDIF                                                         MODIFY    192
C      INCLUDE 'TIMEACC.INS/LIST'                                       MODIFY    193
      RETURN                                                            MODIFY    194
      ENDIF                                                             MODIFY    195
CD                                                                      MODIFY    196
CD    IF REQUESTED PREPARE ARRAYS FOR LOADBUS REDUCTION                 MODIFY    197
CD                                                                      MODIFY    198
      KDO=0                                                             MODIFY    199
      IF(LOBUS.EQ.1)THEN                                                MODIFY    200
C                                                                       MODIFY    201
      IF(LOBUS.NE.LBOLD)THEN                                            MODIFY    202
C                                                                       MODIFY    203
      DO 150 I=1,NLOD                                                   MODIFY    204
        KNLBS(I)=0                                                      MODIFY    205
  150 CONTINUE                                                          MODIFY    206
      IF(LDEB)WRITE(IUD6,6900)LOBUS,LBOLD,KLBUS,TS                      MODIFY    207
C                                                                       MODIFY    208
        KDO=KLBUS                                                       MODIFY    209
C                                                                       MODIFY    210
       DO 250 J=1,KDO                                                   MODIFY    211
        IRED=NNEW(NLBUS(J))                                             MODIFY    212
        DO 200 II=1,NLOD                                                MODIFY    213
         K=NLDOLD(II)                                                   MODIFY    214
         IF(IRED.EQ.K)KNLBS(II)=1                                       MODIFY    215
  200   CONTINUE                                                        MODIFY    216
  250  CONTINUE                                                         MODIFY    217
C                                                                       MODIFY    218
        IF(KDO .GT.0 .AND. (LDEB))THEN                                  MODIFY    219
         WRITE(IUD6,7000)(KNLBS(II),II=1,NLOD)                          MODIFY    220
        ENDIF                                                           MODIFY    221
C                                                                       MODIFY    222
        ENDIF                                                           MODIFY    223
C                                                                       MODIFY    224
       ENDIF                                                            MODIFY    225
C                                                                       MODIFY    226
CD                                                                      MODIFY    227
CD  STEP 3. PREPARE CURRENT INJECTING AND MONITORING BUS VECTOR         MODIFY    228
CD                                                                      MODIFY    229
       IF( (IPREF) .OR. (LOBUS.NE.LBOLD) )THEN                          MODIFY    230
C                                                                       MODIFY    231
       DO 350 K=1,JSOUR                                                 MODIFY    232
        ICUR(K)=K                                                       MODIFY    233
        DO 300 I=1,KDO                                                  MODIFY    234
         IF(NLBUS(I) .EQ. NOLD(K))ICUR(K)=0                             MODIFY    235
  300   CONTINUE                                                        MODIFY    236
  350  CONTINUE                                                         MODIFY    237
C                                                                       MODIFY    238
C      INCLUDE THE CURRENT SOURCE DUE TO THE INFINITE BUSES             MODIFY    239
C                                                                       MODIFY    240
       IF( IFNBUS .NE. 0)THEN                                           MODIFY    241
        DO 400 K=1,KFBUS                                                MODIFY    242
         KK=KCINF(K)                                                    MODIFY    243
         ICUR(JSOUR+K)=KK                                               MODIFY    244
  400   CONTINUE                                                        MODIFY    245
        JSOUR=JSOUR+KFBUS                                               MODIFY    246
       ENDIF                                                            MODIFY    247
C                                                                       MODIFY    248
       NCUR=JSOUR                                                       MODIFY    249
       DO 500 K=1,LASTV2                                                MODIFY    250
        IVREQ(K)=K                                                      MODIFY    251
        DO 450 I=1,KDO                                                  MODIFY    252
         IF(NLBUS(I) .EQ. NOLD(K))IVREQ(K)=0                            MODIFY    253
  450   CONTINUE                                                        MODIFY    254
  500  CONTINUE                                                         MODIFY    255
      NVREQ=LASTV2                                                      MODIFY    256
C                                                                       MODIFY    257
      ENDIF                                                             MODIFY    258
C                                                                       MODIFY    259
       IF(IPREF)THEN                                                    MODIFY    260
CD                                                                      MODIFY    261
CD     COMPLETE THE ZIL NETWORK PREPARATION BY                          MODIFY    262
CD            AUGMENTING ARRAY IVREQ                                    MODIFY    263
CD                                                                      MODIFY    264
      IF(NZLINE.NE.0)THEN                                               MODIFY    265
         DO 550 K=1,NZEB                                                MODIFY    266
            IF(NEQBLT(K).LE.0) GOTO 550                                 MODIFY    267
            NVREQ=NVREQ+1                                               MODIFY    268
            IVREQ(NVREQ)=NZEVB(K)                                       MODIFY    269
  550    CONTINUE                                                       MODIFY    270
         DO 600 K=1,KOFF                                                MODIFY    271
            NTO=NZTOB(K)                                                MODIFY    272
            IF(NTO.LE.0) GOTO 600                                       MODIFY    273
            NVREQ=NVREQ+1                                               MODIFY    274
            IVREQ(NVREQ)=NTO                                            MODIFY    275
  600    CONTINUE                                                       MODIFY    276
      ENDIF                                                             MODIFY    277
C=  END OF AUGMENTATION                                                 MODIFY    278
      IF(LDEB)WRITE(IUD6,6700) JSOUR,NCUR,NLAST,NVREQ                   MODIFY    279
C                                                                       MODIFY    280
      GOTO 1300                                                         MODIFY    281
      ENDIF                                                             MODIFY    282
C                                                                       MODIFY    283
CD                                                                      MODIFY    284
CD   STEP 4. READ IN AND PROCESS THE SWITCHING DATA                     MODIFY    285
CD                                                                      MODIFY    286
      IDONE=1                                                           MODIFY    287
      ISGP=0                                                            MODIFY    288
      ISW=0                                                             MODIFY    289
      JPRO=0                                                            MODIFY    290
      IF(IASWX.EQ.0)THEN                                                MODIFY    291
      JSWF=ISWF                                                         MODIFY    292
      CALL PAGE6                                                        MODIFY    293
C      CALL PAGE17                                                      MODIFY    294
C      WRITE(IU17,6200) TS                                              MODIFY    295
      WRITE(IU6,6200) TS                                                MODIFY    296
      ELSE                                                              MODIFY    297
      JSWF=ISWFA                                                        MODIFY    298
      IF (IASWCT .GT. NAWRUC+1) THEN                                    MODIFY    299
        CALL PAGE6                                                      MODIFY    300
C        CALL PAGE17                                                    MODIFY    301
C        WRITE(IU17,6300) TS                                            MODIFY    302
        WRITE(IU6,6300) TS                                              MODIFY    303
      END IF                                                            MODIFY    304
      ENDIF                                                             MODIFY    305
  650 READ(JSWF,6000) CARD                                              MODIFY    306
      READ (CARD,6400) ITYP                                             MODIFY    307
      ISW=ISW+1                                                         MODIFY    308
      IF(ITYP.NE.IEND)GOTO 650                                          MODIFY    309
      IF(ISW.EQ.1)GOTO 1250                                             MODIFY    310
  700 CONTINUE                                                          MODIFY    311
      ISGP=ISGP+1                                                       MODIFY    312
      IF(ISGP.GT.6.OR.IDONE.EQ.ISW)GOTO 1250                            MODIFY    313
      IKEY=0                                                            MODIFY    314
      DO 750 I=1,ISW                                                    MODIFY    315
      BACKSPACE JSWF                                                    MODIFY    316
  750 CONTINUE                                                          MODIFY    317
      IPRO=JPRO+1                                                       MODIFY    318
      JPRO=IGROUP(ISGP)                                                 MODIFY    319
  800 READ(JSWF,6000) CARD                                              MODIFY    320
      READ (CARD,6400) ITYP                                             MODIFY    321
      IF(ITYP.EQ.IEND)GOTO 700                                          MODIFY    322
      DO 850 I=IPRO,JPRO                                                MODIFY    323
      IF(ITYP.EQ.ISOC(I))GOTO 900                                       MODIFY    324
  850 CONTINUE                                                          MODIFY    325
      GOTO 800                                                          MODIFY    326
  900 JTYP=I-IPRO+1                                                     MODIFY    327
      IKEY=IKEY+1                                                       MODIFY    328
      IDONE=IDONE+1                                                     MODIFY    329
      NCHG=1                                                            MODIFY    330
CD                                                                      MODIFY    331
CD    STEP 5. PERFORM CHANGES OF                                        MODIFY    332
CD                                                                      MODIFY    333
C           NET LOAD  SOL  GEN  IMO  DCL                                MODIFY    334
      GOTO (950,1000,1050,1100,1150,1200), ISGP                         MODIFY    335
C                                                                       MODIFY    336
  950 CONTINUE                                                          MODIFY    337
C                                                                       MODIFY    338
CD                                                                      MODIFY    339
CD            NETWORK                                                   MODIFY    340
CD                                                                      MODIFY    341
C                                                                       MODIFY    342
      CALL MODNET(CARD,IKEY,ISCARD,JTYP,NETTOP,IEBK,LLNET,ISTORE,ICRCCT)MODIFY    343
C                                                                       MODIFY    344
      GOTO 800                                                          MODIFY    345
C                                                                       MODIFY    346
 1000 CONTINUE                                                          MODIFY    347
C                                                                       MODIFY    348
CD                                                                      MODIFY    349
CD    NONLINEAR LOAD CHANGES                                            MODIFY    350
CD                                                                      MODIFY    351
      CALL MOLOAD(CARD,IKEY)                                            MODIFY    352
      IF(ITYP.EQ.ISOC(29).OR.ITYP.EQ.ISOC(30))THEN                      MODIFY    353
       ILSUM=1                                                          MODIFY    354
       ILSUM1=1                                                         MODIFY    355
      ENDIF                                                             MODIFY    356
C                                                                       MODIFY    357
      GOTO 800                                                          MODIFY    358
C                                                                       MODIFY    359
 1050 CONTINUE                                                          MODIFY    360
CD                                                                      MODIFY    361
CD    NETWORK SOLUTION PARAMETER                                        MODIFY    362
CD                                                                      MODIFY    363
      CALL MODSOL(CARD,IKEY,JTYP,IEBK)                                  MODIFY    364
C                                                                       MODIFY    365
      GOTO 800                                                          MODIFY    366
C                                                                       MODIFY    367
 1100 CONTINUE                                                          MODIFY    368
CD                                                                      MODIFY    369
CD    GENERATOR SYSTEM                                                  MODIFY    370
CD                                                                      MODIFY    371
      IF(ITYP.EQ.ISOC(39))THEN                                          MODIFY    372
       IGFD=IGFD+1                                                      MODIFY    373
       READ(CARD,6400)ITYP,NLFI,IMACH,GCKT,XREAL                        MODIFY    374
        IMACH1(IGFD)=IMACH                                              MODIFY    375
        JYG=MYVAR(1,IMACH)                                              MODIFY    376
        TINOLD(IGFD)=TIN(JYG+1)                                         MODIFY    377
       ENDIF                                                            MODIFY    378
C                                                                       MODIFY    379
      CALL MOGDAT(CARD,IKEY,JTYP,IEBK)                                  MODIFY    380
C                                                                       MODIFY    381
      GOTO 800                                                          MODIFY    382
C                                                                       MODIFY    383
 1150 CONTINUE                                                          MODIFY    384
C                                                                       MODIFY    385
CD                                                                      MODIFY    386
CD    INDUCTION MOTOR CHANGES                                           MODIFY    387
CD                                                                      MODIFY    388
      CALL MOMDAT(CARD,IKEY,JTYP,IEBK)                                  MODIFY    389
      GOTO 800                                                          MODIFY    390
C                                                                       MODIFY    391
 1200 CONTINUE                                                          MODIFY    392
C                                                                       MODIFY    393
C     DCLINK CHANGES                                                    MODIFY    394
C                                                                       MODIFY    395
      IF(IKEY.EQ.1)THEN                                                 MODIFY    396
C      WRITE(IU17,6600)                                                 MODIFY    397
      WRITE(IU6,6600)                                                   MODIFY    398
      ENDIF                                                             MODIFY    399
      CALL MODDCL(CARD,IKEY,JTYP,IEBK)                                  MODIFY    400
C                                                                       MODIFY    401
      GOTO 800                                                          MODIFY    402
C                                                                       MODIFY    403
CD                                                                      MODIFY    404
CD    IMPLEMENT THE CHANGES                                             MODIFY    405
CD                                                                      MODIFY    406
 1250 CONTINUE                                                          MODIFY    407
C                                                                       MODIFY    408
      IF(ISCARD.NE.0)THEN                                               MODIFY    409
        ISTORE=2                                                        MODIFY    410
        REWIND IU12                                                     MODIFY    411
        IF(ICRCCT.EQ.1)                                                 MODIFY    412
     *  CALL MODNET(CARD,IKEY,ISCARD,JTYP,NETTOP,IEBK,LLNET,ISTORE,     MODIFY    413
     *             ICRCCT)                                              MODIFY    414
        CALL UPYMAT(ISCARD)                                             MODIFY    415
        REWIND IU12                                                     MODIFY    416
      ENDIF                                                             MODIFY    417
C                                                                       MODIFY    418
CD                                                                      MODIFY    419
CD    STEP 6. READ FAULT AND ZERO POTENTIAL BUS                         MODIFY    420
CD                                                                      MODIFY    421
      ECARD=CARD                                                        MODIFY    422
C                                                                       MODIFY    423
 1300 CONTINUE                                                          MODIFY    424
C                                                                       MODIFY    425
      REWIND IU7                                                        MODIFY    426
      READ(IU7)LNET                                                     MODIFY    427
      CALL CMPWR(IU7,1,LNET,BRAU)                                       MODIFY    428
      CALL CMPWR(IU7,1,LNET,BRAL)                                       MODIFY    429
C                                                                       MODIFY    430
      IF(IPREF)GOTO 1350                                                MODIFY    431
C                                                                       MODIFY    432
      CALL BFAULT(CARD,JTYP,IFAULT,IZV,IEBK,IBFLAG,TS)                  MODIFY    433
C                                                                       MODIFY    434
      IF(LDEB)WRITE(IUD6,6800) IEBK                                     MODIFY    435
C                                                                       MODIFY    436
CD                                                                      MODIFY    437
CD    STEP 7. WRITE LINKNET FORM NETWORK DATA AND POINTERS TO (IU4)     MODIFY    438
CD                                                                      MODIFY    439
      REWIND IU4                                                        MODIFY    440
C                                                                       MODIFY    441
C                                                                       MODIFY    442
      WRITE(IU4) NLAST,LLNET                                            MODIFY    443
      CALL IFWR(IU4,0,NLAST,LBRI)                                       MODIFY    444
      CALL IFWR(IU4,0,LLNET*2,NELI)                                     MODIFY    445
      CALL IHWR(IU4,0,LLNET*2,KTNO)                                     MODIFY    446
      CALL IFWR(IU4,0,LLNET,IARCCT)                                     MODIFY    447
C                                                                       MODIFY    448
      WRITE(IU4) NTT                                                    MODIFY    449
      CALL FLWR(IU4,0,NTT,XPD)                                          MODIFY    450
C                                                                       MODIFY    451
      WRITE(IU4) NLBS,VTHZL,VTHZH                                       MODIFY    452
      IF(NLBS.NE.0) CALL IFWR(IU4,0,NLBS,NLDOLD)                        MODIFY    453
C                                                                       MODIFY    454
      WRITE(IU4) NVBS,IPNODE,NMOTL,NSVC,IGFD                            MODIFY    455
      CALL IFWR(IU4,0,NLAST,NOLD)                                       MODIFY    456
      CALL IHWR(IU4,0,NB*4,NBTDL)                                       MODIFY    457
C                                                                       MODIFY    458
      IF(NT.NE.0)CALL IHWR(IU4,0,IPNODE,NTHG)                           MODIFY    459
      IF(NMOTL.NE.0)CALL IFWR(IU4,0,NMOTL,NMOLD)                        MODIFY    460
      IF(NSVC.NE.0)CALL IFWR(IU4,0,NSVC,NROLD)                          MODIFY    461
C                                                                       MODIFY    462
      CALL CMPWR(IU4,0,NLAST,STAIRS)                                    MODIFY    463
C                                                                       MODIFY    464
      IF(IGFD.NE.0)THEN                                                 MODIFY    465
       CALL IFWR(IU4,0,IGFD,IMACH1)                                     MODIFY    466
       CALL FLWR(IU4,0,IGFD,TINOLD)                                     MODIFY    467
      ENDIF                                                             MODIFY    468
C                                                                       MODIFY    469
      CALL CMPWR(IU4,0,NLAST,OVOLT)                                     MODIFY    470
C                                                                       MODIFY    471
 1350 CONTINUE                                                          MODIFY    472
C                                                                       MODIFY    473
      NLNL=LLNET+LLNET                                                  MODIFY    474
C==                                                                     MODIFY    475
      IF (LDEB2) THEN                                                   MODIFY    476
      WRITE(IUD6,5300) NLAST,NLNL                                       MODIFY    477
      WRITE(IUD6,5400) (I,LBRI(I),I=1,NLAST)                            MODIFY    478
      WRITE(IUD6,5500) (I,NELI(I),KTNO(I),I=1,NLNL)                     MODIFY    479
      WRITE(IUD6,5600) (I,BRAU(I),BRAL(I),I=1,NL)                       MODIFY    480
      WRITE(IUD6,5700) (I,STAIRS(I),I=1,NLAST)                          MODIFY    481
      ENDIF                                                             MODIFY    482
C                                                                       MODIFY    483
      IF (LDEB1) THEN                                                   MODIFY    484
        NWORK=0                                                         MODIFY    485
        DO 1450 IX=1,NELB                                               MODIFY    486
          NLIST=MSKNEW(IX)                                              MODIFY    487
          IF(NLIST.EQ.NWORK) GOTO 1450                                  MODIFY    488
          NWORK=NLIST                                                   MODIFY    489
          LCNT=0                                                        MODIFY    490
          WRITE(IUD6,5000)NWORK,STAIRS(NWORK)                           MODIFY    491
          ITHR=LBRI(NWORK)                                              MODIFY    492
 1400     NBJ=KTNO(ITHR)                                                MODIFY    493
          LCNT=LCNT+1                                                   MODIFY    494
          LPO=(ITHR+1)/2                                                MODIFY    495
          WRITE(IUD6,5100)LCNT,ITHR,NBJ,LPO,BRAU(LPO),BRAL(LPO)         MODIFY    496
          ITHR=NELI(ITHR)                                               MODIFY    497
          IF(ITHR.EQ.0) GOTO 1450                                       MODIFY    498
          GOTO 1400                                                     MODIFY    499
 1450   CONTINUE                                                        MODIFY    500
C                                                                       MODIFY    501
        DO 1550 IX=1,NELB                                               MODIFY    502
          NWORK=MSKOLD(IX)                                              MODIFY    503
          NMASK=MSKNEW(IX)                                              MODIFY    504
          LCNT=0                                                        MODIFY    505
          WRITE(IUD6,5200)NWORK,STAIRS(NWORK),NMASK                     MODIFY    506
          ITHR=LBRI(NWORK)                                              MODIFY    507
 1500     NBJ=KTNO(ITHR)                                                MODIFY    508
          LCNT=LCNT+1                                                   MODIFY    509
          LPO=(ITHR+1)/2                                                MODIFY    510
          WRITE(IUD6,5100)LCNT,ITHR,NBJ,LPO,BRAU(LPO),BRAL(LPO)         MODIFY    511
          ITHR=NELI(ITHR)                                               MODIFY    512
          IF(ITHR.EQ.0) GOTO 1550                                       MODIFY    513
          GOTO 1500                                                     MODIFY    514
 1550   CONTINUE                                                        MODIFY    515
      ENDIF                                                             MODIFY    516
C                                                                       MODIFY    517
C                                                                       MODIFY    518
C                                                                       MODIFY    519
CD                                                                      MODIFY    520
CD    STEP 8. IF THERE ARE ZIL THEN MODIFY                              MODIFY    521
CD            THE ZERO-IMPEDANCE LINE TABLE                             MODIFY    522
CD            (IMSK/MSK/MSKNEW/MSKOLD ARRAYS)                           MODIFY    523
CD                                                                      MODIFY    524
      IF (NZLINE.EQ.0) GOTO 2200                                        MODIFY    525
      IF (NETTOP.EQ.1) CALL ZILCHG                                      MODIFY    526
C                                                                       MODIFY    527
CD                                                                      MODIFY    528
CD    CONVERT THE INTACT LINKNET TO ACTING LINKNET                      MODIFY    529
CD                                                                      MODIFY    530
      DO 1600 I=1,NELB                                                  MODIFY    531
         KNEW=MSKNEW(I)                                                 MODIFY    532
         KOLD=MSKOLD(I)                                                 MODIFY    533
C                                                                       MODIFY    534
CD                                                                      MODIFY    535
CD    ADD STATUS CHECK FOR ZIL SWITCHING                                MODIFY    536
CD                                                                      MODIFY    537
         STAIRS(KNEW)=STAIRS(KNEW)+STAIRS(KOLD)                         MODIFY    538
         STAIRS(KOLD)=(0.0,0.0)                                         MODIFY    539
 1600 CONTINUE                                                          MODIFY    540
      DO 1650 I=1,NZLINE                                                MODIFY    541
         KST=NZFROM(I)                                                  MODIFY    542
         JST=NZTO(I)                                                    MODIFY    543
C                                                                       MODIFY    544
C        ADD STATUS CHECK FOR ZIL SWITCHING                             MODIFY    545
C                                                                       MODIFY    546
         IF(NZSWIT(I).EQ.1)THEN                                         MODIFY    547
          STAIRS(KST)=STAIRS(KST)+CMPLX(0.0,1.0E-5)                     MODIFY    548
          STAIRS(JST)=STAIRS(JST)+CMPLX(0.0,1.0E-5)                     MODIFY    549
          GOTO 1650                                                     MODIFY    550
         ENDIF                                                          MODIFY    551
C                                                                       MODIFY    552
         STAIRS(KST)=STAIRS(KST)+CMPLX(0.0,-10.0)                       MODIFY    553
         STAIRS(JST)=STAIRS(JST)+CMPLX(0.0,-10.0)                       MODIFY    554
         LPO=NZLPO(I)                                                   MODIFY    555
         IENDB=LPO+LPO                                                  MODIFY    556
         IENDA=IENDB-1                                                  MODIFY    557
         KTNO(IENDA)=-KTNO(IENDA)                                       MODIFY    558
         KTNO(IENDB)=-KTNO(IENDB)                                       MODIFY    559
         BRAU(LPO)=(0.0,10.0)                                           MODIFY    560
         BRAL(LPO)=(0.0,10.0)                                           MODIFY    561
 1650 CONTINUE                                                          MODIFY    562
CD                                                                      MODIFY    563
CD    CONVERT THE 'LBRI/NELI/KTNO' STRUCTURE                            MODIFY    564
CD                                                                      MODIFY    565
      IF(NELB.EQ.0)GOTO 1900                                            MODIFY    566
C                                                                       MODIFY    567
      ILIST=1                                                           MODIFY    568
 1700 NWORK=MSKNEW(ILIST)                                               MODIFY    569
      LTHR=LBRI(NWORK)                                                  MODIFY    570
 1750 LNEXT=NELI(LTHR)                                                  MODIFY    571
CD                                                                      MODIFY    572
CD    ADD STATUS CHECK FOR ZIL SWITCHING                                MODIFY    573
CD                                                                      MODIFY    574
      IF (KTNO(LTHR).LT.0) KTNO(LTHR)=-KTNO(LTHR)                       MODIFY    575
      IF (LNEXT.NE.0) THEN                                              MODIFY    576
         LTHR=LNEXT                                                     MODIFY    577
         GOTO 1750                                                      MODIFY    578
      ELSE                                                              MODIFY    579
         LND=LTHR                                                       MODIFY    580
      END IF                                                            MODIFY    581
C                                                                       MODIFY    582
 1800 NMSK=MSKOLD(ILIST)                                                MODIFY    583
      LPRE=LND                                                          MODIFY    584
      LTHR=LBRI(NMSK)                                                   MODIFY    585
      NELI(LND)=LTHR                                                    MODIFY    586
      LBRI(NMSK)=0                                                      MODIFY    587
 1850 LNEXT=NELI(LTHR)                                                  MODIFY    588
      IF (KTNO(LTHR).LT.0) THEN                                         MODIFY    589
         NELI(LPRE)=LNEXT                                               MODIFY    590
         NELI(LTHR)=0                                                   MODIFY    591
      ELSE                                                              MODIFY    592
         LPRE=LTHR                                                      MODIFY    593
C                                                                       MODIFY    594
         LPO=(LTHR+1)/2                                                 MODIFY    595
         IPOB=LPO+LPO                                                   MODIFY    596
         IPOA=IPOB-1                                                    MODIFY    597
         NFNA=KTNO(IPOA)                                                MODIFY    598
         NFNB=KTNO(IPOB)                                                MODIFY    599
         MSKA=MSK(NFNA)                                                 MODIFY    600
         MSKB=MSK(NFNB)                                                 MODIFY    601
         KTNO(IPOA)=MSKA                                                MODIFY    602
         KTNO(IPOB)=MSKB                                                MODIFY    603
         IF (MSKB.EQ.MSKA) THEN                                         MODIFY    604
            KTNO(IPOA)=0                                                MODIFY    605
            KTNO(IPOB)=0                                                MODIFY    606
            STAIRS(MSKA)=STAIRS(MSKA)+2.0*BRAU(LPO)                     MODIFY    607
         ELSE IF (MSKB.GT.MSKA) THEN                                    MODIFY    608
            TEMPB=BRAL(LPO)                                             MODIFY    609
            BRAL(LPO)=BRAU(LPO)                                         MODIFY    610
            BRAU(LPO)=TEMPB                                             MODIFY    611
         ENDIF                                                          MODIFY    612
      ENDIF                                                             MODIFY    613
      IF (LNEXT.NE.0) THEN                                              MODIFY    614
         LTHR=LNEXT                                                     MODIFY    615
         GOTO 1850                                                      MODIFY    616
      ELSE                                                              MODIFY    617
         IF(KTNO(LTHR).LT.0)THEN                                        MODIFY    618
            LND=LPRE                                                    MODIFY    619
         ELSE                                                           MODIFY    620
            LND=LTHR                                                    MODIFY    621
         ENDIF                                                          MODIFY    622
         ILIST=ILIST+1                                                  MODIFY    623
         IF (ILIST.GT.NELB) GOTO 1900                                   MODIFY    624
         NLIST=MSKNEW(ILIST)                                            MODIFY    625
         IF (NLIST.NE.NWORK) GOTO 1700                                  MODIFY    626
         GOTO 1800                                                      MODIFY    627
      ENDIF                                                             MODIFY    628
 1900 CONTINUE                                                          MODIFY    629
C                                                                       MODIFY    630
      DO 1950 I=1,NZLINE                                                MODIFY    631
         LPO=NZLPO(I)                                                   MODIFY    632
         IENDB=LPO+LPO                                                  MODIFY    633
         IENDA=IENDB-1                                                  MODIFY    634
         IF(NZSWIT(I).EQ.1)THEN                                         MODIFY    635
           KTNO(IENDA)=-KTNO(IENDA)                                     MODIFY    636
           KTNO(IENDB)=-KTNO(IENDB)                                     MODIFY    637
           GOTO 1950                                                    MODIFY    638
         ENDIF                                                          MODIFY    639
         IFENOA=KTNO(IENDA)                                             MODIFY    640
         IFENOB=KTNO(IENDB)                                             MODIFY    641
         IF (IFENOB.LT.0) THEN                                          MODIFY    642
            KTNO(IENDB)=-KTNO(IENDB)                                    MODIFY    643
            KPO=IENDB                                                   MODIFY    644
            KNO=IABS(IFENOA)                                            MODIFY    645
            NELI(KPO)=LBRI(KNO)                                         MODIFY    646
            LBRI(KNO)=KPO                                               MODIFY    647
         ENDIF                                                          MODIFY    648
         IF (IFENOA.LT.0) THEN                                          MODIFY    649
            KTNO(IENDA)=-KTNO(IENDA)                                    MODIFY    650
            KPO=IENDA                                                   MODIFY    651
            KNO=IABS(IFENOB)                                            MODIFY    652
            NELI(KPO)=LBRI(KNO)                                         MODIFY    653
            LBRI(KNO)=KPO                                               MODIFY    654
         ENDIF                                                          MODIFY    655
 1950 CONTINUE                                                          MODIFY    656
C==                                                                     MODIFY    657
      IF (LDEB2) THEN                                                   MODIFY    658
      WRITE(IUD6,5300) NLAST,NLNL                                       MODIFY    659
      WRITE(IUD6,5400) (I,LBRI(I),I=1,NLAST)                            MODIFY    660
      WRITE(IUD6,5500) (I,NELI(I),KTNO(I),I=1,NLNL)                     MODIFY    661
      WRITE(IUD6,5600) (I,BRAU(I),BRAL(I),I=1,NL)                       MODIFY    662
      WRITE(IUD6,5700) (I,STAIRS(I),I=1,NLAST)                          MODIFY    663
      ENDIF                                                             MODIFY    664
C                                                                       MODIFY    665
      IF (LDEB1) THEN                                                   MODIFY    666
        NWORK=0                                                         MODIFY    667
        DO 2050 IX=1,NELB                                               MODIFY    668
          NLIST=MSKNEW(IX)                                              MODIFY    669
          IF(NLIST.EQ.NWORK) GOTO 2050                                  MODIFY    670
          NWORK=NLIST                                                   MODIFY    671
          LCNT=0                                                        MODIFY    672
          WRITE(IUD6,5000)NWORK,STAIRS(NWORK)                           MODIFY    673
          ITHR=LBRI(NWORK)                                              MODIFY    674
 2000     NBJ=KTNO(ITHR)                                                MODIFY    675
          LCNT=LCNT+1                                                   MODIFY    676
          LPO=(ITHR+1)/2                                                MODIFY    677
          WRITE(IUD6,5100)LCNT,ITHR,NBJ,LPO,BRAU(LPO),BRAL(LPO)         MODIFY    678
          ITHR=NELI(ITHR)                                               MODIFY    679
          IF(ITHR.EQ.0) GOTO 2050                                       MODIFY    680
          GOTO 2000                                                     MODIFY    681
 2050   CONTINUE                                                        MODIFY    682
C                                                                       MODIFY    683
        DO 2150 IX=1,NELB                                               MODIFY    684
          NWORK=MSKOLD(IX)                                              MODIFY    685
          LCNT=0                                                        MODIFY    686
          WRITE(IUD6,5200)NWORK,STAIRS(NWORK),NMASK                     MODIFY    687
          ITHR=LBRI(NWORK)                                              MODIFY    688
 2100     NBJ=KTNO(ITHR)                                                MODIFY    689
          LCNT=LCNT+1                                                   MODIFY    690
          LPO=(ITHR+1)/2                                                MODIFY    691
          WRITE(IUD6,5100)LCNT,ITHR,NBJ,LPO,BRAU(LPO),BRAL(LPO)         MODIFY    692
          ITHR=NELI(ITHR)                                               MODIFY    693
          IF(ITHR.EQ.0) GOTO 2150                                       MODIFY    694
          GOTO 2100                                                     MODIFY    695
 2150   CONTINUE                                                        MODIFY    696
      ENDIF                                                             MODIFY    697
C                                                                       MODIFY    698
C==                                                                     MODIFY    699
C                                                                       MODIFY    700
 2200 CONTINUE                                                          MODIFY    701
C--                                                                     MODIFY    702
CD                                                                      MODIFY    703
CD    STEP 9. MASK CONSTANT Z LOAD OF NONLINEAR LOAD BUS                MODIFY    704
CD                                                                      MODIFY    705
      IF(NLOD.NE.0)THEN                                                 MODIFY    706
      ISHIFT=0                                                          MODIFY    707
      DO 2500 I=1,NLOD                                                  MODIFY    708
      NCOMP=NLCOMP(1,I)                                                 MODIFY    709
      K=NLDOLD(I)                                                       MODIFY    710
      DO 2450 ICOMP=1,NCOMP                                             MODIFY    711
      ISHIFT=ISHIFT+1                                                   MODIFY    712
      NTYPE=NLTYPE(ISHIFT)                                              MODIFY    713
C                                                                       MODIFY    714
      IF(LOBUS.EQ.1 .AND. NTYPE.LE.2)THEN                               MODIFY    715
       IF(KNLBS(I).EQ.1)GOTO 2450                                       MODIFY    716
      ENDIF                                                             MODIFY    717
C                                                                       MODIFY    718
      GOTO(2250,2300,2350,2400)NTYPE                                    MODIFY    719
C                                                                       MODIFY    720
CD                                                                      MODIFY    721
CD    STEP 10. ADD G,B DUE TO CONSTANT CURRENT LOAD TO DIAGONALS        MODIFY    722
CD                                                                      MODIFY    723
 2250  CONTINUE                                                         MODIFY    724
         JNL=JDNLL(ISHIFT)                                              MODIFY    725
         MSKK=MSK(K)                                                    MODIFY    726
         STAIRS(MSKK)=STAIRS(MSKK)+CMPLX(DDAT(JNL+4),DDAT(JNL+5))       MODIFY    727
C                                                                       MODIFY    728
       GOTO 2450                                                        MODIFY    729
CD                                                                      MODIFY    730
CD       ADD G,B DUE TO CONSTANT MVA LOAD TO DIAGONALS                  MODIFY    731
CD                                                                      MODIFY    732
 2300  CONTINUE                                                         MODIFY    733
         JNL=JDNLL(ISHIFT)                                              MODIFY    734
         GKK=DDAT(JNL+2)/DDAT(JNL+4)                                    MODIFY    735
         BKK=-DDAT(JNL+3)/DDAT(JNL+4)                                   MODIFY    736
         MSKK=MSK(K)                                                    MODIFY    737
         STAIRS(MSKK)=STAIRS(MSKK)+CMPLX(GKK,BKK)                       MODIFY    738
C                                                                       MODIFY    739
       GOTO 2450                                                        MODIFY    740
C                                                                       MODIFY    741
C        RESTORE THE POINTER TO "DDAT"                                  MODIFY    742
C                                                                       MODIFY    743
 2350  CONTINUE                                                         MODIFY    744
C                                                                       MODIFY    745
      NTHLSW=0                                                          MODIFY    746
      JNL=JDNLL(ISHIFT)                                                 MODIFY    747
      JK=IDDAT(JNL+1)                                                   MODIFY    748
      ITERMP=ITERML(JK,1)                                               MODIFY    749
      ITERMQ=ITERML(JK,2)                                               MODIFY    750
      VNML=DDAT(JNL+3)                                                  MODIFY    751
      JL=JNL+10                                                         MODIFY    752
      CKMW=0.0                                                          MODIFY    753
      CKMX=0.0                                                          MODIFY    754
C                                                                       MODIFY    755
C                                                                       MODIFY    756
      IF(ITERMP.NE.0) THEN                                              MODIFY    757
         CKMW=DDAT(JL+4)*VNML**DDAT(JL+2)                               MODIFY    758
         IF(IDDAT(JL+2).NE.0) NTHLSW=1                                  MODIFY    759
         JL=JL+4                                                        MODIFY    760
         IF(ITERMP.EQ.2) THEN                                           MODIFY    761
            CKMW=CKMW+DDAT(JL+4)*VNML**DDAT(JL+2)                       MODIFY    762
            IF(IDDAT(JL+2).NE.0) NTHLSW=1                               MODIFY    763
            JL=JL+4                                                     MODIFY    764
         ENDIF                                                          MODIFY    765
      ENDIF                                                             MODIFY    766
C                                                                       MODIFY    767
      IF(ITERMQ.NE.0) THEN                                              MODIFY    768
         CKMX=DDAT(JL+4)*VNML**DDAT(JL+2)                               MODIFY    769
         IF(IDDAT(JL+2).NE.0) NTHLSW=1                                  MODIFY    770
         JL=JL+4                                                        MODIFY    771
         IF(ITERMQ.EQ.2) THEN                                           MODIFY    772
            CKMX=CKMX+DDAT(JL+4)*VNML**DDAT(JL+2)                       MODIFY    773
            IF(IDDAT(JL+2).NE.0) NTHLSW=1                               MODIFY    774
            JL=JL+4                                                     MODIFY    775
         ENDIF                                                          MODIFY    776
      ENDIF                                                             MODIFY    777
      IF(NTHLSW.EQ.0) NTHL(1,K)=0                                       MODIFY    778
C                                                                       MODIFY    779
      MSKK=MSK(K)                                                       MODIFY    780
      STAIRS(MSKK)=STAIRS(MSKK)+CMPLX(CKMW,-CKMX)                       MODIFY    781
C                                                                       MODIFY    782
      GOTO 2450                                                         MODIFY    783
CD                                                                      MODIFY    784
CD    ADD G,B DUE TO COMPOSITE LOAD TO  DIAGONALS                       MODIFY    785
CD                                                                      MODIFY    786
 2400  CONTINUE                                                         MODIFY    787
         JNL=JDNLL(ISHIFT)                                              MODIFY    788
         VBARVR=DDAT(JNL+7)                                             MODIFY    789
         VBARVI=DDAT(JNL+8)                                             MODIFY    790
         GKKB=DDAT(JNL+4)                                               MODIFY    791
         BKKB=DDAT(JNL+5)                                               MODIFY    792
         GKK=GKKB*VBARVR-BKKB*VBARVI                                    MODIFY    793
         BKK=GKKB*VBARVI+BKKB*VBARVR                                    MODIFY    794
         MSKK=MSK(K)                                                    MODIFY    795
         STAIRS(MSKK)=STAIRS(MSKK)+CMPLX(GKK,BKK)                       MODIFY    796
C                                                                       MODIFY    797
 2450 CONTINUE                                                          MODIFY    798
C                                                                       MODIFY    799
 2500 CONTINUE                                                          MODIFY    800
C                                                                       MODIFY    801
      ENDIF                                                             MODIFY    802
C                                                                       MODIFY    803
C                                                                       MODIFY    804
CD                                                                      MODIFY    805
CD    FORM THE NETWORK TOPOLOGY FILE                                    MODIFY    806
CD                                                                      MODIFY    807
CD    STEP 11. ADD SOURCE ADMITTANCES OF DYNAMIC DEVICE TO NETWORK      MODIFY    808
CD                                                                      MODIFY    809
      IF(NT.NE.0)THEN                                                   MODIFY    810
        NGTHI=0                                                         MODIFY    811
        NSALI=0                                                         MODIFY    812
        DO 2650 K=1,IPNODE                                              MODIFY    813
          U1K=0.0                                                       MODIFY    814
          U2K=0.0                                                       MODIFY    815
          NGCTF=NTHG(K+1)-NTHG(K)                                       MODIFY    816
          DO 2600 J=1,NGCTF                                             MODIFY    817
            NGTHI=NGTHI+1                                               MODIFY    818
            IGEN=ICONTA(1,NGTHI)                                        MODIFY    819
            IF(IGEN.NE.4)THEN                                           MODIFY    820
CD                                                                      MODIFY    821
CD       1  ADD SOURCE ADMITTANCE OF DETAIL MACHINE                     MODIFY    822
CD                                                                      MODIFY    823
              UX=0.5*(UVAR(1,NGTHI)+UVAR(4,NGTHI))                      MODIFY    824
              UY=0.5*(UVAR(2,NGTHI)-UVAR(3,NGTHI))                      MODIFY    825
              U1K=U1K+UX                                                MODIFY    826
              U2K=U2K+UY                                                MODIFY    827
              BUVAR(1,NGTHI)=UX                                         MODIFY    828
              BUVAR(2,NGTHI)=UY                                         MODIFY    829
              BUVAR(3,NGTHI)=-UY                                        MODIFY    830
              BUVAR(4,NGTHI)=UX                                         MODIFY    831
              ISAL(NGTHI)=.FALSE.                                       MODIFY    832
              IF(KSALI.EQ.0)THEN                                        MODIFY    833
                JU1=.FALSE.                                             MODIFY    834
                JU2=.FALSE.                                             MODIFY    835
                JU1=(ABS(UVAR(1,NGTHI)-UVAR(4,NGTHI)).LT.5.E-3)         MODIFY    836
                JU1=(ABS(UVAR(2,NGTHI)+UVAR(3,NGTHI)).LT.5.E-3)         MODIFY    837
                IF(JU1.AND.JU2)GOTO 2600                                MODIFY    838
                ISAL(NGTHI)=.TRUE.                                      MODIFY    839
                NSALI=NSALI+1                                           MODIFY    840
              ENDIF                                                     MODIFY    841
CD                                                                      MODIFY    842
CD       2 ADD SOURCE ADMITTANCE OF CLASSICAL MACHINE                   MODIFY    843
CD                                                                      MODIFY    844
            ELSE                                                        MODIFY    845
              XPDCM=XPD(NGTHI)                                          MODIFY    846
C              IF(XPDCM.GT.9999.0)XPDCM=9999.0                          MODIFY    847
                U2K=U2K-XPDCM                                           MODIFY    848
            ENDIF                                                       MODIFY    849
 2600     CONTINUE                                                      MODIFY    850
          MSKK=MSK(K)                                                   MODIFY    851
          STAIRS(MSKK)=STAIRS(MSKK)+CMPLX(-U1K,U2K)                     MODIFY    852
 2650   CONTINUE                                                        MODIFY    853
      ENDIF                                                             MODIFY    854
CD                                                                      MODIFY    855
CD       3 ADD SOURCE IMPEDANCE OF INDUCTION MOTOR                      MODIFY    856
CD                                                                      MODIFY    857
      IF (NMOTL.NE.0) THEN                                              MODIFY    858
         DO 2750 I=1,NMOTL                                              MODIFY    859
            JM=JMDAT(I)                                                 MODIFY    860
C            IF (DDAT(JM+14).GT.0.0) GOTO 2750                          MODIFY    861
            MOTYPK=IDDAT(JM+1)                                          MODIFY    862
            IF (MOTYPK.GT.10) GOTO 2750                                 MODIFY    863
            JY=JVIMO(I)                                                 MODIFY    864
            K=NMOLD(I)                                                  MODIFY    865
            MSKK=MSK(K)                                                 MODIFY    866
            STAIRS(MSKK)=STAIRS(MSKK)+CMPLX(GSMO(JY+6),-BSMO(JY+7))     MODIFY    867
 2750    CONTINUE                                                       MODIFY    868
      END IF                                                            MODIFY    869
CD                                                                      MODIFY    870
CD       4 ADD SOURCE IMPEDANCE OF TSC LOAD                             MODIFY    871
CD                                                                      MODIFY    872
      IF (NTSCL.NE.0) THEN                                              MODIFY    873
         DO 2800 I=1,NTSCL                                              MODIFY    874
            JTSC=JTCDAT(I)                                              MODIFY    875
            K=IDDAT(JTSC+1)                                             MODIFY    876
            GTSC=DDAT(JTSC+10)                                          MODIFY    877
            MSKK=MSK(K)                                                 MODIFY    878
            STAIRS(MSKK)=STAIRS(MSKK)+CMPLX(GTSC,0.0)                   MODIFY    879
 2800    CONTINUE                                                       MODIFY    880
      END IF                                                            MODIFY    881
CD                                                                      MODIFY    882
CD       5 ADD SOURCE IMPEDANCE OF SVC/REACTORS                         MODIFY    883
CD                                                                      MODIFY    884
      IF(NSVC.NE.0)THEN                                                 MODIFY    885
      DO 2850 I=1,NSVC                                                  MODIFY    886
      K=NROLD(I)                                                        MODIFY    887
      JY=JVSVR(I)                                                       MODIFY    888
      MSKK=MSK(K)                                                       MODIFY    889
      STAIRS(MSKK)=STAIRS(MSKK)+CMPLX(0.0,-BSVCO(JY+3))                 MODIFY    890
 2850 CONTINUE                                                          MODIFY    891
      ENDIF                                                             MODIFY    892
C *******                                                               MODIFY    893
C--                                                                     MODIFY    894
CD                                                                      MODIFY    895
CD   STEP 12. STORE ISOLATED BUS ADMITTANCE WITH 10 PU ADMITTANCE       MODIFY    896
CD                                                                      MODIFY    897
      IF(NISBUS.GT.0)THEN                                               MODIFY    898
        DO 2900 I=1,NISBUS                                              MODIFY    899
          K=ISBUS(I)                                                    MODIFY    900
          MSKK=MSK(K)                                                   MODIFY    901
          IF(CABS(STAIRS(MSKK)).LT.1.0E-5)STAIRS(MSKK)=CMPLX(0.,10.)    MODIFY    902
 2900   CONTINUE                                                        MODIFY    903
      ENDIF                                                             MODIFY    904
                                                                        MODIFY    905
C--                                                                     MODIFY    906
      IF(IZV.EQ.0)GOTO 3000                                             MODIFY    907
      MSKIZV=MSK(IZV)                                                   MODIFY    908
      DO 2950 MK=1,NELB                                                 MODIFY    909
         IF (MSKNEW(MK).NE.MSKIZV) GOTO 2950                            MODIFY    910
         MKZV=MSKOLD(MK)                                                MODIFY    911
         NTHL(1,MKZV)=0                                                 MODIFY    912
 2950 CONTINUE                                                          MODIFY    913
      NTHL(1,MSKIZV)=0                                                  MODIFY    914
      STAIRS(MSKIZV)=CMPLX(1.E-8,1.E8)                                  MODIFY    915
      VOLT(MSKIZV)=CMPLX(0.0,0.0)                                       MODIFY    916
      NCHG=1                                                            MODIFY    917
 3000 CONTINUE                                                          MODIFY    918
C *******                                                               MODIFY    919
      IF (LDEB2) THEN                                                   MODIFY    920
      WRITE(IUD6,5300) NLAST,NLNL                                       MODIFY    921
      WRITE(IUD6,5400) (I,LBRI(I),I=1,NLAST)                            MODIFY    922
      WRITE(IUD6,5500) (I,NELI(I),KTNO(I),I=1,NLNL)                     MODIFY    923
      WRITE(IUD6,5600) (I,BRAU(I),BRAL(I),I=1,NL)                       MODIFY    924
      WRITE(IUD6,5700) (I,STAIRS(I),I=1,NLAST)                          MODIFY    925
      ENDIF                                                             MODIFY    926
C                                                                       MODIFY    927
      IF (LDEB1) THEN                                                   MODIFY    928
        NWORK=0                                                         MODIFY    929
        DO 3100 IX=1,NELB                                               MODIFY    930
          NLIST=MSKNEW(IX)                                              MODIFY    931
          IF(NLIST.EQ.NWORK) GOTO 3100                                  MODIFY    932
          NWORK=NLIST                                                   MODIFY    933
          LCNT=0                                                        MODIFY    934
          WRITE(IUD6,5000)NWORK,STAIRS(NWORK)                           MODIFY    935
          ITHR=LBRI(NWORK)                                              MODIFY    936
 3050     NBJ=KTNO(ITHR)                                                MODIFY    937
          LCNT=LCNT+1                                                   MODIFY    938
          LPO=(ITHR+1)/2                                                MODIFY    939
          WRITE(IUD6,5100)LCNT,ITHR,NBJ,LPO,BRAU(LPO),BRAL(LPO)         MODIFY    940
          ITHR=NELI(ITHR)                                               MODIFY    941
          IF(ITHR.EQ.0) GOTO 3100                                       MODIFY    942
          GOTO 3050                                                     MODIFY    943
 3100   CONTINUE                                                        MODIFY    944
C                                                                       MODIFY    945
        DO 3200 IX=1,NELB                                               MODIFY    946
          NWORK=MSKOLD(IX)                                              MODIFY    947
          LCNT=0                                                        MODIFY    948
          WRITE(IUD6,5200)NWORK,STAIRS(NWORK)                           MODIFY    949
          ITHR=LBRI(NWORK)                                              MODIFY    950
 3150     NBJ=KTNO(ITHR)                                                MODIFY    951
          LCNT=LCNT+1                                                   MODIFY    952
          LPO=(ITHR+1)/2                                                MODIFY    953
          WRITE(IUD6,5100)LCNT,ITHR,NBJ,LPO,BRAU(LPO),BRAL(LPO)         MODIFY    954
          ITHR=NELI(ITHR)                                               MODIFY    955
          IF(ITHR.EQ.0) GOTO 3200                                       MODIFY    956
          GOTO 3150                                                     MODIFY    957
 3200   CONTINUE                                                        MODIFY    958
      ENDIF                                                             MODIFY    959
C=                                                                      MODIFY    960
C=  THE FOLLOWING HAS BEEN REVISED TO DIRECT CALLS OF ORDERING AND FACTOMODIFY    961
C=                                                                      MODIFY    962
      IF((NETTOP.EQ.1).OR.(LOBUS.NE.LBOLD))THEN                         MODIFY    963
       CALL ORDER(NLAST,LLNET)                                          MODIFY    964
      ENDIF                                                             MODIFY    965
C                                                                       MODIFY    966
C                                                                       MODIFY    967
      IF(IPREF)THEN                                                     MODIFY    968
C         CALL PAGE6                                                    MODIFY    969
C         CALL PAGE17                                                   MODIFY    970
C         WRITE(IU17,6500) TS                                           MODIFY    971
         WRITE(IU6,6500) TS                                             MODIFY    972
      ENDIF                                                             MODIFY    973
C                                                                       MODIFY    974
CD                                                                      MODIFY    975
CD    COMBINE THE PARALLEL BRANCHES TO UPDATE THE LINKNET               MODIFY    976
CD                                                                      MODIFY    977
      CALL CMBRAN(NLAST)                                                MODIFY    978
C                                                                       MODIFY    979
      CALL ACOREC(NLAST,LLNET)                                          MODIFY    980
C                                                                       MODIFY    981
      MODE=1                                                            MODIFY    982
      CALL AFACTC(MODE,NLAST)                                           MODIFY    983
C                                                                       MODIFY    984
      CALL ISTAIR(NLAST)                                                MODIFY    985
C                                                                       MODIFY    986
C  FOR LOAD BUS SIMPIFICATION OR INFINITE BUS                           MODIFY    987
C                                                                       MODIFY    988
      IF((LOBUS.EQ.1 .AND. LOBUS.NE.LBOLD))CALL REDUCE                  MODIFY    989
       LBOLD=LOBUS                                                      MODIFY    990
C                                                                       MODIFY    991
       IF(LDEB)WRITE(IUD6,6900)LOBUS,LBOLD                              MODIFY    992
C                                                                       MODIFY    993
      IF(NETTOP.EQ.1)THEN                                               MODIFY    994
         IF(LOBUS.NE.1)THEN                                             MODIFY    995
         IV=1                                                           MODIFY    996
         CALL SETSOL(NLAST,NCUR,ICUR,IV)                                MODIFY    997
         IV=2                                                           MODIFY    998
         CALL SETSOL(NLAST,NVREQ,IVREQ,IV)                              MODIFY    999
            IF(NCZLB.GT.0)THEN                                          MODIFY   1000
            IV=3                                                        MODIFY   1001
            CALL SETSOL(NLAST,NCZLB,ICZLB,IV)                           MODIFY   1002
            ENDIF                                                       MODIFY   1003
         ENDIF                                                          MODIFY   1004
      ENDIF                                                             MODIFY   1005
C                                                                       MODIFY   1006
      IF(NCHG.NE.0)TNLIS=0.0                                            MODIFY   1007
        IF(IEBK.EQ.0)THEN                                               MODIFY   1008
C          INCLUDE 'TIMEACC.INS/LIST'                                   MODIFY   1009
           RETURN                                                       MODIFY   1010
        ENDIF                                                           MODIFY   1011
      WRITE(MSG(1),6100)                                                MODIFY   1012
      CALL PRTMSG(1)                                                    MODIFY   1013
      IF(ABS(TS).LT.1.E-8)THEN                                          MODIFY   1014
      IPRTSW=3                                                          MODIFY   1015
      CALL RESULT(H,LOUT)                                               MODIFY   1016
      ENDIF                                                             MODIFY   1017
C                                                                       MODIFY   1018
C                                                                       MODIFY   1019
      MSG(1)='MODIFY: DUE TO SIMULATION SPECIFICATION DATA ERROR'       MODIFY   1020
      CALL ASTOP(MSG(1),50)                                             MODIFY   1021
C                                                                       MODIFY   1022
 5000     FORMAT(1X,'DB-MODIFY_GXL:NWORK,THE BUS NO. AND STAIRS ',I5,   MODIFY   1023
     +              1X,2G12.5)                                          MODIFY   1024
 5100     FORMAT(1X,'DB-MODIFY_GXL:LCNT,ITHR,NBJ,LPO,BRAU,BRAL ',       MODIFY   1025
     +              4I6,1X,2G12.5,1X,2G12.5)                            MODIFY   1026
 5200     FORMAT(1X,'DB-MODIFY_GXL:NWORK,THE BUS NO. AND STAIRS ',I5,   MODIFY   1027
     +              1X,2G12.5,3X,I5)                                    MODIFY   1028
 5300 FORMAT(//,1X,'DB-MODIFY_NEW:NLAST,NLNL ',2I6)                     MODIFY   1029
 5400 FORMAT(/,1X,' I,LBRI : ',/,(1X,I5,I6,I8,I6,I8,I6,I8,I6,I8,I6      MODIFY   1030
     + ,I8,I6,I8,I6,I8,I6,I8,I6))                                       MODIFY   1031
 5500 FORMAT(/,1X,' I,NELI,KTNO : ',/,(1X,I5,2I6,I8,2I6,I8,2I6,I8,2I6   MODIFY   1032
     + ,I8,2I6,I8,2I6))                                                 MODIFY   1033
 5600 FORMAT(/,1X,' I,BRAU,BRAL : ',/,(1X,I5,1X,2F9.3,1X,2F9.3,         MODIFY   1034
     + I6,1X,2F9.3,1X,2F9.3,I6,1X,2F9.3,1X,2F9.3))                      MODIFY   1035
 5700 FORMAT(/,1X,' I,STAIRS : ',/,(1X,I5,2F9.3,I7,2F9.3,I7,2F9.3       MODIFY   1036
     + ,I7,2F9.3,I7,2F9.3))                                             MODIFY   1037
 5800 FORMAT(//,30X,'* * * SYSTEM HAS BEEN STORED IN HISTORY FILE'      MODIFY   1038
     *,' AT TS=',F10.5,' SECOND * * *')                                 MODIFY   1039
 5900 FORMAT(' *** RUN TERMINATED DUE TO MAXIMUM TIME')                 MODIFY   1040
 6000 FORMAT(A132)                                                      MODIFY   1041
 6100 FORMAT(' *** SWITCHING DATA ERROR')                               MODIFY   1042
 6200 FORMAT('  USER''S MODIFICATION AT TIME TS=',F8.4,' +SEC'//)       MODIFY   1043
 6300 FORMAT('  AUTOMATIC MODIFICATION AT TIME TS=',F8.4,' +SEC'//)     MODIFY   1044
 6400 FORMAT(A3,1X,2I5,3X,A2,F10.5)                                     MODIFY   1045
 6500 FORMAT('  PRE-FAULT CONDITION TS=',F8.4,//)                       MODIFY   1046
 6600 FORMAT (///10X,'SWITCHING OF DC LINK :-',/,10X,21('-'),/T10,'TYPE MODIFY   1047
     1LINK#  RECTIFIER BUS',T42,'INVERTER BUS',T61,'DESCRIPTION',T84,'CHMODIFY   1048
     2ANGES'/)                                                          MODIFY   1049
 6700 FORMAT(1X,'JSOUR=',I5,' NCUR=',I5,' NLAST=',I5,' NVREQ=',I5)      MODIFY   1050
 6800 FORMAT(1X,'MODIFY_IEBK=',I2)                                      MODIFY   1051
C                                                                       MODIFY   1052
 6900  FORMAT(' MODIFY  LOBUS, LBOLD KLBUS TS',3I10,F10.4)              MODIFY   1053
 7000  FORMAT('  KNLBS : ',5I5)                                         MODIFY   1054
      END                                                               MODIFY   1055
