CFPRIME MOLOAD                                                          MOLOAD      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
C                                                                       MOLOAD      3
      SUBROUTINE MOLOAD(CARD,IKEY)                                      MOLOAD      4
CD                                                                      MOLOAD      5
CD    TO PERFORM THE FOLLOWING LOAD SHEDDING AND RESTORING  AND         MOLOAD      6
CD    THRESOLD VOLTAGE CHANGE ACTIVITIES:                               MOLOAD      7
CD                                                                      MOLOAD      8
CD    1. UNDER FREQUENCY LOAD SHED                                      MOLOAD      9
CD    2. UNDER VOLTAGE LOAD SHED                                        MOLOAD     10
CD    3. VOLTAGE DIFFERENCE LOAD SHED                                   MOLOAD     11
CD    4. UNDER FREQENCY CF-1 RELAY                                      MOLOAD     12
CD    5  REMOTE LOAD SHEDING                                            MOLOAD     13
CD    6. MANUAL LOAD SHEDING                                            MOLOAD     14
CD    7. AUTO LOAD RESTORATION                                          MOLOAD     15
CD    8. MANUAL LOAD RESTORATION                                        MOLOAD     16
CD    9. CHANGE OF THRESOLD VOLTAGES OF NON-LINEAR LOAD                 MOLOAD     17
CD                                                                      MOLOAD     18
      INCLUDE 'PARX.INS'                                                MOLOAD     19
      INCLUDE 'CNPT.INS'                                                MOLOAD     20
      INCLUDE 'CNFLAG.INS'                                              MOLOAD     21
      INCLUDE 'CNB6.INS'                                                MOLOAD     22
      INCLUDE 'CNB19.INS'                                               MOLOAD     23
      INCLUDE 'CNPARX.INS'                                              MOLOAD     24
      INCLUDE 'CNVOLT.INS'                                              MOLOAD     25
      INCLUDE 'CNNNEW.INS'                                              MOLOAD     26
      INCLUDE 'CNNBLD.INS'                                              MOLOAD     27
      INCLUDE 'CNSPDI.INS'                                              MOLOAD     28
      INCLUDE 'CNMDAT.INS'                                              MOLOAD     29
      INCLUDE 'CNIPTR.INS'                                              MOLOAD     30
      INCLUDE 'CNUNIT.INS'                                              MOLOAD     31
      INCLUDE 'CNSTN.INS'                                               MOLOAD     32
      INCLUDE 'CNMSG.INS'                                               MOLOAD     33
      INCLUDE 'CNLCOM.INS'                                              MOLOAD     34
C                                                                       MOLOAD     35
C                                                                       MOLOAD     36
      CHARACTER*132 CARD                                                MOLOAD     37
      CHARACTER*3 ITYP,ISOC(3)                                          MOLOAD     38
      CHARACTER*1 CTYP(6),CITYP                                         MOLOAD     39
      CHARACTER*28 DESCPT(8)                                            MOLOAD     40
      DATA ISOC/'SLD','RLD','TH '/ , CTYP/'F','V','D','U','A',' '/      MOLOAD     41
      DATA DESCPT/'UNDER FREQUENCY LOAD SHED   ',                       MOLOAD     42
     &            'UNDER VOLTAGE LOAD SHED     ',                       MOLOAD     43
     &            'VOLTAGE DIFFERENCE LOAD SHED',                       MOLOAD     44
     &            'UNDER FREQENCY CF-1 RELAY   ',                       MOLOAD     45
     &            'REMOTE LOAD SHEDING         ',                       MOLOAD     46
     &            'MANUAL LOAD SHEDING         ',                       MOLOAD     47
     &            'AUTO LOAD RESTORATION       ',                       MOLOAD     48
     &            'MANUAL LOAD RESTORATION     '/                       MOLOAD     49
C                                                                       MOLOAD     50
      INCLUDE 'CDLCOM.INS'                                              MOLOAD     51
C                                                                       MOLOAD     52
      LDEB=(JDEB(43).NE.0)                                              MOLOAD     53
C                                                                       MOLOAD     54
      PDROP1=0.0                                                        MOLOAD     55
      PDROP2=0.0                                                        MOLOAD     56
      QDROP1=0.0                                                        MOLOAD     57
      QDROP2=0.0                                                        MOLOAD     58
C                                             CONSTANT Z                MOLOAD     59
       READ(CARD,2000)ITYP,CITYP,NPROG,ISHUNT,PSHED1,QSHED1,            MOLOAD     60
C                                                                       MOLOAD     61
C      K CURRENT     CONST. MVA      VOLT EXP.                          MOLOAD     62
     & PSHED2,QSHED2,PSHED3,QSHED3,PSHED4,QSHED4                        MOLOAD     63
C                                                                       MOLOAD     64
       DO 150 I=1,6                                                     MOLOAD     65
       IF(CITYP.EQ.CTYP(I))GOTO 160                                     MOLOAD     66
 150   CONTINUE                                                         MOLOAD     67
C                                                                       MOLOAD     68
C    CITYP CAN NOT BE FOUND IN THE LIST                                 MOLOAD     69
C                                                                       MOLOAD     70
       IEBK=1                                                           MOLOAD     71
       WRITE(MSG(1),2150) CITYP                                         MOLOAD     72
       CALL PRTMSG(1)                                                   MOLOAD     73
       GOTO 1000                                                        MOLOAD     74
C                                                                       MOLOAD     75
 160   IT=I                                                             MOLOAD     76
C                                                                       MOLOAD     77
       DO 100 JTYP=1,3                                                  MOLOAD     78
       IF(ITYP.EQ.ISOC(JTYP))GOTO 200                                   MOLOAD     79
 100   CONTINUE                                                         MOLOAD     80
C                                                                       MOLOAD     81
C      ITYP NOT FOUND WRITE ERROR MESSAGE                               MOLOAD     82
C                                                                       MOLOAD     83
       IEBK=1                                                           MOLOAD     84
       WRITE(MSG(1),2100)ITYP                                           MOLOAD     85
       CALL PRTMSG(1)                                                   MOLOAD     86
       GOTO 1000                                                        MOLOAD     87
C                                                                       MOLOAD     88
 200    CONTINUE                                                        MOLOAD     89
C                                                                       MOLOAD     90
         IF(IT.NE.4)THEN                                                MOLOAD     91
           PSHED4=PSHED1                                                MOLOAD     92
           QSHED4=QSHED1                                                MOLOAD     93
           PSHED3=PSHED1                                                MOLOAD     94
           QSHED3=QSHED1                                                MOLOAD     95
           PSHED2=PSHED1                                                MOLOAD     96
           QSHED2=QSHED1                                                MOLOAD     97
         ENDIF                                                          MOLOAD     98
C                                                                       MOLOAD     99
         II3=NPROG*3                                                    MOLOAD    100
         II2=II3-1                                                      MOLOAD    101
         II1=II3-2                                                      MOLOAD    102
C                                                                       MOLOAD    103
      IF(IKEY.EQ.1)THEN                                                 MOLOAD    104
C      WRITE(IU17,1440)                                                 MOLOAD    105
      WRITE(IU6,1440)                                                   MOLOAD    106
      ENDIF                                                             MOLOAD    107
C                                                                       MOLOAD    108
      NLF=NOLD(NPROG)                                                   MOLOAD    109
C                                                                       MOLOAD    110
                                                                        MOLOAD    111
      GOTO (500,510,620), JTYP                                          MOLOAD    112
C                                                                       MOLOAD    113
 500  CONTINUE                                                          MOLOAD    114
C                                                                       MOLOAD    115
      IF(IT.NE.4)THEN                                                   MOLOAD    116
C      WRITE(IU17,1500)ISOC(JTYP),NLF,INAME(II1),INAME(II2),INAME(II3), MOLOAD    117
C     & DESCPT(IT),PSHED1,QSHED1                                        MOLOAD    118
      WRITE(IU6,1500)ISOC(JTYP),NLF,INAME(II1),INAME(II2),INAME(II3),   MOLOAD    119
     & DESCPT(IT),PSHED1,QSHED1                                         MOLOAD    120
      ELSE                                                              MOLOAD    121
C      WRITE(IU17,1550)ISOC(JTYP),NLF,INAME(II1),INAME(II2),INAME(II3), MOLOAD    122
C     & DESCPT(IT),PSHED1,QSHED1,PSHED2,QSHED2,PSHED3,QSHED3,PSHED4,    MOLOAD    123
C     & QSHED4                                                          MOLOAD    124
      WRITE(IU6,1550)ISOC(JTYP),NLF,INAME(II1),INAME(II2),INAME(II3),   MOLOAD    125
     & DESCPT(IT),PSHED1,QSHED1,PSHED2,QSHED2,PSHED3,QSHED3,PSHED4,     MOLOAD    126
     & QSHED4                                                           MOLOAD    127
      ENDIF                                                             MOLOAD    128
C                                                                       MOLOAD    129
      IL=JBLD(NPROG)                                                    MOLOAD    130
      IF(IL.EQ.0)THEN                                                   MOLOAD    131
       WRITE(IU6,1560)                                                  MOLOAD    132
C       WRITE(IU17,1560)                                                MOLOAD    133
       GOTO 1000                                                        MOLOAD    134
      ENDIF                                                             MOLOAD    135
      KL=IL*12                                                          MOLOAD    136
      PMW=BLD(KL-9)                                                     MOLOAD    137
      QMX=BLD(KL-8)                                                     MOLOAD    138
      VMG=BLD(KL-7)*BLD(KL-7)                                           MOLOAD    139
C                                                                       MOLOAD    140
C     SHED THE SHUNT DEVICE (ASSUME THE SAME % AS THE LOAD)             MOLOAD    141
C                                                                       MOLOAD    142
      IF(ISHUNT.NE.0)THEN                                               MOLOAD    143
       GSHUNT=BLD(KL-1)*PSHED1/100.                                     MOLOAD    144
       BSHUNT=BLD(KL)*QSHED1/100.                                       MOLOAD    145
       STAIRS(NPROG)=STAIRS(NPROG)-CMPLX(GSHUNT,BSHUNT)                 MOLOAD    146
      ENDIF                                                             MOLOAD    147
C                                                                       MOLOAD    148
      BLD(KL-5)=BLD(KL-5)+PSHED1*PMW/100.                               MOLOAD    149
      BLD(KL-4)=BLD(KL-4)+QSHED1*QMX/100.                               MOLOAD    150
C                                                                       MOLOAD    151
C==  PICKUP ORIGINAL LOAD FROM LOAD TABLE, UPDATE THE TABLE             MOLOAD    152
C    AND THE NETWORK ACCORDING TO THE SPECIFIED % LOAD SHED             MOLOAD    153
C                                                                       MOLOAD    154
C                                                                       MOLOAD    155
C     FOR THE CONSTANT IMPEDANCE LOAD                                   MOLOAD    156
C                                                                       MOLOAD    157
      PSHED=PSHED1/100.                                                 MOLOAD    158
      QSHED=QSHED1/100.                                                 MOLOAD    159
      IPP=NBLD(KL-6)                                                    MOLOAD    160
      IQQ=NBLD(KL-10)                                                   MOLOAD    161
      IF(IPP.EQ.0.AND.IQQ.EQ.0)GOTO 300                                 MOLOAD    162
C                                                                       MOLOAD    163
      PDROP=IPP*PMW*PSHED/100.                                          MOLOAD    164
      QDROP=IQQ*QMX*QSHED/100.                                          MOLOAD    165
      IF(LDEB)WRITE(IUD6,2300)IPP,IQQ,PMW,QMX,PSHED,QSHED               MOLOAD    166
C                                                                       MOLOAD    167
C     STORE THE AMOUNT OF LOAD BEING SHED IN PU                         MOLOAD    168
C                                                                       MOLOAD    169
      BLD(KL-3)=BLD(KL-3)+PDROP                                         MOLOAD    170
      BLD(KL-2)=BLD(KL-2)+QDROP                                         MOLOAD    171
C                                                                       MOLOAD    172
C     UPDATE THE NETWORK                                                MOLOAD    173
C                                                                       MOLOAD    174
      GKK=PDROP/VMG                                                     MOLOAD    175
      BKK=-QDROP/VMG                                                    MOLOAD    176
C                                                                       MOLOAD    177
      STAIRS(NPROG)=STAIRS(NPROG)-CMPLX(GKK,BKK)                        MOLOAD    178
      IF(LDEB)WRITE(IUD6,2200)NPROG,BLD(KL-3),BLD(KL-2)                 MOLOAD    179
C                                                                       MOLOAD    180
 300  IF(NLOD.EQ.0)GOTO 1050                                            MOLOAD    181
C                                                                       MOLOAD    182
C  SEARCH FOR THE LOAD BUS                                              MOLOAD    183
C                                                                       MOLOAD    184
      ISHIFT=0                                                          MOLOAD    185
      DO 400 I=1,NLOD                                                   MOLOAD    186
       NCOMP=NLCOMP(1,I)                                                MOLOAD    187
       IF(NLDOLD(I).EQ.NPROG)GOTO 410                                   MOLOAD    188
       ISHIFT=ISHIFT+NCOMP                                              MOLOAD    189
 400  CONTINUE                                                          MOLOAD    190
C                                                                       MOLOAD    191
 410  NCOMP=NLCOMP(1,I)                                                 MOLOAD    192
      IF(NCOMP.EQ.0)GOTO 1000                                           MOLOAD    193
C                                                                       MOLOAD    194
      II=0                                                              MOLOAD    195
 420  II=II+1                                                           MOLOAD    196
      IF(II.GT.NCOMP)GOTO 1050                                          MOLOAD    197
      ISHIFT=ISHIFT+1                                                   MOLOAD    198
      NTYPE=NLTYPE(ISHIFT)                                              MOLOAD    199
      GOTO(430,440,450,460)NTYPE                                        MOLOAD    200
C                                                                       MOLOAD    201
 430  CONTINUE                                                          MOLOAD    202
C                                                                       MOLOAD    203
C     CONSTANT CURRENT LOAD                                             MOLOAD    204
C                                                                       MOLOAD    205
        PSHED=PSHED2/100.                                               MOLOAD    206
        QSHED=QSHED2/100.                                               MOLOAD    207
C                                                                       MOLOAD    208
        JNL=JDNLL(ISHIFT)                                               MOLOAD    209
C                                                                       MOLOAD    210
C   UPDATE THE INJECTED CURRENT DUE TO LOAD SHEDING                     MOLOAD    211
C                                                                       MOLOAD    212
         IPP=IDDAT(JNL+1)                                               MOLOAD    213
         IQQ=IDDAT(JNL+8)                                               MOLOAD    214
         PDROP=IPP*PMW*PSHED/100.                                       MOLOAD    215
         QDROP=IQQ*QMX*QSHED/100.                                       MOLOAD    216
C                                                                       MOLOAD    217
C       STORE THE AMOUNT BEING SHED                                     MOLOAD    218
C                                                                       MOLOAD    219
        DDAT(JNL+6)=DDAT(JNL+6)+PDROP                                   MOLOAD    220
        DDAT(JNL+7)=DDAT(JNL+7)+QDROP                                   MOLOAD    221
C                                                                       MOLOAD    222
         DDAT(JNL+2)=DDAT(JNL+2)-PDROP/SQRT(VMG)                        MOLOAD    223
         DDAT(JNL+3)=DDAT(JNL+3)-QDROP/SQRT(VMG)                        MOLOAD    224
C                                                                       MOLOAD    225
C    UPDATE THE CONSTANT IMPENDANCE PUT IN THE NETWORK                  MOLOAD    226
C                                                                       MOLOAD    227
         GKK=PDROP/VMG                                                  MOLOAD    228
         BKK=-QDROP/VMG                                                 MOLOAD    229
C                                                                       MOLOAD    230
         STAIRS(NPROG)=STAIRS(NPROG)-CMPLX(GKK,BKK)                     MOLOAD    231
         IF(LDEB)WRITE(IUD6,2200)NPROG,DDAT(JNL+6),DDAT(JNL+7)          MOLOAD    232
C                                                                       MOLOAD    233
         GOTO 420                                                       MOLOAD    234
C                                                                       MOLOAD    235
 440   CONTINUE                                                         MOLOAD    236
C                                                                       MOLOAD    237
C                                                                       MOLOAD    238
C    CONSTANT MVA AND PF LOAD REPRESENTATION                            MOLOAD    239
C                                                                       MOLOAD    240
C                                                                       MOLOAD    241
       PSHED=PSHED3/100.                                                MOLOAD    242
       QSHED=QSHED3/100.                                                MOLOAD    243
C                                                                       MOLOAD    244
       JNL=JDNLL(ISHIFT)                                                MOLOAD    245
         ITEK=IDDAT(JNL+1)                                              MOLOAD    246
         IPP=IDDAT(JNL+1)                                               MOLOAD    247
         IQQ=IDDAT(JNL+8)                                               MOLOAD    248
         PDROP=IPP*PMW*PSHED/100.                                       MOLOAD    249
         QDROP=IQQ*QMX*QSHED/100.                                       MOLOAD    250
C                                                                       MOLOAD    251
C     STORE THE AMOUNT OF LOAD HAVE BEEN SHED                           MOLOAD    252
C                                                                       MOLOAD    253
         DDAT(JNL+5)=DDAT(JNL+5)+PDROP                                  MOLOAD    254
         DDAT(JNL+6)=DDAT(JNL+6)+QDROP                                  MOLOAD    255
C                                                                       MOLOAD    256
C     UPDATE THE LOAD DUE THE LOAD SHEDING                              MOLOAD    257
C                                                                       MOLOAD    258
         DDAT(JNL+2)=DDAT(JNL+2)-PDROP                                  MOLOAD    259
         DDAT(JNL+3)=DDAT(JNL+3)-QDROP                                  MOLOAD    260
C                                                                       MOLOAD    261
C     UPDATE THE CONSTANT IMPEDANCE DUE TO THE CONST. MVA LOAD          MOLOAD    262
C                                                                       MOLOAD    263
         GKK=PDROP/VMG                                                  MOLOAD    264
         BKK=-QDROP/VMG                                                 MOLOAD    265
         STAIRS(NPROG)=STAIRS(NPROG)-CMPLX(GKK,BKK)                     MOLOAD    266
         IF(LDEB)WRITE(IUD6,2200)NPROG,PDROP,QDROP                      MOLOAD    267
C                                                                       MOLOAD    268
          GOTO 420                                                      MOLOAD    269
C                                                                       MOLOAD    270
 450  CONTINUE                                                          MOLOAD    271
C                                                                       MOLOAD    272
C    FOR VOLTAGE EXPONENTIAL LOAD                                       MOLOAD    273
C                                                                       MOLOAD    274
      IF(NLBS.NE.0)THEN                                                 MOLOAD    275
      PSHED=PSHED4/100.                                                 MOLOAD    276
      QSHED=QSHED4/100.                                                 MOLOAD    277
C                                                                       MOLOAD    278
      DO 310 I=1,NLBS                                                   MOLOAD    279
       IF(NPROG.EQ.NLDOLD(I))THEN                                       MOLOAD    280
C                                                                       MOLOAD    281
C--  RESTORE THE POINTER TO "DDAT"                                      MOLOAD    282
C                                                                       MOLOAD    283
      JNL=JDNLL(I)                                                      MOLOAD    284
      JJ=IDDAT(JNL+1)                                                   MOLOAD    285
      ITERMP=ITERML(JJ,1)                                               MOLOAD    286
      ITERMQ=ITERML(JJ,2)                                               MOLOAD    287
      JL=JNL+10                                                         MOLOAD    288
      VMG1=SQRT(VMG)                                                    MOLOAD    289
C                                                                       MOLOAD    290
       IF (ITERMP.NE.0) THEN                                            MOLOAD    291
         IPNL1=IDDAT(JL+1)                                              MOLOAD    292
         PDROP1=IPNL1*PMW*PSHED/100.                                    MOLOAD    293
         GDROP1=PDROP1/(VMG1**(DDAT(JL+2)+2))                           MOLOAD    294
         DDAT(JL+4)=DDAT(JL+4)-GDROP1                                   MOLOAD    295
C                                                                       MOLOAD    296
         JL=JL+4                                                        MOLOAD    297
       IF (ITERMP.EQ.2) THEN                                            MOLOAD    298
         IPNL2=IDDAT(JL+1)                                              MOLOAD    299
          PDROP2=IPNL2*PMW*PSHED/100.                                   MOLOAD    300
          GDROP2=PDROP2/(VMG1**(DDAT(JL+2)+2))                          MOLOAD    301
          DDAT(JL+4)=DDAT(JL+4)-GDROP2                                  MOLOAD    302
C                                                                       MOLOAD    303
         JL=JL+4                                                        MOLOAD    304
       ENDIF                                                            MOLOAD    305
       ENDIF                                                            MOLOAD    306
C                                                                       MOLOAD    307
       IF (ITERMQ.NE.0) THEN                                            MOLOAD    308
         IQNL1=IDDAT(JL+1)                                              MOLOAD    309
         QDROP1=QMX*IQNL1*QSHED/100.                                    MOLOAD    310
         BDROP1=QDROP1/(VMG1**(DDAT(JL+2)+2))                           MOLOAD    311
         DDAT(JL+4)=DDAT(JL+4)- BDROP1                                  MOLOAD    312
C                                                                       MOLOAD    313
         JL=JL+4                                                        MOLOAD    314
        IF (ITERMQ.EQ.2) THEN                                           MOLOAD    315
         IQNL2=IDDAT(JL+1)                                              MOLOAD    316
         QDROP2=QMX*IQNL2*QSHED/100.                                    MOLOAD    317
         BDROP2=QDROP2/(VMG1**(DDAT(JL+2)+2))                           MOLOAD    318
         DDAT(JL+4)=DDAT(JL+4)- BDROP2                                  MOLOAD    319
C                                                                       MOLOAD    320
          JL=JL+4                                                       MOLOAD    321
         ENDIF                                                          MOLOAD    322
        ENDIF                                                           MOLOAD    323
C                                                                       MOLOAD    324
C     UPDATE THE CONSTANT IMPEDANCE DUE TO VOLTAGE EXPONENTIAL LOAD     MOLOAD    325
C                                                                       MOLOAD    326
C                                                                       MOLOAD    327
C      STORE THE LOAD BEING SHED                                        MOLOAD    328
C                                                                       MOLOAD    329
       DDAT(JNL+9)=DDAT(JNL+9)+PDROP1+PDROP2                            MOLOAD    330
       DDAT(JNL+10)=DDAT(JNL+10)+QDROP1+QDROP2                          MOLOAD    331
C                                                                       MOLOAD    332
       IF(LDEB)WRITE(IUD6,2200)NPROG,DDAT(JNL+9),DDAT(JNL+10)           MOLOAD    333
       ENDIF                                                            MOLOAD    334
 310  CONTINUE                                                          MOLOAD    335
      ENDIF                                                             MOLOAD    336
C                                                                       MOLOAD    337
C   FOR A-LOAD                                                          MOLOAD    338
C                                                                       MOLOAD    339
  460 CONTINUE                                                          MOLOAD    340
C                                                                       MOLOAD    341
 1050 CONTINUE                                                          MOLOAD    342
C                                                                       MOLOAD    343
      GOTO 1000                                                         MOLOAD    344
C                                                                       MOLOAD    345
 510  CONTINUE                                                          MOLOAD    346
C                                                                       MOLOAD    347
C    FOR LOAD RESTORATION                                               MOLOAD    348
C                                                                       MOLOAD    349
      IF(IT.EQ.5)THEN                                                   MOLOAD    350
       KK=7                                                             MOLOAD    351
      ELSE                                                              MOLOAD    352
       KK=8                                                             MOLOAD    353
      ENDIF                                                             MOLOAD    354
C      WRITE(IU17,1500)ISOC(JTYP),NLF,INAME(II1),INAME(II2),INAME(II3), MOLOAD    355
C     & DESCPT(KK),PSHED1,QSHED1                                        MOLOAD    356
      WRITE(IU6,1500)ISOC(JTYP),NLF,INAME(II1),INAME(II2),INAME(II3),   MOLOAD    357
     & DESCPT(KK),PSHED1,QSHED1                                         MOLOAD    358
C                                                                       MOLOAD    359
      IL=JBLD(NPROG)                                                    MOLOAD    360
      KL=IL*12                                                          MOLOAD    361
      PMW=BLD(KL-9)                                                     MOLOAD    362
      QMX=BLD(KL-8)                                                     MOLOAD    363
      VMG=BLD(KL-7)*BLD(KL-7)                                           MOLOAD    364
C                                                                       MOLOAD    365
C     RESTORE THE SHUNT DEVICE (ASSUME THE SAME % AS THE LOAD)          MOLOAD    366
C                                                                       MOLOAD    367
      IF(ISHUNT.NE.0)THEN                                               MOLOAD    368
       GSHUNT=BLD(KL-1)*PSHED1/100.                                     MOLOAD    369
       BSHUNT=BLD(KL)*QSHED1/100.                                       MOLOAD    370
       STAIRS(NPROG)=STAIRS(NPROG)+CMPLX(GSHUNT,BSHUNT)                 MOLOAD    371
      ENDIF                                                             MOLOAD    372
C                                                                       MOLOAD    373
      BLD(KL-5)=BLD(KL-5)-PSHED1*PMW/100.                               MOLOAD    374
      BLD(KL-4)=BLD(KL-4)-QSHED1*QMX/100.                               MOLOAD    375
C                                                                       MOLOAD    376
C==  PICKUP ORIGINAL LOAD FROM LOAD TABLE, UPDATE THE TABLE             MOLOAD    377
C    AND THE NETWORK ACCORDING TO THE SPECIFIED % LOAD SHED             MOLOAD    378
C                                                                       MOLOAD    379
C                                                                       MOLOAD    380
C     FOR THE CONSTANT IMPEDANCE LOAD                                   MOLOAD    381
C                                                                       MOLOAD    382
      PSHED=PSHED1/100.                                                 MOLOAD    383
      QSHED=QSHED1/100.                                                 MOLOAD    384
      IPP=NBLD(KL-6)                                                    MOLOAD    385
      IQQ=NBLD(KL-10)                                                   MOLOAD    386
      IF(IPP.EQ.0.AND.IQQ.EQ.0)GOTO 520                                 MOLOAD    387
C                                                                       MOLOAD    388
      PDROP=IPP*PMW*PSHED/100.                                          MOLOAD    389
      QDROP=IQQ*QMX*QSHED/100.                                          MOLOAD    390
C                                                                       MOLOAD    391
C     RESTORE THE AMOUNT OF LOAD BEING SHED IN PU                       MOLOAD    392
C                                                                       MOLOAD    393
      BLD(KL-3)=BLD(KL-3)-PDROP                                         MOLOAD    394
      BLD(KL-2)=BLD(KL-2)-QDROP                                         MOLOAD    395
C                                                                       MOLOAD    396
C     UPDATE THE NETWORK                                                MOLOAD    397
C                                                                       MOLOAD    398
      GKK=PDROP/VMG                                                     MOLOAD    399
      BKK=-QDROP/VMG                                                    MOLOAD    400
C                                                                       MOLOAD    401
      STAIRS(NPROG)=STAIRS(NPROG)+CMPLX(GKK,BKK)                        MOLOAD    402
C                                                                       MOLOAD    403
 520  IF(NLOD.EQ.0)GOTO 2050                                            MOLOAD    404
C                                                                       MOLOAD    405
C  SEARCH FOR THE LOAD BUS                                              MOLOAD    406
C                                                                       MOLOAD    407
      ISHIFT=0                                                          MOLOAD    408
      DO 530 I=1,NLOD                                                   MOLOAD    409
       NCOMP=NLCOMP(1,I)                                                MOLOAD    410
       IF(NLDOLD(I).EQ.NPROG)GOTO 540                                   MOLOAD    411
       ISHIFT=ISHIFT+NCOMP                                              MOLOAD    412
 530  CONTINUE                                                          MOLOAD    413
C                                                                       MOLOAD    414
 540  NCOMP=NLCOMP(1,I)                                                 MOLOAD    415
      IF(NCOMP.EQ.0)GOTO 1000                                           MOLOAD    416
C                                                                       MOLOAD    417
      II=0                                                              MOLOAD    418
 550  II=II+1                                                           MOLOAD    419
      IF(II.GT.NCOMP)GOTO 1000                                          MOLOAD    420
      ISHIFT=ISHIFT+1                                                   MOLOAD    421
      NTYPE=NLTYPE(ISHIFT)                                              MOLOAD    422
      GOTO(560,565,570,575)NTYPE                                        MOLOAD    423
C                                                                       MOLOAD    424
 560  CONTINUE                                                          MOLOAD    425
C                                                                       MOLOAD    426
C     CONSTANT CURRENT LOAD                                             MOLOAD    427
C                                                                       MOLOAD    428
        PSHED=PSHED2/100.                                               MOLOAD    429
        QSHED=QSHED2/100.                                               MOLOAD    430
C                                                                       MOLOAD    431
        JNL=JDNLL(ISHIFT)                                               MOLOAD    432
C                                                                       MOLOAD    433
C   UPDATE THE INJECTED CURRENT DUE TO LOAD RESTORATION                 MOLOAD    434
C                                                                       MOLOAD    435
         IPP=IDDAT(JNL+1)                                               MOLOAD    436
         IQQ=IDDAT(JNL+8)                                               MOLOAD    437
         PDROP=IPP*PMW*PSHED/100.                                       MOLOAD    438
         QDROP=IQQ*QMX*QSHED/100.                                       MOLOAD    439
C                                                                       MOLOAD    440
C       UPDATE THE  AMOUNT THE LOAD SHED                                MOLOAD    441
C                                                                       MOLOAD    442
        DDAT(JNL+6)=DDAT(JNL+6)-PDROP                                   MOLOAD    443
        DDAT(JNL+7)=DDAT(JNL+7)-QDROP                                   MOLOAD    444
C                                                                       MOLOAD    445
         DDAT(JNL+2)=DDAT(JNL+2)+PDROP/SQRT(VMG)                        MOLOAD    446
         DDAT(JNL+3)=DDAT(JNL+3)+QDROP/SQRT(VMG)                        MOLOAD    447
C                                                                       MOLOAD    448
C    UPDATE THE CONSTANT IMPENDANCE PUT IN THE NETWORK                  MOLOAD    449
C                                                                       MOLOAD    450
         GKK=PDROP/VMG                                                  MOLOAD    451
         BKK=-QDROP/VMG                                                 MOLOAD    452
C                                                                       MOLOAD    453
         STAIRS(NPROG)=STAIRS(NPROG)+CMPLX(GKK,BKK)                     MOLOAD    454
         IF(LDEB)WRITE(IUD6,2200)NPROG,DDAT(JNL+6),DDAT(JNL+7)          MOLOAD    455
C                                                                       MOLOAD    456
         GOTO 550                                                       MOLOAD    457
C                                                                       MOLOAD    458
 565   CONTINUE                                                         MOLOAD    459
C                                                                       MOLOAD    460
C                                                                       MOLOAD    461
C    CONSTANT MVA AND PF LOAD REPRESENTATION                            MOLOAD    462
C                                                                       MOLOAD    463
C                                                                       MOLOAD    464
       PSHED=PSHED3/100.                                                MOLOAD    465
       QSHED=QSHED3/100.                                                MOLOAD    466
C                                                                       MOLOAD    467
       JNL=JDNLL(ISHIFT)                                                MOLOAD    468
         ITEK=IDDAT(JNL+1)                                              MOLOAD    469
         IPP=IDDAT(JNL+1)                                               MOLOAD    470
         IQQ=IDDAT(JNL+7)                                               MOLOAD    471
         PDROP=IPP*PMW*PSHED/100.                                       MOLOAD    472
         QDROP=IQQ*QMX*QSHED/100.                                       MOLOAD    473
C                                                                       MOLOAD    474
C     UPDATE THE LOAD                                                   MOLOAD    475
C                                                                       MOLOAD    476
         DDAT(JNL+5)=DDAT(JNL+5)-PDROP                                  MOLOAD    477
         DDAT(JNL+6)=DDAT(JNL+6)-QDROP                                  MOLOAD    478
C                                                                       MOLOAD    479
C     UPDATE THE LOAD DUE THE LOAD SHEDING                              MOLOAD    480
C                                                                       MOLOAD    481
         DDAT(JNL+2)=DDAT(JNL+2)+PDROP                                  MOLOAD    482
         DDAT(JNL+3)=DDAT(JNL+3)+QDROP                                  MOLOAD    483
C                                                                       MOLOAD    484
C     UPDATE THE CONSTANT IMPEDANCE DUE TO THE CONST. MVA LOAD          MOLOAD    485
C                                                                       MOLOAD    486
         GKK=PDROP/VMG                                                  MOLOAD    487
         BKK=-QDROP/VMG                                                 MOLOAD    488
         STAIRS(NPROG)=STAIRS(NPROG)+CMPLX(GKK,BKK)                     MOLOAD    489
         IF(LDEB)WRITE(IUD6,2200)NPROG,PDROP,QDROP                      MOLOAD    490
C                                                                       MOLOAD    491
          GOTO 550                                                      MOLOAD    492
C                                                                       MOLOAD    493
 570  CONTINUE                                                          MOLOAD    494
C                                                                       MOLOAD    495
C    FOR VOLTAGE EXPONENTIAL LOAD                                       MOLOAD    496
C                                                                       MOLOAD    497
      IF(NLBS.NE.0)THEN                                                 MOLOAD    498
      PSHED=PSHED4/100.                                                 MOLOAD    499
      QSHED=QSHED4/100.                                                 MOLOAD    500
C                                                                       MOLOAD    501
      DO 580 I=1,NLBS                                                   MOLOAD    502
       IF(NPROG.EQ.NLDOLD(I))THEN                                       MOLOAD    503
C                                                                       MOLOAD    504
C--  RESTORE THE POINTER TO "DDAT"                                      MOLOAD    505
C                                                                       MOLOAD    506
      JNL=JDNLL(I)                                                      MOLOAD    507
      JJ=IDDAT(JNL+1)                                                   MOLOAD    508
      ITERMP=ITERML(JJ,1)                                               MOLOAD    509
      ITERMQ=ITERML(JJ,2)                                               MOLOAD    510
      JL=JNL+10                                                         MOLOAD    511
C                                                                       MOLOAD    512
       IF (ITERMP.NE.0) THEN                                            MOLOAD    513
         IPNL1=IDDAT(JL+1)                                              MOLOAD    514
         PDROP1=IPNL1*PMW*PSHED/100.                                    MOLOAD    515
C                                                                       MOLOAD    516
         JL=JL+4                                                        MOLOAD    517
       IF (ITERMP.EQ.2) THEN                                            MOLOAD    518
         IPNL2=IDDAT(JL+1)                                              MOLOAD    519
          PDROP2=IPNL2*PMW*PSHED/100.                                   MOLOAD    520
C                                                                       MOLOAD    521
         JL=JL+4                                                        MOLOAD    522
       ENDIF                                                            MOLOAD    523
       ENDIF                                                            MOLOAD    524
C                                                                       MOLOAD    525
       IF (ITERMQ.NE.0) THEN                                            MOLOAD    526
         IQNL1=IDDAT(JL+1)                                              MOLOAD    527
         QDROP1=QMX*IQNL1*QSHED/100.                                    MOLOAD    528
C                                                                       MOLOAD    529
         JL=JL+4                                                        MOLOAD    530
        IF (ITERMQ.EQ.2) THEN                                           MOLOAD    531
         IQNL2=IDDAT(JL+1)                                              MOLOAD    532
         QDROP2=QMX*IQNL2*QSHED/100.                                    MOLOAD    533
C                                                                       MOLOAD    534
          JL=JL+4                                                       MOLOAD    535
         ENDIF                                                          MOLOAD    536
        ENDIF                                                           MOLOAD    537
C                                                                       MOLOAD    538
C     UPDATE THE CONSTANT IMPEDANCE DUE TO VOLTAGE EXPONENTIAL LOAD     MOLOAD    539
C                                                                       MOLOAD    540
C                                                                       MOLOAD    541
C      UPDATE THE LOAD BEING SHED                                       MOLOAD    542
C                                                                       MOLOAD    543
       DDAT(JNL+9)=DDAT(JNL+9)-PDROP1-PDROP2                            MOLOAD    544
       DDAT(JNL+10)=DDAT(JNL+10)-QDROP1-QDROP2                          MOLOAD    545
C                                                                       MOLOAD    546
       GKK=(PDROP1+PDROP2)/VMG                                          MOLOAD    547
       BKK=-(QDROP1+QDROP2)/VMG                                         MOLOAD    548
       STAIRS(NPROG)=STAIRS(NPROG)+CMPLX(GKK,BKK)                       MOLOAD    549
       IF(LDEB)WRITE(IUD6,2200)NPROG,DDAT(JNL+9),DDAT(JNL+10)           MOLOAD    550
       ENDIF                                                            MOLOAD    551
 580  CONTINUE                                                          MOLOAD    552
      ENDIF                                                             MOLOAD    553
C                                                                       MOLOAD    554
C   FOR A-LOAD                                                          MOLOAD    555
C                                                                       MOLOAD    556
  575 CONTINUE                                                          MOLOAD    557
C                                                                       MOLOAD    558
 2050 CONTINUE                                                          MOLOAD    559
C                                                                       MOLOAD    560
      GOTO 1000                                                         MOLOAD    561
C                                                                       MOLOAD    562
 620  CONTINUE                                                          MOLOAD    563
C                                                                       MOLOAD    564
      VTHZH=PSHED1                                                      MOLOAD    565
      VTHZL=QSHED1                                                      MOLOAD    566
C      WRITE(IU17,1620) ITYP,VTHZH,VTHZL                                MOLOAD    567
      WRITE(IU6,1620) ITYP,VTHZH,VTHZL                                  MOLOAD    568
C                                                                       MOLOAD    569
 1000 CONTINUE                                                          MOLOAD    570
C                                                                       MOLOAD    571
      RETURN                                                            MOLOAD    572
C                                                                       MOLOAD    573
 1440 FORMAT (///10X,'SWITCHING ACTIVITIES OF LOADS :-',/,10X,32('-'),  MOLOAD    574
     &/,10X,'TYPE   BUS#   BUS NAME',T43,'DESCRIPTION',T78,'CHANGES'/)  MOLOAD    575
 1500 FORMAT(10X,A3,2X,I6,3X,3A4,6X,A28,6X,'P = ',F6.2,' %','  Q = ',   MOLOAD    576
     &F6.2,' %')                                                        MOLOAD    577
 1550 FORMAT(10X,A3,2X,I6,3X,3A4,6X,A28,3X,'P1= ',F6.2,'%',' Q1= ',     MOLOAD    578
     &F6.2,'%',' P2= ',F6.2,'%',' Q2= ',F6.2,'%',/,73X,'P3= ',F6.2,     MOLOAD    579
     &'%',' Q3= ',F6.2,'%',' P4= ',F6.2,'%',' Q4= ',F6.2)               MOLOAD    580
 1560 FORMAT(10X,'* * * THE ABOVE BUS HAS NO LOAD, NO LOAD',            MOLOAD    581
     &' SHEDDING TOOK PLACE * * *')                                     MOLOAD    582
 1620 FORMAT (T11,A2,T43,'THRESHOLD VOLTAGE CHANGE',T78,'VTHL= ',F10.5,'MOLOAD    583
     1  VTHH= ',F10.5)                                                  MOLOAD    584
 2000  FORMAT(A3,A1,2I5,8F10.5)                                         MOLOAD    585
 2100 FORMAT(' *** ERROR TYPE=',A3,' IS NOT AMONG THE ACTIVIITY LIST')  MOLOAD    586
 2150 FORMAT(' *** ERROR TRIPPING SIGNAL TYPE =',A4                     MOLOAD    587
     *,' IS NOT IN THE LIST')                                           MOLOAD    588
 2200 FORMAT(' LOAD DROP AT BUS # ',I6, ' P =',F12.4,' Q =',F12.4)      MOLOAD    589
 2300 FORMAT(' IPP, IQQ, PMW, QMX, PSHED, QSHED ',2I5,4F12.4)           MOLOAD    590
C                                                                       MOLOAD    591
      END                                                               MOLOAD    592
