CFPRIME GCVOLT                                                          GCVOLT      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  GCVOLT (JPOSN, TYPE)                                  GCVOLT      3
CD -------------------------------------------------------------------  GCVOLT      4
CD                                                                      GCVOLT      5
CD              *****     GCVOLT  ROUTINE   *****                       GCVOLT      6
CD                                                                      GCVOLT      7
CD -------------------------------------------------------------------  GCVOLT      8
CD                                                                      GCVOLT      9
CD       PURPOSE:  Adds voltage controlled converter to network.        GCVOLT     10
CD                                                                      GCVOLT     11
CD                                                                      GCVOLT     12
CD       DEFINITION OF LOCAL VARIABLES:                                 GCVOLT     13
CD                 COL    -  matrix column number.                      GCVOLT     14
CD                 I      -  first converter bus.                       GCVOLT     15
CD                 II     -  pointer from first bus to column in        GCVOLT     16
CD                           matrix.                                    GCVOLT     17
CD                 ISA    -  temporary storage for swapping.            GCVOLT     18
CD                 J      -  second converter bus.                      GCVOLT     19
CD                 JJ     -  pointer from second bus to column in       GCVOLT     20
CD                           matrix.                                    GCVOLT     21
CD                 OLD    -  column that is removed from matrix.        GCVOLT     22
CD          (P)    POSN   -  storage position for dc information.       GCVOLT     23
CD                 ROW    -  matrix row number.                         GCVOLT     24
CD          (P)    TYPE   -  type of control for converter.             GCVOLT     25
CD                                                                      GCVOLT     26
CD -------------------------------------------------------------------  GCVOLT     27
C                                                                       GCVOLT     28
      INCLUDE 'PARX.INS'                                                GCVOLT     29
      INCLUDE 'CNPARX.INS'                                              GCVOLT     30
      INCLUDE 'CNUNIT.INS'                                              GCVOLT     31
      INCLUDE 'CNMSG.INS'                                               GCVOLT     32
      INCLUDE 'GRDC01.INS'                                              GCVOLT     33
      INCLUDE 'GRDC02.INS'                                              GCVOLT     34
      INCLUDE 'GRDC03.INS'                                              GCVOLT     35
      INCLUDE 'UDCA.INS'                                                GCVOLT     36
      INCLUDE 'UDCF.INS'                                                GCVOLT     37
      INCLUDE 'UDCJ.INS'                                                GCVOLT     38
C                                                                       GCVOLT     39
      COMMON /CONVST/ ICOMF(NDCC),ICEXT(NDCC)                           GCVOLT     40
      LOGICAL       NOCHG                                               GCVOLT     41
C                                                                       GCVOLT     42
      DOUBLE PRECISION TIMX, VALUE                                      GCVOLT     43
C                                                                       GCVOLT     44
      DIMENSION OLD(NDCC), CHANGE(NDCC)                                 GCVOLT     45
C                                                                       GCVOLT     46
      CHARACTER*20  SUBNAM                                              GCVOLT     47
      CHARACTER*8   TYPE                                                GCVOLT     48
C                                                                       GCVOLT     49
      I = ICONRE(JPOSN,1)                                               GCVOLT     50
      J = ICONRE(JPOSN,2)                                               GCVOLT     51
C                                                                       GCVOLT     52
      CONTYP(JPOSN) = TYPE                                              GCVOLT     53
C                                                                       GCVOLT     54
      GOTO 10                                                           GCVOLT     55
C                                                                       GCVOLT     56
      ENTRY GBVOLT (JPOSN)                                              GCVOLT     57
CD -------------------------------------------------------------------  GCVOLT     58
CD                                                                      GCVOLT     59
CD              *****     GBVOLT  ROUTINE   *****                       GCVOLT     60
CD                                                                      GCVOLT     61
CD -------------------------------------------------------------------  GCVOLT     62
CD                                                                      GCVOLT     63
CD       PURPOSE:  Adds voltage controlled breakers to network.         GCVOLT     64
CD                                                                      GCVOLT     65
CD -------------------------------------------------------------------  GCVOLT     66
C                                                                       GCVOLT     67
      I = IBRKRE(JPOSN,1)                                               GCVOLT     68
      J = IBRKRE(JPOSN,2)                                               GCVOLT     69
C                                                                       GCVOLT     70
  10  IF(I .NE. 0) II = NXFIND(I)                                       GCVOLT     71
      IF(J .NE. 0) JJ = NXFIND(J)                                       GCVOLT     72
C                                                                       GCVOLT     73
      IF(J.EQ.0)THEN                                                    GCVOLT     74
C                                                                       GCVOLT     75
         DO 20 JROW = 1, ISIZEG                                         GCVOLT     76
            OLD(JROW) = GMATRX(JROW,II)                                 GCVOLT     77
20       CONTINUE                                                       GCVOLT     78
C                                                                       GCVOLT     79
      ELSE                                                              GCVOLT     80
C                                                                       GCVOLT     81
         DO 40 JROW = 1, ISIZEG                                         GCVOLT     82
            OLD(JROW) = GMATRX(JROW,JJ)                                 GCVOLT     83
40       CONTINUE                                                       GCVOLT     84
      END IF                                                            GCVOLT     85
C                                                                       GCVOLT     86
      IF(I .NE. 0.AND.J .NE. 0)THEN                                     GCVOLT     87
C                                                                       GCVOLT     88
         DO 60 JROW = 1, ISIZEG                                         GCVOLT     89
            GMATRX(JROW,II) = GMATRX(JROW,II) + GMATRX(JROW,JJ)         GCVOLT     90
60       CONTINUE                                                       GCVOLT     91
C                                                                       GCVOLT     92
         DO 80 JCOL = 1, ISIZEG                                         GCVOLT     93
            GMATRX(II,JCOL) = GMATRX(II,JCOL) + GMATRX(JJ,JCOL)         GCVOLT     94
80       CONTINUE                                                       GCVOLT     95
C                                                                       GCVOLT     96
      END IF                                                            GCVOLT     97
C                                                                       GCVOLT     98
      IF(J.EQ.0)THEN                                                    GCVOLT     99
C                                                                       GCVOLT    100
         ISA = NDFIND(II)                                               GCVOLT    101
         DO 120 JCOL = II+1, ISIZEG                                     GCVOLT    102
            DO 100 JROW = 1, ISIZEG                                     GCVOLT    103
               GMATRX(JROW,JCOL-1) = GMATRX(JROW,JCOL)                  GCVOLT    104
100         CONTINUE                                                    GCVOLT    105
            NDFIND(JCOL-1) = NDFIND(JCOL)                               GCVOLT    106
120      CONTINUE                                                       GCVOLT    107
         NDFIND(ISIZEG) = ISA                                           GCVOLT    108
C                                                                       GCVOLT    109
      ELSE                                                              GCVOLT    110
C                                                                       GCVOLT    111
         ISA = NDFIND(JJ)                                               GCVOLT    112
         DO 160 JCOL = JJ+1, ISIZEG                                     GCVOLT    113
            DO 140 JROW = 1, ISIZEG                                     GCVOLT    114
               GMATRX(JROW,JCOL-1) = GMATRX(JROW,JCOL)                  GCVOLT    115
140         CONTINUE                                                    GCVOLT    116
            NDFIND(JCOL-1) = NDFIND(JCOL)                               GCVOLT    117
160      CONTINUE                                                       GCVOLT    118
         NDFIND(ISIZEG) = ISA                                           GCVOLT    119
C                                                                       GCVOLT    120
      END IF                                                            GCVOLT    121
C                                                                       GCVOLT    122
      DO 180 JROW = 1, ISIZEG                                           GCVOLT    123
         GMATRX(JROW,ISIZEG) = OLD(JROW)                                GCVOLT    124
180   CONTINUE                                                          GCVOLT    125
C                                                                       GCVOLT    126
      DO 200 JROW = 1, NUMNOD                                           GCVOLT    127
         NXFIND(NDFIND(JROW)) = JROW                                    GCVOLT    128
         NCFIND(NDFIND(JROW)) = JROW                                    GCVOLT    129
200   CONTINUE                                                          GCVOLT    130
C                                                                       GCVOLT    131
      ISIZEG = ISIZEG - 1                                               GCVOLT    132
C                                                                       GCVOLT    133
      IF(J.EQ.0)THEN                                                    GCVOLT    134
C                                                                       GCVOLT    135
         DO 240 JROW = II+1, ISIZEG+1                                   GCVOLT    136
            DO 220 JCOL = 1, ISIZEG                                     GCVOLT    137
               GMATRX(JROW-1,JCOL) = GMATRX(JROW,JCOL)                  GCVOLT    138
220         CONTINUE                                                    GCVOLT    139
240      CONTINUE                                                       GCVOLT    140
C                                                                       GCVOLT    141
      ELSE                                                              GCVOLT    142
C                                                                       GCVOLT    143
         DO 280 JROW = JJ+1, ISIZEG+1                                   GCVOLT    144
            DO 260 JCOL = 1, ISIZEG                                     GCVOLT    145
               GMATRX(JROW-1,JCOL) = GMATRX(JROW,JCOL)                  GCVOLT    146
260         CONTINUE                                                    GCVOLT    147
280      CONTINUE                                                       GCVOLT    148
      END IF                                                            GCVOLT    149
C                                                                       GCVOLT    150
      RETURN                                                            GCVOLT    151
C                                                                       GCVOLT    152
      ENTRY VCALPA (JPOSN, SETPT)                                       GCVOLT    153
CD -------------------------------------------------------------------  GCVOLT    154
CD                                                                      GCVOLT    155
CD              *****     VCALPA  ROUTINE   *****                       GCVOLT    156
CD                                                                      GCVOLT    157
CD -------------------------------------------------------------------  GCVOLT    158
CD                                                                      GCVOLT    159
CD       PURPOSE:  Updates injection vector for alpha controlled        GCVOLT    160
CD                 converter.                                           GCVOLT    161
CD                                                                      GCVOLT    162
CD -------------------------------------------------------------------  GCVOLT    163
C                                                                       GCVOLT    164
      GO TO 290                                                         GCVOLT    165
C                                                                       GCVOLT    166
      ENTRY VCGAMA (JPOSN, SETPT)                                       GCVOLT    167
CD -------------------------------------------------------------------  GCVOLT    168
CD                                                                      GCVOLT    169
CD              *****     VCGAMA  ROUTINE   *****                       GCVOLT    170
CD                                                                      GCVOLT    171
CD -------------------------------------------------------------------  GCVOLT    172
CD                                                                      GCVOLT    173
CD       PURPOSE:  Updates injection vector for gamma controlled        GCVOLT    174
CD                 converter.                                           GCVOLT    175
CD                                                                      GCVOLT    176
CD -------------------------------------------------------------------  GCVOLT    177
C                                                                       GCVOLT    178
290   IF(QINV(JPOSN))THEN                                               GCVOLT    179
         SIGMA = -1.0                                                   GCVOLT    180
      ELSE                                                              GCVOLT    181
         SIGMA = 1.0                                                    GCVOLT    182
      END IF                                                            GCVOLT    183
C                                                                       GCVOLT    184
      IF(SETPT .LT. 0.0) SETPT = 0.0                                    GCVOLT    185
      IF(SETPT .GT. PII) SETPT = PII                                    GCVOLT    186
      VALUE = (SIGMA * PII * TAPPOS(JPOSN) * VAHVDC(JPOSN)) /           GCVOLT    187
     1         (3.0 * XCCONV(JPOSN)) * COS(SETPT)                       GCVOLT    188
C                                                                       GCVOLT    189
      GOTO 300                                                          GCVOLT    190
C                                                                       GCVOLT    191
      ENTRY VCALGA (JPOSN, SETP1,SETP2)                                 GCVOLT    192
CD -------------------------------------------------------------------  GCVOLT    193
CD                                                                      GCVOLT    194
CD              *****     VCALGA  ROUTINE   *****                       GCVOLT    195
CD                                                                      GCVOLT    196
CD -------------------------------------------------------------------  GCVOLT    197
CD                                                                      GCVOLT    198
CD       PURPOSE:  Updates injection vector for alpha-gamma controlled  GCVOLT    199
CD                 self commutated voltage sourced converter.           GCVOLT    200
CD                                                                      GCVOLT    201
CD -------------------------------------------------------------------  GCVOLT    202
C                                                                       GCVOLT    203
      IF(SETP1 .LT. -1.5707964) SETP1 = -1.5707964                      GCVOLT    204
      IF(SETP1 .GT.  1.5707964) SETP1 =  1.5707964                      GCVOLT    205
      IF(SETP2 .LT. -1.0)       SETP2 = -1.0                            GCVOLT    206
      IF(SETP2 .GT.  1.0)       SETP2 =  1.0                            GCVOLT    207
C                                                                       GCVOLT    208
      ANG = SETP1 + VACONV(JPOSN)                                       GCVOLT    209
      VALUE = - VAHVDC(JPOSN) * SETP2 * SIN(ANG)                        GCVOLT    210
     1        / XCCONV(JPOSN) / TAPPOS(JPOSN)                           GCVOLT    211
C                                                                       GCVOLT    212
      GOTO 300                                                          GCVOLT    213
C                                                                       GCVOLT    214
      ENTRY VBCURR (JPOSN, SETPT)                                       GCVOLT    215
CD -------------------------------------------------------------------  GCVOLT    216
CD                                                                      GCVOLT    217
CD              *****     VBCURR  ROUTINE   *****                       GCVOLT    218
CD                                                                      GCVOLT    219
CD -------------------------------------------------------------------  GCVOLT    220
CD                                                                      GCVOLT    221
CD       PURPOSE:  Updates current injection vector for current         GCVOLT    222
CD                 controlled breakers.                                 GCVOLT    223
CD                                                                      GCVOLT    224
CD -------------------------------------------------------------------  GCVOLT    225
C                                                                       GCVOLT    226
      VALUE = SETPT                                                     GCVOLT    227
C                                                                       GCVOLT    228
      I = IBRKRE(JPOSN,1)                                               GCVOLT    229
      J = IBRKRE(JPOSN,2)                                               GCVOLT    230
C                                                                       GCVOLT    231
      GOTO 320                                                          GCVOLT    232
C                                                                       GCVOLT    233
      ENTRY VCCURR (JPOSN, SETPT)                                       GCVOLT    234
CD -------------------------------------------------------------------  GCVOLT    235
CD                                                                      GCVOLT    236
CD              *****     VCCURR  ROUTINE   *****                       GCVOLT    237
CD                                                                      GCVOLT    238
CD -------------------------------------------------------------------  GCVOLT    239
CD                                                                      GCVOLT    240
CD       PURPOSE:  Updates injection vector for current controlled      GCVOLT    241
CD                 converter.                                           GCVOLT    242
CD                                                                      GCVOLT    243
CD -------------------------------------------------------------------  GCVOLT    244
C                                                                       GCVOLT    245
      VALUE = SETPT/1000.0                                              GCVOLT    246
C                                                                       GCVOLT    247
  300 I = ICONRE(JPOSN,1)                                               GCVOLT    248
      J = ICONRE(JPOSN,2)                                               GCVOLT    249
C                                                                       GCVOLT    250
  320 IF (I .NE. 0) XINJVE(I)=XINJVE(I)+VALUE                           GCVOLT    251
      IF (J .NE. 0) XINJVE(J)=XINJVE(J)-VALUE                           GCVOLT    252
C                                                                       GCVOLT    253
      RETURN                                                            GCVOLT    254
C                                                                       GCVOLT    255
      ENTRY VCVOLT (JPOSN, SETPT)                                       GCVOLT    256
CD -------------------------------------------------------------------  GCVOLT    257
CD                                                                      GCVOLT    258
CD              *****     VCVOLT  ROUTINE   *****                       GCVOLT    259
CD                                                                      GCVOLT    260
CD -------------------------------------------------------------------  GCVOLT    261
CD                                                                      GCVOLT    262
CD       PURPOSE:  Updates injection vector for voltage controlled      GCVOLT    263
CD                 converter.                                           GCVOLT    264
CD                                                                      GCVOLT    265
CD -------------------------------------------------------------------  GCVOLT    266
C                                                                       GCVOLT    267
      I = ICONRE(JPOSN,1)                                               GCVOLT    268
      J = ICONRE(JPOSN,2)                                               GCVOLT    269
C                                                                       GCVOLT    270
      GOTO 400                                                          GCVOLT    271
C                                                                       GCVOLT    272
      ENTRY VBVOLT (JPOSN, SETPT)                                       GCVOLT    273
CD -------------------------------------------------------------------  GCVOLT    274
CD                                                                      GCVOLT    275
CD              *****     VBVOLT  ROUTINE   *****                       GCVOLT    276
CD                                                                      GCVOLT    277
CD -------------------------------------------------------------------  GCVOLT    278
CD                                                                      GCVOLT    279
CD       PURPOSE:  Updates current injection vector for voltage         GCVOLT    280
CD                 controlled breakers.                                 GCVOLT    281
CD                                                                      GCVOLT    282
CD -------------------------------------------------------------------  GCVOLT    283
C                                                                       GCVOLT    284
      I = IBRKRE(JPOSN,1)                                               GCVOLT    285
      J = IBRKRE(JPOSN,2)                                               GCVOLT    286
  400 IF (I .NE. 0) II = NXFIND(I)                                      GCVOLT    287
      IF (J .NE. 0) JJ = NXFIND(J)                                      GCVOLT    288
C                                                                       GCVOLT    289
C     Determine where the column that is to be removed for this         GCVOLT    290
C     breaker is in the modified G matrix.                              GCVOLT    291
C                                                                       GCVOLT    292
      IF (J .EQ. 0) THEN                                                GCVOLT    293
         JCOL = NCFIND(I)                                               GCVOLT    294
      ELSE                                                              GCVOLT    295
         JCOL = NCFIND(J)                                               GCVOLT    296
      END IF                                                            GCVOLT    297
C                                                                       GCVOLT    298
C                                                                       GCVOLT    299
C     Calculate change to the injection vector.                         GCVOLT    300
C                                                                       GCVOLT    301
      DO 520 JROW = 1, ISIZEV                                           GCVOLT    302
         CHANGE(JROW) = - GMATRX(JROW,JCOL) * SETPT                     GCVOLT    303
520   CONTINUE                                                          GCVOLT    304
C                                                                       GCVOLT    305
C                                                                       GCVOLT    306
C     Add the change in the injection vector to the injection vector.   GCVOLT    307
C                                                                       GCVOLT    308
      DO 540 JROW = 1, ISIZEV                                           GCVOLT    309
         XINJVE(JROW) = XINJVE(JROW) + CHANGE(JROW)                     GCVOLT    310
540   CONTINUE                                                          GCVOLT    311
C                                                                       GCVOLT    312
C                                                                       GCVOLT    313
C     Neither end is ground so add the injection at j to injection      GCVOLT    314
C     at i.                                                             GCVOLT    315
C                                                                       GCVOLT    316
      IF (I .NE. 0 .AND. J .NE. 0) THEN                                 GCVOLT    317
         XINJVE(II) = XINJVE(II) + XINJVE(JJ)                           GCVOLT    318
      ENDIF                                                             GCVOLT    319
C                                                                       GCVOLT    320
C                                                                       GCVOLT    321
C     Determine the element in the vector to be moved.                  GCVOLT    322
C                                                                       GCVOLT    323
      IF (J .EQ. 0) THEN                                                GCVOLT    324
         MOVE = NXFIND(I)                                               GCVOLT    325
      ELSE                                                              GCVOLT    326
         MOVE = NXFIND(J)                                               GCVOLT    327
      END IF                                                            GCVOLT    328
C                                                                       GCVOLT    329
C                                                                       GCVOLT    330
C     Save the element to be moved.                                     GCVOLT    331
C                                                                       GCVOLT    332
      OLD1 = XINJVE(MOVE)                                               GCVOLT    333
      ISA = NDFIND(MOVE)                                                GCVOLT    334
C                                                                       GCVOLT    335
C                                                                       GCVOLT    336
C     Re-order vector so that moved element is at the end.              GCVOLT    337
C     Update pointer lists                                              GCVOLT    338
C                                                                       GCVOLT    339
      DO 560 JROW = MOVE+1, ISIZEV                                      GCVOLT    340
         XINJVE(JROW-1) = XINJVE(JROW)                                  GCVOLT    341
         NDFIND(JROW-1) = NDFIND(JROW)                                  GCVOLT    342
560   CONTINUE                                                          GCVOLT    343
      XINJVE(ISIZEV) = OLD1                                             GCVOLT    344
      NDFIND(ISIZEV) = ISA                                              GCVOLT    345
C                                                                       GCVOLT    346
C     Create inverse reference vector                                   GCVOLT    347
C                                                                       GCVOLT    348
      DO 580 ICL = 1, NUMNOD                                            GCVOLT    349
         NXFIND(NDFIND(ICL)) = ICL                                      GCVOLT    350
580   CONTINUE                                                          GCVOLT    351
C                                                                       GCVOLT    352
C     Reduce the size of the vector by one.                             GCVOLT    353
C                                                                       GCVOLT    354
      ISIZEV = ISIZEV - 1                                               GCVOLT    355
C                                                                       GCVOLT    356
      RETURN                                                            GCVOLT    357
C                                                                       GCVOLT    358
      ENTRY SCALPA (JPOSN, SETPT,TIMX)                                  GCVOLT    359
CD -------------------------------------------------------------------  GCVOLT    360
CD                                                                      GCVOLT    361
CD              *****     SCALPA  ROUTINE   *****                       GCVOLT    362
CD                                                                      GCVOLT    363
CD -------------------------------------------------------------------  GCVOLT    364
CD                                                                      GCVOLT    365
CD       PURPOSE:  Solve for current and cos(gamma) for alpha           GCVOLT    366
CD                 controlled converter.                                GCVOLT    367
CD                                                                      GCVOLT    368
CD -------------------------------------------------------------------  GCVOLT    369
C                                                                       GCVOLT    370
      IF(SDBG)THEN                                                      GCVOLT    371
         SUBNAM = 'SCALPA ROUTINE.'                                     GCVOLT    372
      ELSE                                                              GCVOLT    373
         SUBNAM = ' '                                                   GCVOLT    374
      END IF                                                            GCVOLT    375
C                                                                       GCVOLT    376
C     Set controlled alpha value.                                       GCVOLT    377
C                                                                       GCVOLT    378
      CALPHA(JPOSN) = COS(SETPT)                                        GCVOLT    379
C                                                                       GCVOLT    380
C     Check for infeasible firing angle                                 GCVOLT    381
C                                                                       GCVOLT    382
      IF(SETPT .LT. 0.0)THEN                                            GCVOLT    383
         USETPT(JPOSN) = 0.0                                            GCVOLT    384
         SETPT = 0.0                                                    GCVOLT    385
         CALPHA(JPOSN) = 1.0                                            GCVOLT    386
         DCCHNG = .TRUE.                                                GCVOLT    387
         WRITE (MSG(1),9000) TIMX,SUBNAM                                GCVOLT    388
         WRITE (MSG(2),9100) DCCNAM(JPOSN)                              GCVOLT    389
         WRITE (MSG(3),9110)                                            GCVOLT    390
         CALL PRTMSG(3)                                                 GCVOLT    391
      END IF                                                            GCVOLT    392
C                                                                       GCVOLT    393
C                                                                       GCVOLT    394
      IF(SETPT .GT. PII)THEN                                            GCVOLT    395
         COMFAL = .TRUE.                                                GCVOLT    396
         UMODE(JPOSN) = 'COMFAIL'                                       GCVOLT    397
         USETPT(JPOSN) = 0.0                                            GCVOLT    398
         SETPT = 0.0                                                    GCVOLT    399
         CALPHA(JPOSN) = -1.0                                           GCVOLT    400
         WRITE (MSG(1),9000) TIMX,SUBNAM                                GCVOLT    401
         WRITE (MSG(2),9100) DCCNAM(JPOSN)                              GCVOLT    402
         WRITE (MSG(3),9120)                                            GCVOLT    403
         CALL PRTMSG(3)                                                 GCVOLT    404
      END IF                                                            GCVOLT    405
C                                                                       GCVOLT    406
C     Determine if inverter or rectifier, and set the sign term.        GCVOLT    407
C                                                                       GCVOLT    408
      IF(QINV(JPOSN))THEN                                               GCVOLT    409
         SIGN = 1.0                                                     GCVOLT    410
      ELSE                                                              GCVOLT    411
         SIGN = -1.0                                                    GCVOLT    412
      END IF                                                            GCVOLT    413
C                                                                       GCVOLT    414
C     CALCULATE THE CURRENT                                             GCVOLT    415
C                                                                       GCVOLT    416
      V1 = TAPPOS(JPOSN) * SIGN * VAHVDC(JPOSN)                         GCVOLT    417
      IF(ABS(V1).LT.0.0001) V1 = 0.0001*SIGN                            GCVOLT    418
      V2 = VDCONV(JPOSN) + V1 * CALPHA(JPOSN)                           GCVOLT    419
      XDCONV(JPOSN) = -PII * V2 /(3.0 *XCCONV(JPOSN))                   GCVOLT    420
C                                                                       GCVOLT    421
C     DO NOT ALLOW NEGATIVE CURRENT TO FLOW                             GCVOLT    422
C                                                                       GCVOLT    423
      IF(XDCONV(JPOSN)*SIGN.GT.0.0) THEN                                GCVOLT    424
         NEGCUR = .TRUE.                                                GCVOLT    425
         SETPT=0.0                                                      GCVOLT    426
         USETPT(JPOSN)=0.0                                              GCVOLT    427
         UMODE(JPOSN)= 'BLOCK'                                          GCVOLT    428
         XDCONV(JPOSN) = 0.0                                            GCVOLT    429
         IF(ICEXT(JPOSN).EQ.0) THEN                                     GCVOLT    430
            ICEXT(JPOSN)=1                                              GCVOLT    431
            WRITE (MSG(1),9000) TIMX,SUBNAM                             GCVOLT    432
            WRITE (MSG(2),9170) DCCNAM(JPOSN)                           GCVOLT    433
            WRITE (MSG(3),9180)                                         GCVOLT    434
            CALL PRTMSG(3)                                              GCVOLT    435
         ENDIF                                                          GCVOLT    436
      ELSEIF(XDCONV(JPOSN)*SIGN.LT.0.0) THEN                            GCVOLT    437
         IF(ICEXT(JPOSN).EQ.1) THEN                                     GCVOLT    438
            ICEXT(JPOSN)=0                                              GCVOLT    439
            WRITE (MSG(1),9000) TIMX,SUBNAM                             GCVOLT    440
            WRITE (MSG(2),9170) DCCNAM(JPOSN)                           GCVOLT    441
            WRITE (MSG(3),9181)                                         GCVOLT    442
            CALL PRTMSG(3)                                              GCVOLT    443
         ENDIF                                                          GCVOLT    444
      END IF                                                            GCVOLT    445
C                                                                       GCVOLT    446
C     NOW CALCULATE GAMMA VALUE                                         GCVOLT    447
C                                                                       GCVOLT    448
      V3= V1*PII/(6.0*XCCONV(JPOSN))                                    GCVOLT    449
      CGAMMA(JPOSN) = -CALPHA(JPOSN) -XDCONV(JPOSN)/V3                  GCVOLT    450
C                                                                       GCVOLT    451
      IF(CGAMMA(JPOSN) .GT. 1.0)THEN                                    GCVOLT    452
         CGAMMA(JPOSN) = 1.0                                            GCVOLT    453
         COMFAL = .TRUE.                                                GCVOLT    454
         UMODE(JPOSN) = 'COMFAIL'                                       GCVOLT    455
         USETPT(JPOSN) = 0.0                                            GCVOLT    456
         SETPT = 0.0                                                    GCVOLT    457
         IF(ICOMF(JPOSN).EQ.0) THEN                                     GCVOLT    458
            ICOMF(JPOSN)=1                                              GCVOLT    459
            WRITE (MSG(1),9000) TIMX,SUBNAM                             GCVOLT    460
            WRITE (MSG(2),9100) DCCNAM(JPOSN)                           GCVOLT    461
            WRITE (MSG(3),9101) XDCONV(JPOSN),-V1,VDCONV(JPOSN)         GCVOLT    462
            WRITE (MSG(4),9140)                                         GCVOLT    463
            CALL PRTMSG(4)                                              GCVOLT    464
         ENDIF                                                          GCVOLT    465
      ELSEIF(CGAMMA(JPOSN).LT.1.0) THEN                                 GCVOLT    466
         IF(ICOMF(JPOSN).EQ.1)  THEN                                    GCVOLT    467
            ICOMF(JPOSN)=0                                              GCVOLT    468
            WRITE (MSG(1),9000) TIMX,SUBNAM                             GCVOLT    469
            WRITE (MSG(2),9100) DCCNAM(JPOSN)                           GCVOLT    470
            WRITE (MSG(3),9101) XDCONV(JPOSN),-V1,VDCONV(JPOSN)         GCVOLT    471
            WRITE (MSG(4),9261)                                         GCVOLT    472
            CALL PRTMSG(4)                                              GCVOLT    473
         ENDIF                                                          GCVOLT    474
      END IF                                                            GCVOLT    475
C                                                                       GCVOLT    476
      IF(CGAMMA(JPOSN) .LT. -1.0)THEN                                   GCVOLT    477
         CGAMMA(JPOSN) = -1.0                                           GCVOLT    478
         UMODE(JPOSN) = 'ALPHA'                                         GCVOLT    479
         USETPT(JPOSN) = 0.0                                            GCVOLT    480
         SETPT = 0.0                                                    GCVOLT    481
         CALPHA(JPOSN) = 1.0                                            GCVOLT    482
         DCCHNG = .TRUE.                                                GCVOLT    483
         WRITE (MSG(1),9000) TIMX,SUBNAM                                GCVOLT    484
         WRITE (MSG(2),9100) DCCNAM(JPOSN)                              GCVOLT    485
         WRITE (MSG(3),9101) XDCONV(JPOSN),-V1,VDCONV(JPOSN)            GCVOLT    486
         WRITE (MSG(4),9160)                                            GCVOLT    487
         CALL PRTMSG(4)                                                 GCVOLT    488
      END IF                                                            GCVOLT    489
C                                                                       GCVOLT    490
      RETURN                                                            GCVOLT    491
C                                                                       GCVOLT    492
      ENTRY SCGAMA (JPOSN, SETPT,TIMX)                                  GCVOLT    493
CD -------------------------------------------------------------------  GCVOLT    494
CD                                                                      GCVOLT    495
CD              *****     SCGAMA  ROUTINE   *****                       GCVOLT    496
CD                                                                      GCVOLT    497
CD -------------------------------------------------------------------  GCVOLT    498
CD                                                                      GCVOLT    499
CD       PURPOSE:  Solve for current and cos(alpha) for gamma           GCVOLT    500
CD                 controlled converter.                                GCVOLT    501
CD                                                                      GCVOLT    502
CD -------------------------------------------------------------------  GCVOLT    503
C                                                                       GCVOLT    504
      IF(SDBG)THEN                                                      GCVOLT    505
         SUBNAM = 'SCGAMA ROUTINE.'                                     GCVOLT    506
      ELSE                                                              GCVOLT    507
         SUBNAM = ' '                                                   GCVOLT    508
      END IF                                                            GCVOLT    509
C                                                                       GCVOLT    510
      CGAMMA(JPOSN)=COS(SETPT)                                          GCVOLT    511
C                                                                       GCVOLT    512
C                                                                       GCVOLT    513
C     Check for infeasible extinction angle.                            GCVOLT    514
C                                                                       GCVOLT    515
      IF(SETPT .LT. 0.0)THEN                                            GCVOLT    516
         COMFAL = .TRUE.                                                GCVOLT    517
         UMODE(JPOSN) = 'COMFAIL'                                       GCVOLT    518
         USETPT(JPOSN) = 0.0                                            GCVOLT    519
         SETPT = 0.0                                                    GCVOLT    520
         CGAMMA(JPOSN) = 1.0                                            GCVOLT    521
         WRITE (MSG(1),9000) TIMX,SUBNAM                                GCVOLT    522
         WRITE (MSG(2),9100) DCCNAM(JPOSN)                              GCVOLT    523
         WRITE (MSG(3),9200)                                            GCVOLT    524
         CALL PRTMSG(3)                                                 GCVOLT    525
      ELSEIF(SETPT.GT.0.0) THEN                                         GCVOLT    526
         IF(ICOMF(JPOSN).EQ.1)  THEN                                    GCVOLT    527
            ICOMF(JPOSN)=0                                              GCVOLT    528
            WRITE (MSG(1),9000) TIMX,SUBNAM                             GCVOLT    529
            WRITE (MSG(2),9100) DCCNAM(JPOSN)                           GCVOLT    530
            WRITE (MSG(3),9261)                                         GCVOLT    531
            CALL PRTMSG(3)                                              GCVOLT    532
         ENDIF                                                          GCVOLT    533
      END IF                                                            GCVOLT    534
C                                                                       GCVOLT    535
C                                                                       GCVOLT    536
      IF(SETPT .GT. PII)THEN                                            GCVOLT    537
         DCCHNG = .TRUE.                                                GCVOLT    538
         UMODE(JPOSN) = 'ALPHA'                                         GCVOLT    539
         USETPT(JPOSN) = 0.0                                            GCVOLT    540
         SETPT = 0.0                                                    GCVOLT    541
         CGAMMA(JPOSN) = -1.0                                           GCVOLT    542
         WRITE (MSG(1),9000) TIMX,SUBNAM                                GCVOLT    543
         WRITE (MSG(2),9100) DCCNAM(JPOSN)                              GCVOLT    544
         WRITE (MSG(3),9220)                                            GCVOLT    545
         CALL PRTMSG(3)                                                 GCVOLT    546
      END IF                                                            GCVOLT    547
C                                                                       GCVOLT    548
C     Determine if inverter or rectifier, and set the sign term.        GCVOLT    549
C                                                                       GCVOLT    550
      IF(QINV(JPOSN))THEN                                               GCVOLT    551
         SIGN = 1.0                                                     GCVOLT    552
      ELSE                                                              GCVOLT    553
         SIGN = -1.0                                                    GCVOLT    554
      END IF                                                            GCVOLT    555
C                                                                       GCVOLT    556
C     CALCULATE THE CURRENT                                             GCVOLT    557
C                                                                       GCVOLT    558
      V1 = TAPPOS(JPOSN) * SIGN * VAHVDC(JPOSN)                         GCVOLT    559
      IF(ABS(V1).LT.0.0001) V1 = 0.0001*SIGN                            GCVOLT    560
      V2 = -VDCONV(JPOSN) + V1 *CGAMMA(JPOSN)                           GCVOLT    561
      XDCONV(JPOSN) = -PII * V2 / (3.0 * XCCONV(JPOSN))                 GCVOLT    562
C                                                                       GCVOLT    563
C     CHECK FOR AND PREVENT REVERSE CURRENT                             GCVOLT    564
C                                                                       GCVOLT    565
      IF(XDCONV(JPOSN) * SIGN .GT. 0.0)THEN                             GCVOLT    566
         NEGCUR = .TRUE.                                                GCVOLT    567
         SETPT = 0.0                                                    GCVOLT    568
         USETPT(JPOSN) = 0.0                                            GCVOLT    569
         UMODE(JPOSN) = 'BLOCK'                                         GCVOLT    570
         XDCONV(JPOSN)=0.0                                              GCVOLT    571
         IF(ICEXT(JPOSN).EQ.0) THEN                                     GCVOLT    572
            ICEXT(JPOSN)=1                                              GCVOLT    573
            WRITE (MSG(1),9000) TIMX,SUBNAM                             GCVOLT    574
            WRITE (MSG(2),9170) DCCNAM(JPOSN)                           GCVOLT    575
            WRITE (MSG(3),9180)                                         GCVOLT    576
            CALL PRTMSG(3)                                              GCVOLT    577
         ENDIF                                                          GCVOLT    578
      ELSEIF(XDCONV(JPOSN)*SIGN.LT.0.0) THEN                            GCVOLT    579
         IF(ICEXT(JPOSN).EQ.1)  THEN                                    GCVOLT    580
            ICEXT(JPOSN)=0                                              GCVOLT    581
            WRITE (MSG(1),9000) TIMX,SUBNAM                             GCVOLT    582
            WRITE (MSG(2),9170) DCCNAM(JPOSN)                           GCVOLT    583
            WRITE (MSG(3),9181)                                         GCVOLT    584
            CALL PRTMSG(3)                                              GCVOLT    585
         ENDIF                                                          GCVOLT    586
      END IF                                                            GCVOLT    587
C                                                                       GCVOLT    588
C     NOW CALCULATE ALPHA VALUE                                         GCVOLT    589
C                                                                       GCVOLT    590
      V3 = V1 * PII / (6.0 * XCCONV(JPOSN))                             GCVOLT    591
      CALPHA(JPOSN) = -CGAMMA(JPOSN) - XDCONV(JPOSN) / V3               GCVOLT    592
      IF(CALPHA(JPOSN) .GT. 1.0)THEN                                    GCVOLT    593
         CALPHA(JPOSN) = 1.0                                            GCVOLT    594
         UMODE(JPOSN) = 'ALPHA'                                         GCVOLT    595
         USETPT(JPOSN) = 0.0                                            GCVOLT    596
         SETPT = 0.0                                                    GCVOLT    597
         WRITE (MSG(1),9000) TIMX,SUBNAM                                GCVOLT    598
         WRITE (MSG(2),9100) DCCNAM(JPOSN)                              GCVOLT    599
         WRITE (MSG(3),9101) XDCONV(JPOSN),-V1,VDCONV(JPOSN)            GCVOLT    600
         WRITE (MSG(4),9240)                                            GCVOLT    601
         CALL PRTMSG(4)                                                 GCVOLT    602
         DCCHNG = .TRUE.                                                GCVOLT    603
      END IF                                                            GCVOLT    604
C                                                                       GCVOLT    605
      IF(CALPHA(JPOSN) .LT. -1.0)THEN                                   GCVOLT    606
         CALPHA(JPOSN) = -1.0                                           GCVOLT    607
         COMFAL = .TRUE.                                                GCVOLT    608
         UMODE(JPOSN) = 'COMFAIL'                                       GCVOLT    609
         USETPT(JPOSN) = 0.0                                            GCVOLT    610
         SETPT = 0.0                                                    GCVOLT    611
         IF(ICOMF(JPOSN).EQ.0) THEN                                     GCVOLT    612
            ICOMF(JPOSN)=1                                              GCVOLT    613
            WRITE (MSG(1),9000) TIMX,SUBNAM                             GCVOLT    614
            WRITE (MSG(2),9100) DCCNAM(JPOSN)                           GCVOLT    615
            WRITE (MSG(3),9101) XDCONV(JPOSN),-V1,VDCONV(JPOSN)         GCVOLT    616
            WRITE (MSG(4),9260)                                         GCVOLT    617
            CALL PRTMSG(4)                                              GCVOLT    618
         ENDIF                                                          GCVOLT    619
      END IF                                                            GCVOLT    620
C                                                                       GCVOLT    621
      RETURN                                                            GCVOLT    622
C                                                                       GCVOLT    623
      ENTRY SCVOLT (JPOSN, SETPT,TIMX,IVC)                              GCVOLT    624
CD -------------------------------------------------------------------  GCVOLT    625
CD                                                                      GCVOLT    626
CD              *****     SCVOLT  ROUTINE   *****                       GCVOLT    627
CD                                                                      GCVOLT    628
CD -------------------------------------------------------------------  GCVOLT    629
CD                                                                      GCVOLT    630
CD       PURPOSE:  Solve for current, cos(alpha), and cos(gamma)        GCVOLT    631
CD                 for voltage controlled converter.                    GCVOLT    632
CD                                                                      GCVOLT    633
CD -------------------------------------------------------------------  GCVOLT    634
C                                                                       GCVOLT    635
      IF(SDBG)THEN                                                      GCVOLT    636
         SUBNAM = 'SCVOLT ROUTINE.'                                     GCVOLT    637
      ELSE                                                              GCVOLT    638
         SUBNAM = ' '                                                   GCVOLT    639
      END IF                                                            GCVOLT    640
C                                                                       GCVOLT    641
      NOCHG = .TRUE.                                                    GCVOLT    642
      IVC=1                                                             GCVOLT    643
C                                                                       GCVOLT    644
      VDCONV(JPOSN) = SETPT                                             GCVOLT    645
C                                                                       GCVOLT    646
C                                                                       GCVOLT    647
C     Determine converter current from network                          GCVOLT    648
C                                                                       GCVOLT    649
      I = ICONRE(JPOSN,1)                                               GCVOLT    650
      J = ICONRE(JPOSN,2)                                               GCVOLT    651
C                                                                       GCVOLT    652
      IF(J.EQ.0)THEN                                                    GCVOLT    653
         JROW = I                                                       GCVOLT    654
      ELSE                                                              GCVOLT    655
         JROW = J                                                       GCVOLT    656
      END IF                                                            GCVOLT    657
C                                                                       GCVOLT    658
C     Use the saved JROW vector and node voltages to get current        GCVOLT    659
C                                                                       GCVOLT    660
      CURR = 0.0                                                        GCVOLT    661
      DO 620 II = 1, NUMNOD                                             GCVOLT    662
         CURR = CURR + GMSAVE(JROW,II) * VDCNOD(II)                     GCVOLT    663
620   CONTINUE                                                          GCVOLT    664
      CURR = CURR - XINJSA(JROW)                                        GCVOLT    665
C                                                                       GCVOLT    666
      IF(J.EQ.0)THEN                                                    GCVOLT    667
         SETPT = CURR*1000.0                                            GCVOLT    668
      ELSE                                                              GCVOLT    669
         SETPT = -CURR*1000.0                                           GCVOLT    670
      END IF                                                            GCVOLT    671
C                                                                       GCVOLT    672
C     Because converters cannot tolerate negative current in a "COMFAIL"GCVOLT    673
C     state we must prevent it.                                         GCVOLT    674
C                                                                       GCVOLT    675
      IF(QINV(JPOSN))THEN                                               GCVOLT    676
         SIGN = 1.0                                                     GCVOLT    677
      ELSE                                                              GCVOLT    678
         SIGN = -1.0                                                    GCVOLT    679
      END IF                                                            GCVOLT    680
C                                                                       GCVOLT    681
      IF(SETPT * SIGN .GT. 0.0.AND.UMODE(JPOSN) .NE. 'BYPASS')THEN      GCVOLT    682
         NEGCUR = .TRUE.                                                GCVOLT    683
         SETPT = 0.0                                                    GCVOLT    684
         USETPT(JPOSN) = 0.0                                            GCVOLT    685
         UMODE(JPOSN) = 'BLOCK'                                         GCVOLT    686
         NOCHG = .FALSE.                                                GCVOLT    687
         IF(ICEXT(JPOSN).EQ.0) THEN                                     GCVOLT    688
            ICEXT(JPOSN)=1                                              GCVOLT    689
            WRITE (MSG(1),9000) TIMX,SUBNAM                             GCVOLT    690
            WRITE (MSG(2),9170) DCCNAM(JPOSN)                           GCVOLT    691
            WRITE (MSG(3),9180)                                         GCVOLT    692
            CALL PRTMSG(3)                                              GCVOLT    693
         ENDIF                                                          GCVOLT    694
      END IF                                                            GCVOLT    695
C                                                                       GCVOLT    696
      IF(UMODE(JPOSN).EQ.'BYPASS' .OR.                                  GCVOLT    697
     1    UMODE(JPOSN).EQ.'COMFAIL')THEN                                GCVOLT    698
         SETPT = 0.0                                                    GCVOLT    699
      END IF                                                            GCVOLT    700
C                                                                       GCVOLT    701
      IF(.NOT.NOCHG) RETURN                                             GCVOLT    702
C                                                                       GCVOLT    703
      ENTRY SCCURR (JPOSN, SETPT,TIMX,IVC)                              GCVOLT    704
CD -------------------------------------------------------------------  GCVOLT    705
CD                                                                      GCVOLT    706
CD              *****     SCCURR  ROUTINE   *****                       GCVOLT    707
CD                                                                      GCVOLT    708
CD -------------------------------------------------------------------  GCVOLT    709
CD                                                                      GCVOLT    710
CD       PURPOSE:  Solve for cos(alpha) and cos(gamma) for current      GCVOLT    711
CD                 controlled converter.                                GCVOLT    712
CD                                                                      GCVOLT    713
CD -------------------------------------------------------------------  GCVOLT    714
C                                                                       GCVOLT    715
      IF(SDBG)THEN                                                      GCVOLT    716
        IF(IVC.EQ.0)THEN                                                GCVOLT    717
         SUBNAM = 'SCCURR ROUTINE.'                                     GCVOLT    718
        ELSE                                                            GCVOLT    719
         SUBNAM = 'SCVOLT ROUTINE.'                                     GCVOLT    720
        ENDIF                                                           GCVOLT    721
      ELSE                                                              GCVOLT    722
         SUBNAM = ' '                                                   GCVOLT    723
      END IF                                                            GCVOLT    724
C                                                                       GCVOLT    725
      XDCONV(JPOSN) = SETPT / 1000.0                                    GCVOLT    726
C                                                                       GCVOLT    727
C     Determine if inverter or rectifier, and set the sign term.        GCVOLT    728
C                                                                       GCVOLT    729
      IF(QINV(JPOSN))THEN                                               GCVOLT    730
         SIGN = 1.0                                                     GCVOLT    731
      ELSE                                                              GCVOLT    732
         SIGN = -1.0                                                    GCVOLT    733
      END IF                                                            GCVOLT    734
C                                                                       GCVOLT    735
C     Check current for feasibility.                                    GCVOLT    736
C                                                                       GCVOLT    737
      IF(XDCONV(JPOSN) * SIGN .GT. 0.0)THEN                             GCVOLT    738
         SETPT = 0.0                                                    GCVOLT    739
         NEGCUR = .TRUE.                                                GCVOLT    740
         USETPT(JPOSN) = 0.0                                            GCVOLT    741
         UMODE(JPOSN) = 'BLOCK'                                         GCVOLT    742
         IF(ICEXT(JPOSN).EQ.0) THEN                                     GCVOLT    743
            ICEXT(JPOSN)=1                                              GCVOLT    744
            WRITE (MSG(1),9000) TIMX,SUBNAM                             GCVOLT    745
            WRITE (MSG(2),9170) DCCNAM(JPOSN)                           GCVOLT    746
            WRITE (MSG(3),9180)                                         GCVOLT    747
            CALL PRTMSG(3)                                              GCVOLT    748
         ENDIF                                                          GCVOLT    749
      ELSEIF(XDCONV(JPOSN)*SIGN.LT.0.0) THEN                            GCVOLT    750
         IF(ICEXT(JPOSN).EQ.1)  THEN                                    GCVOLT    751
            ICEXT(JPOSN)=0                                              GCVOLT    752
            WRITE (MSG(1),9000) TIMX,SUBNAM                             GCVOLT    753
            WRITE (MSG(2),9170) DCCNAM(JPOSN)                           GCVOLT    754
            WRITE (MSG(3),9181)                                         GCVOLT    755
            CALL PRTMSG(3)                                              GCVOLT    756
         ENDIF                                                          GCVOLT    757
      END IF                                                            GCVOLT    758
C                                                                       GCVOLT    759
      V1 = 3.0 * XCCONV(JPOSN) * XDCONV(JPOSN) / PII                    GCVOLT    760
      V2 = -TAPPOS(JPOSN) * SIGN * VAHVDC(JPOSN)                        GCVOLT    761
      IF(ABS(V2).LT.0.0001) V2 = -0.0001*SIGN                           GCVOLT    762
C                                                                       GCVOLT    763
      CALPHA(JPOSN) = (VDCONV(JPOSN) + V1) / V2                         GCVOLT    764
C                                                                       GCVOLT    765
      IF(UMODE(JPOSN).EQ.'COMFAIL' .OR.                                 GCVOLT    766
     1   UMODE(JPOSN).EQ.'BYPASS' .OR.                                  GCVOLT    767
     2   UMODE(JPOSN).EQ.'BLOCK')THEN                                   GCVOLT    768
         CALPHA(JPOSN) = 0.0                                            GCVOLT    769
      END IF                                                            GCVOLT    770
C                                                                       GCVOLT    771
      IA1=0                                                             GCVOLT    772
C                                                                       GCVOLT    773
      IF(CALPHA(JPOSN) .GT. 1.0)THEN                                    GCVOLT    774
         CALPHA(JPOSN) = 1.0                                            GCVOLT    775
         IA1=1                                                          GCVOLT    776
         UMODE(JPOSN) = 'ALPHA'                                         GCVOLT    777
         USETPT(JPOSN) = 0.0                                            GCVOLT    778
         SETPT = 0.0                                                    GCVOLT    779
         DCCHNG = .TRUE.                                                GCVOLT    780
         WRITE (MSG(1),9000) TIMX,SUBNAM                                GCVOLT    781
         WRITE (MSG(2),9100) DCCNAM(JPOSN)                              GCVOLT    782
         WRITE (MSG(3),9101) XDCONV(JPOSN),V2,VDCONV(JPOSN)             GCVOLT    783
         WRITE (MSG(4),9240)                                            GCVOLT    784
         CALL PRTMSG(4)                                                 GCVOLT    785
      END IF                                                            GCVOLT    786
C                                                                       GCVOLT    787
      IA2=0                                                             GCVOLT    788
      IF(CALPHA(JPOSN) .LT. -1.0)THEN                                   GCVOLT    789
         CALPHA(JPOSN) = -1.0                                           GCVOLT    790
         IA2=1                                                          GCVOLT    791
         COMFAL = .TRUE.                                                GCVOLT    792
         UMODE(JPOSN) = 'COMFAIL'                                       GCVOLT    793
         USETPT(JPOSN) = 0.0                                            GCVOLT    794
         SETPT = 0.0                                                    GCVOLT    795
         IF(ICOMF(JPOSN).EQ.0) THEN                                     GCVOLT    796
            ICOMF(JPOSN)=1                                              GCVOLT    797
            WRITE (MSG(1),9000) TIMX,SUBNAM                             GCVOLT    798
            WRITE (MSG(2),9100) DCCNAM(JPOSN)                           GCVOLT    799
            WRITE (MSG(3),9101) XDCONV(JPOSN),V2,VDCONV(JPOSN)          GCVOLT    800
            WRITE (MSG(4),9260)                                         GCVOLT    801
            CALL PRTMSG(4)                                              GCVOLT    802
         ENDIF                                                          GCVOLT    803
      END IF                                                            GCVOLT    804
C                                                                       GCVOLT    805
      V3 = -V2 /2.0                                                     GCVOLT    806
      CGAMMA(JPOSN) = (VDCONV(JPOSN) + V3 * CALPHA(JPOSN) )/ V3         GCVOLT    807
C                                                                       GCVOLT    808
      IF(UMODE(JPOSN).EQ.'COMFAIL' .OR.                                 GCVOLT    809
     1   UMODE(JPOSN).EQ.'BYPASS' .OR.                                  GCVOLT    810
     2   UMODE(JPOSN).EQ.'BLOCK')THEN                                   GCVOLT    811
         CGAMMA(JPOSN) = 1.0                                            GCVOLT    812
      END IF                                                            GCVOLT    813
C                                                                       GCVOLT    814
      IF(CGAMMA(JPOSN) .GT. 1.0)THEN                                    GCVOLT    815
         CGAMMA(JPOSN) = 1.0                                            GCVOLT    816
         IF(IA2.EQ.0)THEN                                               GCVOLT    817
         COMFAL = .TRUE.                                                GCVOLT    818
         UMODE(JPOSN) = 'COMFAIL'                                       GCVOLT    819
         USETPT(JPOSN) = 0.0                                            GCVOLT    820
         SETPT = 0.0                                                    GCVOLT    821
         IF(ICOMF(JPOSN).EQ.0) THEN                                     GCVOLT    822
            ICOMF(JPOSN)=1                                              GCVOLT    823
            WRITE (MSG(1),9000) TIMX,SUBNAM                             GCVOLT    824
            WRITE (MSG(2),9100) DCCNAM(JPOSN)                           GCVOLT    825
            WRITE (MSG(3),9101) XDCONV(JPOSN),V2,VDCONV(JPOSN)          GCVOLT    826
            WRITE (MSG(4),9140)                                         GCVOLT    827
            CALL PRTMSG(4)                                              GCVOLT    828
         ENDIF                                                          GCVOLT    829
         ENDIF                                                          GCVOLT    830
      ELSEIF(CGAMMA(JPOSN).LT.1.0) THEN                                 GCVOLT    831
         IF(ICOMF(JPOSN).EQ.1)  THEN                                    GCVOLT    832
            ICOMF(JPOSN)=0                                              GCVOLT    833
            WRITE (MSG(1),9000) TIMX,SUBNAM                             GCVOLT    834
            WRITE (MSG(2),9100) DCCNAM(JPOSN)                           GCVOLT    835
            WRITE (MSG(3),9101) XDCONV(JPOSN),V2,VDCONV(JPOSN)          GCVOLT    836
            WRITE (MSG(4),9261)                                         GCVOLT    837
            CALL PRTMSG(4)                                              GCVOLT    838
         ENDIF                                                          GCVOLT    839
      END IF                                                            GCVOLT    840
C                                                                       GCVOLT    841
      IF(CGAMMA(JPOSN) .LT. -1.0)THEN                                   GCVOLT    842
         CGAMMA(JPOSN) = -1.0                                           GCVOLT    843
         IF(IA1.EQ.0)THEN                                               GCVOLT    844
         UMODE(JPOSN) = 'ALPHA'                                         GCVOLT    845
         USETPT(JPOSN) = 0.0                                            GCVOLT    846
         CALPHA(JPOSN) = 1.0                                            GCVOLT    847
         SETPT = 0.0                                                    GCVOLT    848
         DCCHNG = .TRUE.                                                GCVOLT    849
         WRITE (MSG(1),9000) TIMX,SUBNAM                                GCVOLT    850
         WRITE (MSG(2),9100) DCCNAM(JPOSN)                              GCVOLT    851
         WRITE (MSG(3),9101) XDCONV(JPOSN),V2,VDCONV(JPOSN)             GCVOLT    852
         WRITE (MSG(4),9160)                                            GCVOLT    853
         CALL PRTMSG(4)                                                 GCVOLT    854
         ENDIF                                                          GCVOLT    855
      END IF                                                            GCVOLT    856
C                                                                       GCVOLT    857
      RETURN                                                            GCVOLT    858
C                                                                       GCVOLT    859
      ENTRY SBVOLT (JPOSN)                                              GCVOLT    860
CD -------------------------------------------------------------------  GCVOLT    861
CD                                                                      GCVOLT    862
CD              *****     SBVOLT  ROUTINE   *****                       GCVOLT    863
CD                                                                      GCVOLT    864
CD -------------------------------------------------------------------  GCVOLT    865
CD                                                                      GCVOLT    866
CD       PURPOSE:  Solve for breaker current,                           GCVOLT    867
CD                 for voltage controlled breakers.                     GCVOLT    868
CD                                                                      GCVOLT    869
CD -------------------------------------------------------------------  GCVOLT    870
C                                                                       GCVOLT    871
C     Determine breaker current from network                            GCVOLT    872
C                                                                       GCVOLT    873
      I = IBRKRE(JPOSN,1)                                               GCVOLT    874
      J = IBRKRE(JPOSN,2)                                               GCVOLT    875
C                                                                       GCVOLT    876
      IF (J .EQ. 0) THEN                                                GCVOLT    877
         JROW = I                                                       GCVOLT    878
      ELSE                                                              GCVOLT    879
         JROW = J                                                       GCVOLT    880
      END IF                                                            GCVOLT    881
C                                                                       GCVOLT    882
C     Use the saved row vector and node voltages to get current         GCVOLT    883
C                                                                       GCVOLT    884
      CURR = 0.0                                                        GCVOLT    885
      DO 660 II = 1, NUMNOD                                             GCVOLT    886
         CURR = CURR + GMSAVE(JROW,II) * VDCNOD(II)                     GCVOLT    887
660   CONTINUE                                                          GCVOLT    888
      CURR = CURR - XINJSA(JROW)                                        GCVOLT    889
      IF(J.EQ.0)THEN                                                    GCVOLT    890
         CURR = -CURR                                                   GCVOLT    891
      ENDIF                                                             GCVOLT    892
C                                                                       GCVOLT    893
      UBCURR(JPOSN) = CURR                                              GCVOLT    894
C                                                                       GCVOLT    895
      RETURN                                                            GCVOLT    896
C                                                                       GCVOLT    897
      ENTRY SCALGA (JPOSN, SETP1, SETP2, TIMX)                          GCVOLT    898
CD -------------------------------------------------------------------  GCVOLT    899
CD                                                                      GCVOLT    900
CD              *****     SCALGA  ROUTINE   *****                       GCVOLT    901
CD                                                                      GCVOLT    902
CD -------------------------------------------------------------------  GCVOLT    903
CD                                                                      GCVOLT    904
CD       PURPOSE:  Solve for current for alpha and gamma controlled     GCVOLT    905
CD                 self commutated voltage sourced converter.           GCVOLT    906
CD                                                                      GCVOLT    907
CD -------------------------------------------------------------------  GCVOLT    908
C                                                                       GCVOLT    909
      IF(SDBG)THEN                                                      GCVOLT    910
         SUBNAM = 'SCALGA ROUTINE.'                                     GCVOLT    911
      ELSE                                                              GCVOLT    912
         SUBNAM = ' '                                                   GCVOLT    913
      END IF                                                            GCVOLT    914
C                                                                       GCVOLT    915
C     Check for infeasible power angle                                  GCVOLT    916
C                                                                       GCVOLT    917
      IF(SETP1 .LT. - 1.5707964)THEN                                    GCVOLT    918
         SETP1 = - 1.5707964                                            GCVOLT    919
         DCCHNG = .TRUE.                                                GCVOLT    920
         WRITE (MSG(1),9000) TIMX,SUBNAM                                GCVOLT    921
         WRITE (MSG(2),9100) DCCNAM(JPOSN)                              GCVOLT    922
         WRITE (MSG(3),9111)                                            GCVOLT    923
         CALL PRTMSG(3)                                                 GCVOLT    924
      END IF                                                            GCVOLT    925
C                                                                       GCVOLT    926
C                                                                       GCVOLT    927
      IF(SETP1 .GT. 1.5707964)THEN                                      GCVOLT    928
         SETP1 = 1.5707964                                              GCVOLT    929
         DCCHNG = .TRUE.                                                GCVOLT    930
         WRITE (MSG(1),9000) TIMX,SUBNAM                                GCVOLT    931
         WRITE (MSG(2),9100) DCCNAM(JPOSN)                              GCVOLT    932
         WRITE (MSG(3),9121)                                            GCVOLT    933
         CALL PRTMSG(3)                                                 GCVOLT    934
      END IF                                                            GCVOLT    935
C                                                                       GCVOLT    936
C     Set controlled alpha value.                                       GCVOLT    937
C                                                                       GCVOLT    938
      CALPHA(JPOSN) = SETP1                                             GCVOLT    939
C                                                                       GCVOLT    940
C     Check for infeasible modulation ratio.                            GCVOLT    941
C                                                                       GCVOLT    942
      IF(SETP2 .LT. -1.0)THEN                                           GCVOLT    943
         SETP2 = -1.0                                                   GCVOLT    944
         DCCHNG = .TRUE.                                                GCVOLT    945
         WRITE (MSG(1),9000) TIMX,SUBNAM                                GCVOLT    946
         WRITE (MSG(2),9100) DCCNAM(JPOSN)                              GCVOLT    947
         WRITE (MSG(3),9201)                                            GCVOLT    948
         CALL PRTMSG(3)                                                 GCVOLT    949
      END IF                                                            GCVOLT    950
C                                                                       GCVOLT    951
      IF(SETP2 .GT. 1.0)THEN                                            GCVOLT    952
         SETP2 = 1.0                                                    GCVOLT    953
         DCCHNG = .TRUE.                                                GCVOLT    954
         WRITE (MSG(1),9000) TIMX,SUBNAM                                GCVOLT    955
         WRITE (MSG(2),9100) DCCNAM(JPOSN)                              GCVOLT    956
         WRITE (MSG(3),9221)                                            GCVOLT    957
         CALL PRTMSG(3)                                                 GCVOLT    958
      END IF                                                            GCVOLT    959
C                                                                       GCVOLT    960
C     Set controlled gamma value.                                       GCVOLT    961
C                                                                       GCVOLT    962
      CGAMMA(JPOSN) = SETP2                                             GCVOLT    963
C                                                                       GCVOLT    964
C     Calculate the current                                             GCVOLT    965
C                                                                       GCVOLT    966
      ANG = SETP1 + VACONV(JPOSN)                                       GCVOLT    967
      XDCONV(JPOSN) = - VAHVDC(JPOSN) * SETP2 * SIN(ANG)                GCVOLT    968
     1                / XCCONV(JPOSN) / TAPPOS(JPOSN)                   GCVOLT    969
C                                                                       GCVOLT    970
C     DO NOT ALLOW NEGATIVE VOLTAGE ACROSS CONVERTER                    GCVOLT    971
C                                                                       GCVOLT    972
      IF(VDCONV(JPOSN).LT.0.0) THEN                                     GCVOLT    973
         NEGCUR = .TRUE.                                                GCVOLT    974
         SETP1=0.0                                                      GCVOLT    975
         USETPT(JPOSN)=0.0                                              GCVOLT    976
         UMODE(JPOSN)= 'BYPASS'                                         GCVOLT    977
         IF(ICEXT(JPOSN).EQ.0) THEN                                     GCVOLT    978
            ICEXT(JPOSN)=1                                              GCVOLT    979
            WRITE (MSG(1),9000) TIMX,SUBNAM                             GCVOLT    980
            WRITE (MSG(2),9170) DCCNAM(JPOSN)                           GCVOLT    981
            WRITE (MSG(3),9182)                                         GCVOLT    982
            CALL PRTMSG(3)                                              GCVOLT    983
         ENDIF                                                          GCVOLT    984
      ELSEIF(VDCONV(JPOSN).GT.0.0) THEN                                 GCVOLT    985
         IF(ICEXT(JPOSN).EQ.1) THEN                                     GCVOLT    986
            ICEXT(JPOSN)=0                                              GCVOLT    987
            WRITE (MSG(1),9000) TIMX,SUBNAM                             GCVOLT    988
            WRITE (MSG(2),9170) DCCNAM(JPOSN)                           GCVOLT    989
            WRITE (MSG(3),9183)                                         GCVOLT    990
            CALL PRTMSG(3)                                              GCVOLT    991
         ENDIF                                                          GCVOLT    992
      END IF                                                            GCVOLT    993
C                                                                       GCVOLT    994
      RETURN                                                            GCVOLT    995
C                                                                       GCVOLT    996
      ENTRY SCAGVD (JPOSN, SETP1, SETP2, TIMX, IVC)                     GCVOLT    997
CD -------------------------------------------------------------------  GCVOLT    998
CD                                                                      GCVOLT    999
CD              *****     SCAGVD  ROUTINE   *****                       GCVOLT   1000
CD                                                                      GCVOLT   1001
CD -------------------------------------------------------------------  GCVOLT   1002
CD                                                                      GCVOLT   1003
CD       PURPOSE:  Solve for current and gamma/alpha for alpha/gamma    GCVOLT   1004
CD                 and voltage controlled self commutated               GCVOLT   1005
CD                 voltage sourced converter.                           GCVOLT   1006
CD                                                                      GCVOLT   1007
CD -------------------------------------------------------------------  GCVOLT   1008
C                                                                       GCVOLT   1009
      IF(SDBG)THEN                                                      GCVOLT   1010
         SUBNAM = 'SCAGVD ROUTINE.'                                     GCVOLT   1011
      ELSE                                                              GCVOLT   1012
         SUBNAM = ' '                                                   GCVOLT   1013
      END IF                                                            GCVOLT   1014
C                                                                       GCVOLT   1015
      IF(IVC.EQ.0) IVC=1                                                GCVOLT   1016
C                                                                       GCVOLT   1017
      VDCONV(JPOSN) = SETP2                                             GCVOLT   1018
C                                                                       GCVOLT   1019
C     Determine converter current from network                          GCVOLT   1020
C                                                                       GCVOLT   1021
      I = ICONRE(JPOSN,1)                                               GCVOLT   1022
      J = ICONRE(JPOSN,2)                                               GCVOLT   1023
C                                                                       GCVOLT   1024
      IF(J.EQ.0)THEN                                                    GCVOLT   1025
         JROW = I                                                       GCVOLT   1026
      ELSE                                                              GCVOLT   1027
         JROW = J                                                       GCVOLT   1028
      END IF                                                            GCVOLT   1029
C                                                                       GCVOLT   1030
C     Use the saved JROW vector and node voltages to get current        GCVOLT   1031
C                                                                       GCVOLT   1032
      CURR = 0.0                                                        GCVOLT   1033
      DO 670 II = 1, NUMNOD                                             GCVOLT   1034
         CURR = CURR + GMSAVE(JROW,II) * VDCNOD(II)                     GCVOLT   1035
670   CONTINUE                                                          GCVOLT   1036
      CURR = CURR - XINJSA(JROW)                                        GCVOLT   1037
C                                                                       GCVOLT   1038
      IF(J.EQ.0)THEN                                                    GCVOLT   1039
         SETP2 = CURR*1000.0                                            GCVOLT   1040
      ELSE                                                              GCVOLT   1041
         SETP2 = -CURR*1000.0                                           GCVOLT   1042
      END IF                                                            GCVOLT   1043
C                                                                       GCVOLT   1044
      IF(UMODE(JPOSN).EQ.'COMFAIL' .OR.                                 GCVOLT   1045
     1   UMODE(JPOSN).EQ.'BYPASS' .OR.                                  GCVOLT   1046
     3   UMOD2(JPOSN).EQ.'COMFAIL' .OR.                                 GCVOLT   1047
     4   UMOD2(JPOSN).EQ.'BYPASS') THEN                                 GCVOLT   1048
         SETP2 = 0.0                                                    GCVOLT   1049
      END IF                                                            GCVOLT   1050
C                                                                       GCVOLT   1051
      IF(IVC.EQ.2) GO TO 680                                            GCVOLT   1052
C                                                                       GCVOLT   1053
      ENTRY SCALID (JPOSN, SETP1, SETP2, TIMX, IVC)                     GCVOLT   1054
CD -------------------------------------------------------------------  GCVOLT   1055
CD                                                                      GCVOLT   1056
CD              *****     SCALID  ROUTINE   *****                       GCVOLT   1057
CD                                                                      GCVOLT   1058
CD -------------------------------------------------------------------  GCVOLT   1059
CD                                                                      GCVOLT   1060
CD       PURPOSE:  Solve for gamma for alpha and current controlled     GCVOLT   1061
CD                 self commutated voltage sourced converter.           GCVOLT   1062
CD                                                                      GCVOLT   1063
CD -------------------------------------------------------------------  GCVOLT   1064
C                                                                       GCVOLT   1065
      IF(SDBG)THEN                                                      GCVOLT   1066
        IF(IVC.EQ.0)THEN                                                GCVOLT   1067
         SUBNAM = 'SCALID ROUTINE.'                                     GCVOLT   1068
        ELSE                                                            GCVOLT   1069
         SUBNAM = 'SCAGVD ROUTINE.'                                     GCVOLT   1070
        ENDIF                                                           GCVOLT   1071
      ELSE                                                              GCVOLT   1072
         SUBNAM = ' '                                                   GCVOLT   1073
      END IF                                                            GCVOLT   1074
C                                                                       GCVOLT   1075
C     Set controlled current value.                                     GCVOLT   1076
C                                                                       GCVOLT   1077
      XDCONV(JPOSN) = SETP2 / 1000.0                                    GCVOLT   1078
C                                                                       GCVOLT   1079
C     Check for infeasible power angle                                  GCVOLT   1080
C                                                                       GCVOLT   1081
      IF(SETP1 .LT. - 1.5707964)THEN                                    GCVOLT   1082
         SETP1 = - 1.5707964                                            GCVOLT   1083
         DCCHNG = .TRUE.                                                GCVOLT   1084
         WRITE (MSG(1),9000) TIMX,SUBNAM                                GCVOLT   1085
         WRITE (MSG(2),9100) DCCNAM(JPOSN)                              GCVOLT   1086
         WRITE (MSG(3),9111)                                            GCVOLT   1087
         CALL PRTMSG(3)                                                 GCVOLT   1088
      END IF                                                            GCVOLT   1089
C                                                                       GCVOLT   1090
      IF(SETP1 .GT. 1.5707964)THEN                                      GCVOLT   1091
         SETP1 = 1.5707964                                              GCVOLT   1092
         DCCHNG = .TRUE.                                                GCVOLT   1093
         WRITE (MSG(1),9000) TIMX,SUBNAM                                GCVOLT   1094
         WRITE (MSG(2),9100) DCCNAM(JPOSN)                              GCVOLT   1095
         WRITE (MSG(3),9121)                                            GCVOLT   1096
         CALL PRTMSG(3)                                                 GCVOLT   1097
      END IF                                                            GCVOLT   1098
C                                                                       GCVOLT   1099
C     Calculate gamma                                                   GCVOLT   1100
C                                                                       GCVOLT   1101
      IF(UMODE(JPOSN).EQ.'COMFAIL' .OR.                                 GCVOLT   1102
     1   UMODE(JPOSN).EQ.'BYPASS' .OR.                                  GCVOLT   1103
     2   UMODE(JPOSN).EQ.'BLOCK' .OR.                                   GCVOLT   1104
     3   UMOD2(JPOSN).EQ.'COMFAIL' .OR.                                 GCVOLT   1105
     4   UMOD2(JPOSN).EQ.'BYPASS' .OR.                                  GCVOLT   1106
     5   UMOD2(JPOSN).EQ.'BLOCK') THEN                                  GCVOLT   1107
         CGAMMA(JPOSN) = 0.0                                            GCVOLT   1108
      ELSE                                                              GCVOLT   1109
         ANG = SETP1 + VACONV(JPOSN)                                    GCVOLT   1110
         IF(ABS(ANG).LT.0.000001) ANG = 0.000001                        GCVOLT   1111
         SETP1 = ANG -VAHVDC(JPOSN)                                     GCVOLT   1112
         CGAMMA(JPOSN) = - XDCONV(JPOSN) * TAPPOS(JPOSN) *              GCVOLT   1113
     1                     XCCONV(JPOSN) /(VAHVDC(JPOSN) * SIN(ANG))    GCVOLT   1114
         IF(UMODE(JPOSN).EQ.'ALPHA') USETPT(JPOSN) = SETP1 * 180.0/PII  GCVOLT   1115
         IF(UMOD2(JPOSN).EQ.'ALPHA') USETP2(JPOSN) = SETP1 * 180.0/PII  GCVOLT   1116
      END IF                                                            GCVOLT   1117
C                                                                       GCVOLT   1118
      CALPHA(JPOSN) = SETP1                                             GCVOLT   1119
C                                                                       GCVOLT   1120
C     Check for infeasible modulation ratio.                            GCVOLT   1121
C                                                                       GCVOLT   1122
      IF(CGAMMA(JPOSN) .LT. -1.0)THEN                                   GCVOLT   1123
         CGAMMA(JPOSN) = -1.0                                           GCVOLT   1124
         MODCHG = .TRUE.                                                GCVOLT   1125
         IF(UMODE(JPOSN).EQ.'ALPHA') THEN                               GCVOLT   1126
            UMOD2(JPOSN) = 'GAMMA'                                      GCVOLT   1127
            USETP2(JPOSN) = -1.0                                        GCVOLT   1128
         ENDIF                                                          GCVOLT   1129
         IF(UMOD2(JPOSN).EQ.'ALPHA') THEN                               GCVOLT   1130
            UMODE(JPOSN) = 'GAMMA'                                      GCVOLT   1131
            USETPT(JPOSN) = -1.0                                        GCVOLT   1132
         ENDIF                                                          GCVOLT   1133
         IF(ICOMF(JPOSN).EQ.0) THEN                                     GCVOLT   1134
            ICOMF(JPOSN)=1                                              GCVOLT   1135
            WRITE (MSG(1),9000) TIMX,SUBNAM                             GCVOLT   1136
            WRITE (MSG(2),9100) DCCNAM(JPOSN)                           GCVOLT   1137
            WRITE (MSG(3),9141)                                         GCVOLT   1138
            CALL PRTMSG(3)                                              GCVOLT   1139
         ENDIF                                                          GCVOLT   1140
      ELSEIF(CGAMMA(JPOSN) .GT. 1.0)THEN                                GCVOLT   1141
         CGAMMA(JPOSN) = 1.0                                            GCVOLT   1142
         MODCHG = .TRUE.                                                GCVOLT   1143
         IF(UMODE(JPOSN).EQ.'ALPHA') THEN                               GCVOLT   1144
            UMOD2(JPOSN) = 'GAMMA'                                      GCVOLT   1145
            USETP2(JPOSN) = 1.0                                         GCVOLT   1146
         ENDIF                                                          GCVOLT   1147
         IF(UMOD2(JPOSN).EQ.'ALPHA') THEN                               GCVOLT   1148
            UMODE(JPOSN) = 'GAMMA'                                      GCVOLT   1149
            USETPT(JPOSN) = 1.0                                         GCVOLT   1150
         ENDIF                                                          GCVOLT   1151
         IF(ICOMF(JPOSN).EQ.0) THEN                                     GCVOLT   1152
            ICOMF(JPOSN)=1                                              GCVOLT   1153
            WRITE (MSG(1),9000) TIMX,SUBNAM                             GCVOLT   1154
            WRITE (MSG(2),9100) DCCNAM(JPOSN)                           GCVOLT   1155
            WRITE (MSG(3),9161)                                         GCVOLT   1156
            CALL PRTMSG(3)                                              GCVOLT   1157
         ENDIF                                                          GCVOLT   1158
      ELSE                                                              GCVOLT   1159
         IF(ICOMF(JPOSN).EQ.1) THEN                                     GCVOLT   1160
            ICOMF(JPOSN)=0                                              GCVOLT   1161
            WRITE (MSG(1),9000) TIMX,SUBNAM                             GCVOLT   1162
            WRITE (MSG(2),9100) DCCNAM(JPOSN)                           GCVOLT   1163
            WRITE (MSG(3),9163)                                         GCVOLT   1164
            CALL PRTMSG(3)                                              GCVOLT   1165
         ENDIF                                                          GCVOLT   1166
      END IF                                                            GCVOLT   1167
C                                                                       GCVOLT   1168
C     DO NOT ALLOW NEGATIVE VOLTAGE ACROSS CONVERTER                    GCVOLT   1169
C                                                                       GCVOLT   1170
      IF(VDCONV(JPOSN).LT.0.0) THEN                                     GCVOLT   1171
         NEGCUR = .TRUE.                                                GCVOLT   1172
         SETP1=0.0                                                      GCVOLT   1173
         USETPT(JPOSN)=0.0                                              GCVOLT   1174
         UMODE(JPOSN)= 'BYPASS'                                         GCVOLT   1175
         IF(ICEXT(JPOSN).EQ.0) THEN                                     GCVOLT   1176
            ICEXT(JPOSN)=1                                              GCVOLT   1177
            WRITE (MSG(1),9000) TIMX,SUBNAM                             GCVOLT   1178
            WRITE (MSG(2),9170) DCCNAM(JPOSN)                           GCVOLT   1179
            WRITE (MSG(3),9182)                                         GCVOLT   1180
            CALL PRTMSG(3)                                              GCVOLT   1181
         ENDIF                                                          GCVOLT   1182
      ELSEIF(VDCONV(JPOSN).GT.0.0) THEN                                 GCVOLT   1183
         IF(ICEXT(JPOSN).EQ.1) THEN                                     GCVOLT   1184
            ICEXT(JPOSN)=0                                              GCVOLT   1185
            WRITE (MSG(1),9000) TIMX,SUBNAM                             GCVOLT   1186
            WRITE (MSG(2),9170) DCCNAM(JPOSN)                           GCVOLT   1187
            WRITE (MSG(3),9183)                                         GCVOLT   1188
            CALL PRTMSG(3)                                              GCVOLT   1189
         ENDIF                                                          GCVOLT   1190
      END IF                                                            GCVOLT   1191
C                                                                       GCVOLT   1192
      RETURN                                                            GCVOLT   1193
C                                                                       GCVOLT   1194
      ENTRY SCGAID (JPOSN, SETP1, SETP2, TIMX, IVC)                     GCVOLT   1195
CD -------------------------------------------------------------------  GCVOLT   1196
CD                                                                      GCVOLT   1197
CD              *****     SCGAID  ROUTINE   *****                       GCVOLT   1198
CD                                                                      GCVOLT   1199
CD -------------------------------------------------------------------  GCVOLT   1200
CD                                                                      GCVOLT   1201
CD       PURPOSE:  Solve for alpha for gamma and current controlled     GCVOLT   1202
CD                 self commutated voltage sourced converter.           GCVOLT   1203
CD                                                                      GCVOLT   1204
CD -------------------------------------------------------------------  GCVOLT   1205
C                                                                       GCVOLT   1206
  680 IF(SDBG)THEN                                                      GCVOLT   1207
        IF(IVC.EQ.0)THEN                                                GCVOLT   1208
         SUBNAM = 'SCGAID ROUTINE.'                                     GCVOLT   1209
        ELSE                                                            GCVOLT   1210
         SUBNAM = 'SCAGVD ROUTINE.'                                     GCVOLT   1211
        ENDIF                                                           GCVOLT   1212
      ELSE                                                              GCVOLT   1213
         SUBNAM = ' '                                                   GCVOLT   1214
      END IF                                                            GCVOLT   1215
C                                                                       GCVOLT   1216
C     Set controlled current value.                                     GCVOLT   1217
C                                                                       GCVOLT   1218
      XDCONV(JPOSN) = SETP2 / 1000.0                                    GCVOLT   1219
C                                                                       GCVOLT   1220
C     Check for infeasible modulation ratio.                            GCVOLT   1221
C                                                                       GCVOLT   1222
      IF(SETP1 .LT. -1.0)THEN                                           GCVOLT   1223
         SETP1 = -1.0                                                   GCVOLT   1224
         DCCHNG = .TRUE.                                                GCVOLT   1225
         WRITE (MSG(1),9000) TIMX,SUBNAM                                GCVOLT   1226
         WRITE (MSG(2),9100) DCCNAM(JPOSN)                              GCVOLT   1227
         WRITE (MSG(3),9201)                                            GCVOLT   1228
         CALL PRTMSG(3)                                                 GCVOLT   1229
      END IF                                                            GCVOLT   1230
C                                                                       GCVOLT   1231
      IF(SETP1 .GT. 1.0)THEN                                            GCVOLT   1232
         SETP1 = 1.0                                                    GCVOLT   1233
         DCCHNG = .TRUE.                                                GCVOLT   1234
         WRITE (MSG(1),9000) TIMX,SUBNAM                                GCVOLT   1235
         WRITE (MSG(2),9100) DCCNAM(JPOSN)                              GCVOLT   1236
         WRITE (MSG(3),9221)                                            GCVOLT   1237
         CALL PRTMSG(3)                                                 GCVOLT   1238
      END IF                                                            GCVOLT   1239
C                                                                       GCVOLT   1240
C     Calculate alpha                                                   GCVOLT   1241
C                                                                       GCVOLT   1242
      IF(UMODE(JPOSN).EQ.'COMFAIL' .OR.                                 GCVOLT   1243
     1   UMODE(JPOSN).EQ.'BYPASS' .OR.                                  GCVOLT   1244
     2   UMODE(JPOSN).EQ.'BLOCK' .OR.                                   GCVOLT   1245
     3   UMOD2(JPOSN).EQ.'COMFAIL' .OR.                                 GCVOLT   1246
     4   UMOD2(JPOSN).EQ.'BYPASS' .OR.                                  GCVOLT   1247
     5   UMOD2(JPOSN).EQ.'BLOCK') THEN                                  GCVOLT   1248
         CALPHA(JPOSN) = 0.0                                            GCVOLT   1249
         CGAMMA(JPOSN) = 0.0                                            GCVOLT   1250
      ELSE                                                              GCVOLT   1251
         IF(ABS(SETP1).LT.0.000001) SETP1 = 0.000001                    GCVOLT   1252
         IF(UMODE(JPOSN).EQ.'GAMMA') USETPT(JPOSN) = SETP1              GCVOLT   1253
         IF(UMOD2(JPOSN).EQ.'GAMMA') USETP2(JPOSN) = SETP1              GCVOLT   1254
         CGAMMA(JPOSN) = SETP1                                          GCVOLT   1255
         SINA = - XDCONV(JPOSN) * TAPPOS(JPOSN) *                       GCVOLT   1256
     1            XCCONV(JPOSN) / (VAHVDC(JPOSN) * SETP1)               GCVOLT   1257
C                                                                       GCVOLT   1258
C     Check for infeasible power angle.                                 GCVOLT   1259
C                                                                       GCVOLT   1260
         IF(SINA .LT. - 1.0) THEN                                       GCVOLT   1261
            IF(VACONV(JPOSN).GT.0.0) THEN                               GCVOLT   1262
               CALPHA(JPOSN) = -1.5707964 - VACONV(JPOSN)               GCVOLT   1263
               ALP = CALPHA(JPOSN) * 180.0 / PII                        GCVOLT   1264
            ELSE                                                        GCVOLT   1265
               CALPHA(JPOSN) = -1.5707964                               GCVOLT   1266
               ALP = -90.0                                              GCVOLT   1267
            ENDIF                                                       GCVOLT   1268
            MODCHG = .TRUE.                                             GCVOLT   1269
            IF(UMODE(JPOSN).EQ.'GAMMA') THEN                            GCVOLT   1270
               UMOD2(JPOSN) = 'ALPHA'                                   GCVOLT   1271
               USETP2(JPOSN) = ALP                                      GCVOLT   1272
            ENDIF                                                       GCVOLT   1273
            IF(UMOD2(JPOSN).EQ.'GAMMA') THEN                            GCVOLT   1274
               UMODE(JPOSN) = 'ALPHA'                                   GCVOLT   1275
               USETPT(JPOSN) = ALP                                      GCVOLT   1276
            ENDIF                                                       GCVOLT   1277
            IF(ICOMF(JPOSN).EQ.0) THEN                                  GCVOLT   1278
               ICOMF(JPOSN)=1                                           GCVOLT   1279
               WRITE (MSG(1),9000) TIMX,SUBNAM                          GCVOLT   1280
               WRITE (MSG(2),9100) DCCNAM(JPOSN)                        GCVOLT   1281
               WRITE (MSG(3),9241) ALP                                  GCVOLT   1282
               CALL PRTMSG(3)                                           GCVOLT   1283
            ENDIF                                                       GCVOLT   1284
         ELSEIF(SINA .GT. 1.0) THEN                                     GCVOLT   1285
            IF(VACONV(JPOSN).LT.0.0) THEN                               GCVOLT   1286
               CALPHA(JPOSN) = 1.5707964 - VACONV(JPOSN)                GCVOLT   1287
               ALP = CALPHA(JPOSN) * 180.0 / PII                        GCVOLT   1288
            ELSE                                                        GCVOLT   1289
               CALPHA(JPOSN) = 1.5707964                                GCVOLT   1290
               ALP = 90.0                                               GCVOLT   1291
            ENDIF                                                       GCVOLT   1292
            MODCHG = .TRUE.                                             GCVOLT   1293
            IF(UMODE(JPOSN).EQ.'GAMMA') THEN                            GCVOLT   1294
               UMOD2(JPOSN) = 'ALPHA'                                   GCVOLT   1295
               USETP2(JPOSN) = ALP                                      GCVOLT   1296
            ENDIF                                                       GCVOLT   1297
            IF(UMOD2(JPOSN).EQ.'GAMMA') THEN                            GCVOLT   1298
               UMODE(JPOSN) = 'ALPHA'                                   GCVOLT   1299
               USETPT(JPOSN) = ALP                                      GCVOLT   1300
            ENDIF                                                       GCVOLT   1301
            IF(ICOMF(JPOSN).EQ.0) THEN                                  GCVOLT   1302
               ICOMF(JPOSN)=1                                           GCVOLT   1303
               WRITE (MSG(1),9000) TIMX,SUBNAM                          GCVOLT   1304
               WRITE (MSG(2),9100) DCCNAM(JPOSN)                        GCVOLT   1305
               WRITE (MSG(3),9262) ALP                                  GCVOLT   1306
               CALL PRTMSG(3)                                           GCVOLT   1307
            ENDIF                                                       GCVOLT   1308
         ELSE                                                           GCVOLT   1309
            ANG1 = ASIN(SINA)                                           GCVOLT   1310
            ANG2 = VACONV(JPOSN)                                        GCVOLT   1311
            ANG = ANG1 - ANG2                                           GCVOLT   1312
            IF(ANG .LT. - PII/2.0 .OR. ANG .GT. PII/2.0) THEN           GCVOLT   1313
               CALPHA(JPOSN) = PII - ANG1 - ANG2                        GCVOLT   1314
            ELSE                                                        GCVOLT   1315
               CALPHA(JPOSN) = ANG                                      GCVOLT   1316
            END IF                                                      GCVOLT   1317
            IF(ICOMF(JPOSN).EQ.1) THEN                                  GCVOLT   1318
               ICOMF(JPOSN)=0                                           GCVOLT   1319
               WRITE (MSG(1),9000) TIMX,SUBNAM                          GCVOLT   1320
               WRITE (MSG(2),9100) DCCNAM(JPOSN)                        GCVOLT   1321
               WRITE (MSG(3),9163)                                      GCVOLT   1322
               CALL PRTMSG(3)                                           GCVOLT   1323
            END IF                                                      GCVOLT   1324
         END IF                                                         GCVOLT   1325
      END IF                                                            GCVOLT   1326
C                                                                       GCVOLT   1327
C     DO NOT ALLOW NEGATIVE VOLTAGE ACROSS CONVERTER                    GCVOLT   1328
C                                                                       GCVOLT   1329
      IF(VDCONV(JPOSN).LT.0.0) THEN                                     GCVOLT   1330
         NEGCUR = .TRUE.                                                GCVOLT   1331
         SETP1=0.0                                                      GCVOLT   1332
         USETPT(JPOSN)=0.0                                              GCVOLT   1333
         UMODE(JPOSN)= 'BYPASS'                                         GCVOLT   1334
         IF(ICEXT(JPOSN).EQ.0) THEN                                     GCVOLT   1335
            ICEXT(JPOSN)=1                                              GCVOLT   1336
            WRITE (MSG(1),9000) TIMX,SUBNAM                             GCVOLT   1337
            WRITE (MSG(2),9170) DCCNAM(JPOSN)                           GCVOLT   1338
            WRITE (MSG(3),9182)                                         GCVOLT   1339
            CALL PRTMSG(3)                                              GCVOLT   1340
         ENDIF                                                          GCVOLT   1341
      ELSEIF(VDCONV(JPOSN).GT.0.0) THEN                                 GCVOLT   1342
         IF(ICEXT(JPOSN).EQ.1) THEN                                     GCVOLT   1343
            ICEXT(JPOSN)=0                                              GCVOLT   1344
            WRITE (MSG(1),9000) TIMX,SUBNAM                             GCVOLT   1345
            WRITE (MSG(2),9170) DCCNAM(JPOSN)                           GCVOLT   1346
            WRITE (MSG(3),9183)                                         GCVOLT   1347
            CALL PRTMSG(3)                                              GCVOLT   1348
         ENDIF                                                          GCVOLT   1349
      END IF                                                            GCVOLT   1350
C                                                                       GCVOLT   1351
      RETURN                                                            GCVOLT   1352
C                                                                       GCVOLT   1353
 9000 FORMAT(' *** WARNING AT TIME =',F10.4,5X,A)                       GCVOLT   1354
 9100 FORMAT(14X,'CONVERTER ',A)                                        GCVOLT   1355
 9101 FORMAT(14X,'ID =',F7.3,' KA  V0 =',F9.3,' KV  VD =',F9.3,' KV')   GCVOLT   1356
 9110 FORMAT(14X                                                        GCVOLT   1357
     *,'ALPHA ORDER LESS THAN ZERO DEGREES, ALPHA SET TO ZERO.')        GCVOLT   1358
 9111 FORMAT(14X                                                        GCVOLT   1359
     *,'ALPHA ORDER LESS THAN -90 DEGREES, ALPHA SET TO -90.')          GCVOLT   1360
 9120 FORMAT(14X                                                        GCVOLT   1361
     *,'ALPHA ORDER MORE THAN 180 DEGREES, FAILED COMMUTATION.')        GCVOLT   1362
 9121 FORMAT(14X                                                        GCVOLT   1363
     *,'ALPHA ORDER MORE THAN 90 DEGREES, ALPHA SET TO 90.')            GCVOLT   1364
 9140 FORMAT(14X                                                        GCVOLT   1365
     *,'CALCULATED GAMMA LESS THAN ZERO DEGREES, FAILED COMMUTATION.')  GCVOLT   1366
 9141 FORMAT(14X                                                        GCVOLT   1367
     *,'CALCULATED GAMMA LESS THAN -1 PER UNIT, GAMMA SET TO -1.')      GCVOLT   1368
 9160 FORMAT(14X                                                        GCVOLT   1369
     *,'CALCULATED GAMMA MORE THAN 180 DEGREES, ALPHA SET TO ZERO.')    GCVOLT   1370
 9161 FORMAT(14X                                                        GCVOLT   1371
     *,'CALCULATED GAMMA MORE THAN 1 PER UNIT, GAMMA SET TO 1.')        GCVOLT   1372
 9163 FORMAT(14X                                                        GCVOLT   1373
     *,'CALCULATED ALPHA OR GAMMA LEAVES PREVIOUSLY SET LIMIT.')        GCVOLT   1374
 9170 FORMAT(14X,'CONVERTER ',A,' MAY EXPERIENCE')                      GCVOLT   1375
 9180 FORMAT(14X                                                        GCVOLT   1376
     *,'A CHANGE IN ALPHA DUE TO CURRENT BEING EXTINGUISHED.')          GCVOLT   1377
 9181 FORMAT(14X                                                        GCVOLT   1378
     *,'A CHANGE IN ALPHA DUE TO CURRENT BEING RESTORED.')              GCVOLT   1379
 9182 FORMAT(14X                                                        GCVOLT   1380
     *,'A CHANGE IN ALPHA/GAMMA DUE TO VOLTAGE BEING VANISHED.')        GCVOLT   1381
 9183 FORMAT(14X                                                        GCVOLT   1382
     *,'A CHANGE IN ALPHA/GAMMA DUE TO VOLTAGE BEING RESTORED.')        GCVOLT   1383
 9200 FORMAT(14X                                                        GCVOLT   1384
     *,'GAMMA ORDER LESS THAN ZERO DEGREES, FAILED COMMUTATION.')       GCVOLT   1385
 9201 FORMAT(14X                                                        GCVOLT   1386
     *,'GAMMA ORDER LESS THAN -1 PER UNIT, GAMMA SET TO -1.')           GCVOLT   1387
 9220 FORMAT(14X                                                        GCVOLT   1388
     *,'GAMMA ORDER MORE THAN 180 DEGREES, ALPHA SET TO ZERO.')         GCVOLT   1389
 9221 FORMAT(14X                                                        GCVOLT   1390
     *,'GAMMA ORDER MORE THAN 1 PER UNIT, GAMMA SET TO 1.')             GCVOLT   1391
 9240 FORMAT(14X                                                        GCVOLT   1392
     *,'CALCULATED ALPHA LESS THAN ZERO DEGREES, ALPHA SET TO ZERO.')   GCVOLT   1393
 9241 FORMAT(14X                                                        GCVOLT   1394
     *,'CALCULATED SINE LESS THAN -1.0, ALPHA SET TO ',F6.2,' DEG.')    GCVOLT   1395
 9260 FORMAT(14X                                                        GCVOLT   1396
     *,'CALCULATED ALPHA MORE THAN 180 DEGREES, FAILED COMMUTATION.')   GCVOLT   1397
 9261 FORMAT(14X                                                        GCVOLT   1398
     *,'GAMMA LARGER THAN ZERO DEGREES, COMMUTATION FAILURE ENDED.')    GCVOLT   1399
 9262 FORMAT(14X                                                        GCVOLT   1400
     *,'CALCULATED SINE LARGER THAN 1.0, ALPHA SET TO ',F6.2,' DEG.')   GCVOLT   1401
C                                                                       GCVOLT   1402
      END                                                               GCVOLT   1403
