CFPRIME ASVC3                                                           ASVC3       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 ASVC3(IDMSN,KSELF,EPD,EPQ)                             ASVC3       3
CD                                                                      ASVC3       4
CD    TO FORMULATE THE JACOBIAN MATRICES OF TYPE 3 SVC.                 ASVC3       5
CD                                                                      ASVC3       6
      INCLUDE 'PARX.INS'                                                ASVC3       7
      INCLUDE 'CNB8.INS'                                                ASVC3       8
      INCLUDE 'CNB19.INS'                                               ASVC3       9
      INCLUDE 'CNEXC.INS'                                               ASVC3      10
      INCLUDE 'CNSVS.INS'                                               ASVC3      11
      INCLUDE 'CNUNIT.INS'                                              ASVC3      12
      INCLUDE 'CNVOLT.INS'                                              ASVC3      13
      INCLUDE 'CNYVAR.INS'                                              ASVC3      14
      INCLUDE 'CNPARX.INS'                                              ASVC3      15
      INCLUDE 'CNMDAT.INS'                                              ASVC3      16
      INCLUDE 'CNXSTA.INS'                                              ASVC3      17
      INCLUDE 'CNMSTA.INS'                                              ASVC3      18
      INCLUDE 'CNABAK.INS'                                              ASVC3      19
      INCLUDE 'CNMSG.INS'                                               ASVC3      20
C                                                                       ASVC3      21
      NXS=0                                                             ASVC3      22
      VSR1=VSR/VSM                                                      ASVC3      23
      VSI1=VSI/VSM                                                      ASVC3      24
C                                                                       ASVC3      25
C     SET UP SENSING BUS INFORMATION                                    ASVC3      26
C                                                                       ASVC3      27
      ICOLBV=0                                                          ASVC3      28
      MT1=IDDAT(JS+28)                                                  ASVC3      29
C                                                                       ASVC3      30
C     FIRST SENSING SIGNAL                                              ASVC3      31
C                                                                       ASVC3      32
      GOTO (10,20,30), MT1+1                                            ASVC3      33
C                                                                       ASVC3      34
C     LINE POWER                                                        ASVC3      35
C                                                                       ASVC3      36
   10 NSEN1=IDDAT(JS+30)                                                ASVC3      37
      NSEN1S=IDDAT(JS+31)                                               ASVC3      38
C                                                                       ASVC3      39
      VFD=REAL(VOLT(NSEN1))                                             ASVC3      40
      VFQ=AIMAG(VOLT(NSEN1))                                            ASVC3      41
      VTD=REAL(VOLT(NSEN1S))                                            ASVC3      42
      VTQ=AIMAG(VOLT(NSEN1S))                                           ASVC3      43
      GFT=0.0                                                           ASVC3      44
      BFT=0.0                                                           ASVC3      45
      MLIN=IDDAT(JS+8)                                                  ASVC3      46
      DO 15 I=1,MLIN                                                    ASVC3      47
         LOC=IDDAT(JS+45+2*I)                                           ASVC3      48
         CALL GETIMP(GJK,BJK,LOC)                                       ASVC3      49
         GFT=GFT+GJK                                                    ASVC3      50
         BFT=BFT-BJK                                                    ASVC3      51
   15 CONTINUE                                                          ASVC3      52
      ALP1=GFT*(2.0*VFD-VTD)+BFT*VTQ                                    ASVC3      53
      ALP2=GFT*(2.0*VFQ-VTQ)-BFT*VTD                                    ASVC3      54
      ALP3=-GFT*VFD-BFT*VFQ                                             ASVC3      55
      ALP4=-GFT*VFQ+BFT*VFD                                             ASVC3      56
C                                                                       ASVC3      57
      ICOLBV=2                                                          ASVC3      58
      NBR(1)=NSEN1                                                      ASVC3      59
      NBR(2)=NSEN1S                                                     ASVC3      60
      NSEN1=1                                                           ASVC3      61
      NSEN1S=2                                                          ASVC3      62
      GOTO 40                                                           ASVC3      63
C                                                                       ASVC3      64
C     BUS FREQUENCY                                                     ASVC3      65
C                                                                       ASVC3      66
   20 NXS=NXS+1                                                         ASVC3      67
      TFI=DDAT(JS+30)                                                   ASVC3      68
      A(NXS,NXS)=-TFI                                                   ASVC3      69
C                                                                       ASVC3      70
      NSEN1=IDDAT(JS+31)                                                ASVC3      71
      VSENR=REAL(VOLT(NSEN1))                                           ASVC3      72
      VSENI=AIMAG(VOLT(NSEN1))                                          ASVC3      73
      VSENM2=VSENR*VSENR+VSENI*VSENI                                    ASVC3      74
      ALP2=-VSENI*TFI/VSENM2                                            ASVC3      75
      ALP3=VSENR*TFI/VSENM2                                             ASVC3      76
C                                                                       ASVC3      77
      ICOLBV=1                                                          ASVC3      78
      NBR(1)=NSEN1                                                      ASVC3      79
      NSEN1=1                                                           ASVC3      80
      B(NXS,1)=ALP2                                                     ASVC3      81
      B(NXS,2)=ALP3                                                     ASVC3      82
C                                                                       ASVC3      83
      ALP1=TFI/WXBASE                                                   ASVC3      84
      ALP2=ALP2/WXBASE                                                  ASVC3      85
      ALP3=ALP3/WXBASE                                                  ASVC3      86
      ALP4=0.0                                                          ASVC3      87
      GOTO 40                                                           ASVC3      88
C                                                                       ASVC3      89
C     PACC INPUT - NOT ALLOWED FOR IMPLICIT INTEGRATION METHODS         ASVC3      90
C                                                                       ASVC3      91
   30 WRITE(MSG(1),1000)                                                ASVC3      92
      WRITE(MSG(2),1010)                                                ASVC3      93
      WRITE(MSG(3),1020)                                                ASVC3      94
      CALL PRTMSG(3)                                                    ASVC3      95
      MSG(1)=' SVC: INPUT TYPE ERROR. SEE RESULT FILE FOR DETAILS'      ASVC3      96
      CALL ASTOP(MSG(1),51)                                             ASVC3      97
C                                                                       ASVC3      98
   40 CONTINUE                                                          ASVC3      99
C                                                                       ASVC3     100
C     SECOND SENSING SIGNAL                                             ASVC3     101
C                                                                       ASVC3     102
      NSEN2=0                                                           ASVC3     103
      MT2=IDDAT(JS+29)                                                  ASVC3     104
C                                                                       ASVC3     105
      GOTO (50,60,70), MT2+1                                            ASVC3     106
C                                                                       ASVC3     107
C     VSEN                                                              ASVC3     108
C                                                                       ASVC3     109
   50 NSEN2=IDDAT(JS+10)                                                ASVC3     110
      IF (NSEN2.EQ.NBR(1)) THEN                                         ASVC3     111
         NSEN2=1                                                        ASVC3     112
      ELSE IF (MT1.EQ.0.AND.NSEN2.EQ.NBR(2)) THEN                       ASVC3     113
         NSEN2=2                                                        ASVC3     114
      ELSE                                                              ASVC3     115
         ICOLBV=ICOLBV+1                                                ASVC3     116
         NBR(ICOLBV)=NSEN2                                              ASVC3     117
         NSEN2=3                                                        ASVC3     118
      END IF                                                            ASVC3     119
      BETA1=0.0                                                         ASVC3     120
      BETA2=VSR1                                                        ASVC3     121
      BETA3=VSI1                                                        ASVC3     122
      GOTO 80                                                           ASVC3     123
C                                                                       ASVC3     124
C     QSVC                                                              ASVC3     125
C                                                                       ASVC3     126
   60 IF (KSELF.EQ.NBR(1)) THEN                                         ASVC3     127
         NSEN2=1                                                        ASVC3     128
      ELSE IF (MT1.EQ.0.AND.KSELF.EQ.NBR(2)) THEN                       ASVC3     129
         NSEN2=2                                                        ASVC3     130
      ELSE                                                              ASVC3     131
         ICOLBV=ICOLBV+1                                                ASVC3     132
         NBR(ICOLBV)=KSELF                                              ASVC3     133
         NSEN2=3                                                        ASVC3     134
      END IF                                                            ASVC3     135
      BETA1=EPD*EPD+EPQ*EPQ                                             ASVC3     136
      BETA2=2.0*BSVCS*EPD                                               ASVC3     137
      BETA3=2.0*BSVCS*EPQ                                               ASVC3     138
      GOTO 80                                                           ASVC3     139
C                                                                       ASVC3     140
C     ISVC                                                              ASVC3     141
C                                                                       ASVC3     142
   70 IF (KSELF.EQ.NBR(1)) THEN                                         ASVC3     143
         NSEN2=1                                                        ASVC3     144
      ELSE IF (MT1.EQ.0.AND.KSELF.EQ.NBR(2)) THEN                       ASVC3     145
         NSEN2=2                                                        ASVC3     146
      ELSE                                                              ASVC3     147
         ICOLBV=ICOLBV+1                                                ASVC3     148
         NBR(ICOLBV)=KSELF                                              ASVC3     149
         NSEN2=3                                                        ASVC3     150
      END IF                                                            ASVC3     151
      BETA1=SQRT(EPD*EPD+EPQ*EPQ)                                       ASVC3     152
      BETA2=BSVCS*EPD/BETA1                                             ASVC3     153
      BETA3=BSVCS*EPQ/BETA1                                             ASVC3     154
C                                                                       ASVC3     155
   80 CONTINUE                                                          ASVC3     156
C                                                                       ASVC3     157
C     THIRD INPUT SIGNAL                                                ASVC3     158
C                                                                       ASVC3     159
      NSEN3=IDDAT(JS+10)                                                ASVC3     160
      DO 90 I=1,ICOLBV                                                  ASVC3     161
         IF (NSEN3.EQ.NBR(I)) THEN                                      ASVC3     162
            NSEN3=I                                                     ASVC3     163
            GOTO 100                                                    ASVC3     164
         END IF                                                         ASVC3     165
   90 CONTINUE                                                          ASVC3     166
      ICOLBV=ICOLBV+1                                                   ASVC3     167
      NBR(ICOLBV)=NSEN3                                                 ASVC3     168
      NSEN3=ICOLBV                                                      ASVC3     169
  100 CONTINUE                                                          ASVC3     170
      GAMA1=VSR1                                                        ASVC3     171
      GAMA2=VSI1                                                        ASVC3     172
C                                                                       ASVC3     173
C     TS7 BLOCK                                                         ASVC3     174
C                                                                       ASVC3     175
      CKS1=DDAT(JS+33)                                                  ASVC3     176
      IF (IDDAT(JS+34).EQ.0) THEN                                       ASVC3     177
C                                                                       ASVC3     178
         ALP1=ALP1*CKS1                                                 ASVC3     179
         ALP2=ALP2*CKS1                                                 ASVC3     180
         ALP3=ALP3*CKS1                                                 ASVC3     181
         ALP4=ALP4*CKS1                                                 ASVC3     182
C                                                                       ASVC3     183
      ELSE                                                              ASVC3     184
C                                                                       ASVC3     185
         NXS=NXS+1                                                      ASVC3     186
         TS7I=DDAT(JS+34)                                               ASVC3     187
         A(NXS,NXS)=-TS7I                                               ASVC3     188
C                                                                       ASVC3     189
         WS1=CKS1*TS7I                                                  ASVC3     190
         IF (MT1.EQ.0) THEN                                             ASVC3     191
C                                                                       ASVC3     192
            B(NXS,1)=ALP1*WS1                                           ASVC3     193
            B(NXS,2)=ALP2*WS1                                           ASVC3     194
            B(NXS,3)=ALP3*WS1                                           ASVC3     195
            B(NXS,4)=ALP4*WS1                                           ASVC3     196
C                                                                       ASVC3     197
         ELSE IF (MT1.EQ.1) THEN                                        ASVC3     198
C                                                                       ASVC3     199
            A(NXS,NXS-1)=-ALP1*WS1                                      ASVC3     200
            B(NXS,1)=ALP2*WS1                                           ASVC3     201
            B(NXS,2)=ALP3*WS1                                           ASVC3     202
C                                                                       ASVC3     203
         END IF                                                         ASVC3     204
C                                                                       ASVC3     205
      END IF                                                            ASVC3     206
C                                                                       ASVC3     207
C     TS8, TS9 BLOCK                                                    ASVC3     208
C                                                                       ASVC3     209
      IF (IDDAT(JS+36).EQ.0) THEN                                       ASVC3     210
C                                                                       ASVC3     211
         T8T9=1.0                                                       ASVC3     212
C                                                                       ASVC3     213
      ELSE                                                              ASVC3     214
C                                                                       ASVC3     215
         NXS=NXS+1                                                      ASVC3     216
         TS9I=DDAT(JS+36)                                               ASVC3     217
         T8T9=DDAT(JS+35)*TS9I                                          ASVC3     218
         A(NXS,NXS)=-TS9I                                               ASVC3     219
         IF (IDDAT(JS+34).EQ.0) THEN                                    ASVC3     220
C                                                                       ASVC3     221
            IF (MT1.EQ.0) THEN                                          ASVC3     222
C                                                                       ASVC3     223
               B(NXS,1)=ALP1*TS9I                                       ASVC3     224
               B(NXS,2)=ALP2*TS9I                                       ASVC3     225
               B(NXS,3)=ALP3*TS9I                                       ASVC3     226
               B(NXS,4)=ALP4*TS9I                                       ASVC3     227
               ALP1=ALP1*T8T9                                           ASVC3     228
               ALP2=ALP2*T8T9                                           ASVC3     229
               ALP3=ALP3*T8T9                                           ASVC3     230
               ALP4=ALP4*T8T9                                           ASVC3     231
C                                                                       ASVC3     232
            ELSE IF (MT1.EQ.1) THEN                                     ASVC3     233
C                                                                       ASVC3     234
               A(NXS,NXS-1)=-ALP1*TS9I                                  ASVC3     235
               B(NXS,1)=ALP2*TS9I                                       ASVC3     236
               B(NXS,2)=ALP3*TS9I                                       ASVC3     237
               ALP1=ALP1*T8T9                                           ASVC3     238
               ALP2=ALP2*T8T9                                           ASVC3     239
               ALP3=ALP3*T8T9                                           ASVC3     240
C                                                                       ASVC3     241
            END IF                                                      ASVC3     242
C                                                                       ASVC3     243
         ELSE                                                           ASVC3     244
C                                                                       ASVC3     245
            A(NXS,NXS-1)=TS9I                                           ASVC3     246
C                                                                       ASVC3     247
         END IF                                                         ASVC3     248
C                                                                       ASVC3     249
      END IF                                                            ASVC3     250
C                                                                       ASVC3     251
C     TS10 BLOCK                                                        ASVC3     252
C                                                                       ASVC3     253
      CKS2=DDAT(JS+40)                                                  ASVC3     254
      IF (IDDAT(JS+41).EQ.0) THEN                                       ASVC3     255
C                                                                       ASVC3     256
         BETA1=BETA1*CKS2                                               ASVC3     257
         BETA2=BETA2*CKS2                                               ASVC3     258
         BETA3=BETA3*CKS2                                               ASVC3     259
C                                                                       ASVC3     260
      ELSE                                                              ASVC3     261
C                                                                       ASVC3     262
         NXS=NXS+1                                                      ASVC3     263
         TS10I=DDAT(JS+41)                                              ASVC3     264
         A(NXS,NXS)=-TS10I                                              ASVC3     265
C                                                                       ASVC3     266
         WS1=CKS2*TS10I                                                 ASVC3     267
         IWS1=2*NSEN2                                                   ASVC3     268
         A(NXS,IDMSN)=BETA1*WS1                                         ASVC3     269
         B(NXS,IWS1-1)=BETA2*WS1                                        ASVC3     270
         B(NXS,IWS1)=BETA3*WS1                                          ASVC3     271
C                                                                       ASVC3     272
      END IF                                                            ASVC3     273
C                                                                       ASVC3     274
C     TS11, TS12 BLOCK                                                  ASVC3     275
C                                                                       ASVC3     276
      IF (IDDAT(JS+43).EQ.0) THEN                                       ASVC3     277
C                                                                       ASVC3     278
         T11T12=1.0                                                     ASVC3     279
C                                                                       ASVC3     280
      ELSE                                                              ASVC3     281
C                                                                       ASVC3     282
         NXS=NXS+1                                                      ASVC3     283
         TS12I=DDAT(JS+43)                                              ASVC3     284
         T11T12=DDAT(JS+42)*TS12I                                       ASVC3     285
         A(NXS,NXS)=-TS12I                                              ASVC3     286
         IF (IDDAT(JS+41).EQ.0) THEN                                    ASVC3     287
C                                                                       ASVC3     288
            IWS1=2*NSEN2                                                ASVC3     289
            A(NXS,IDMSN)=BETA1*TS12I                                    ASVC3     290
            B(NXS,IWS1-1)=BETA2*TS12I                                   ASVC3     291
            B(NXS,IWS1)=BETA3*TS12I                                     ASVC3     292
            BETA1=BETA1*T11T12                                          ASVC3     293
            BETA2=BETA2*T11T12                                          ASVC3     294
            BETA3=BETA3*T11T12                                          ASVC3     295
C                                                                       ASVC3     296
         ELSE                                                           ASVC3     297
C                                                                       ASVC3     298
            A(NXS,NXS-1)=TS12I                                          ASVC3     299
C                                                                       ASVC3     300
         END IF                                                         ASVC3     301
C                                                                       ASVC3     302
      END IF                                                            ASVC3     303
C                                                                       ASVC3     304
C     TS13 BLOCK (COMPULSORY)                                           ASVC3     305
C                                                                       ASVC3     306
      NXS=NXS+1                                                         ASVC3     307
      TS13I=DDAT(JS+37)                                                 ASVC3     308
      A(NXS,NXS)=-TS13I                                                 ASVC3     309
      CALL ASVC3U(NXS,NXS,NSEN2,IDMSN,BETA1,BETA2,BETA3,                ASVC3     310
     *            TS13I,T8T9,T11T12)                                    ASVC3     311
C                                                                       ASVC3     312
C     TS1 BLOCK                                                         ASVC3     313
C                                                                       ASVC3     314
      IF (IDDAT(JS+1).NE.0) THEN                                        ASVC3     315
C                                                                       ASVC3     316
         NXS=NXS+1                                                      ASVC3     317
         TS1I=DDAT(JS+1)                                                ASVC3     318
         A(NXS,NXS)=-TS1I                                               ASVC3     319
C                                                                       ASVC3     320
         IWS1=2*NSEN3                                                   ASVC3     321
         B(NXS,IWS1-1)=GAMA1*TS1I                                       ASVC3     322
         B(NXS,IWS1)=GAMA2*TS1I                                         ASVC3     323
C                                                                       ASVC3     324
      END IF                                                            ASVC3     325
C                                                                       ASVC3     326
C     TS2, TS3 BLOCK                                                    ASVC3     327
C                                                                       ASVC3     328
      GAIN=DDAT(JS+38)                                                  ASVC3     329
      IF (IDDAT(JS+4).EQ.0) THEN                                        ASVC3     330
C                                                                       ASVC3     331
         T2T3=1.0                                                       ASVC3     332
C                                                                       ASVC3     333
      ELSE                                                              ASVC3     334
C                                                                       ASVC3     335
         NXS=NXS+1                                                      ASVC3     336
         TS3I=DDAT(JS+4)                                                ASVC3     337
         T2T3=DDAT(JS+3)*TS3I                                           ASVC3     338
         A(NXS,NXS)=-TS3I                                               ASVC3     339
         GAIN1=GAIN*TS3I                                                ASVC3     340
C                                                                       ASVC3     341
         NXS1=NXS                                                       ASVC3     342
         IF (IDDAT(JS+1).EQ.0) THEN                                     ASVC3     343
C                                                                       ASVC3     344
            IWS1=2*NSEN3                                                ASVC3     345
            B(NXS,IWS1-1)=GAMA1*TS3I                                    ASVC3     346
            B(NXS,IWS1)=GAMA2*TS3I                                      ASVC3     347
            GAMA1=GAMA1*T2T3                                            ASVC3     348
            GAMA2=GAMA2*T2T3                                            ASVC3     349
C                                                                       ASVC3     350
         ELSE                                                           ASVC3     351
C                                                                       ASVC3     352
            NXS1=NXS1-1                                                 ASVC3     353
            A(NXS,NXS1)=TS3I                                            ASVC3     354
C                                                                       ASVC3     355
         END IF                                                         ASVC3     356
C                                                                       ASVC3     357
         NXS1=NXS1-1                                                    ASVC3     358
         A(NXS,NXS1)=-GAIN1                                             ASVC3     359
         CALL ASVC3U(NXS,NXS1,NSEN2,IDMSN,BETA1,BETA2,BETA3,            ASVC3     360
     *               GAIN1,T8T9,T11T12)                                 ASVC3     361
         GAIN=GAIN*T2T3                                                 ASVC3     362
C                                                                       ASVC3     363
      END IF                                                            ASVC3     364
C                                                                       ASVC3     365
C     TS4, TS5 BLOCK                                                    ASVC3     366
C                                                                       ASVC3     367
      IF (IDDAT(JS+6).EQ.0) THEN                                        ASVC3     368
C                                                                       ASVC3     369
         T4T5=1.0                                                       ASVC3     370
C                                                                       ASVC3     371
      ELSE                                                              ASVC3     372
C                                                                       ASVC3     373
         NXS=NXS+1                                                      ASVC3     374
         TS5I=DDAT(JS+6)                                                ASVC3     375
         T4T5=DDAT(JS+5)*TS5I                                           ASVC3     376
         A(NXS,NXS)=-TS5I                                               ASVC3     377
         GAIN1=GAIN*TS5I                                                ASVC3     378
C                                                                       ASVC3     379
         NXS1=NXS                                                       ASVC3     380
         IF (IDDAT(JS+4).NE.0) THEN                                     ASVC3     381
C                                                                       ASVC3     382
            NXS1=NXS1-1                                                 ASVC3     383
            A(NXS,NXS1)=TS5I*(1.0-T2T3)                                 ASVC3     384
C                                                                       ASVC3     385
         END IF                                                         ASVC3     386
C                                                                       ASVC3     387
         IF (IDDAT(JS+1).EQ.0) THEN                                     ASVC3     388
C                                                                       ASVC3     389
            IWS1=2*NSEN3                                                ASVC3     390
            B(NXS,IWS1-1)=GAMA1*TS5I                                    ASVC3     391
            B(NXS,IWS1)=GAMA2*TS5I                                      ASVC3     392
            GAMA1=GAMA1*T4T5                                            ASVC3     393
            GAMA2=GAMA2*T4T5                                            ASVC3     394
C                                                                       ASVC3     395
         ELSE                                                           ASVC3     396
C                                                                       ASVC3     397
            NXS1=NXS1-1                                                 ASVC3     398
            A(NXS,NXS1)=TS5I*T2T3                                       ASVC3     399
C                                                                       ASVC3     400
         END IF                                                         ASVC3     401
C                                                                       ASVC3     402
         NXS1=NXS1-1                                                    ASVC3     403
         A(NXS,NXS1)=-GAIN1                                             ASVC3     404
         CALL ASVC3U(NXS,NXS1,NSEN2,IDMSN,BETA1,BETA2,BETA3,            ASVC3     405
     *               GAIN1,T8T9,T11T12)                                 ASVC3     406
         GAIN=GAIN*T4T5                                                 ASVC3     407
C                                                                       ASVC3     408
      END IF                                                            ASVC3     409
C                                                                       ASVC3     410
C     TS6 BLOCK                                                         ASVC3     411
C                                                                       ASVC3     412
      CSVC=DDAT(JS+7)                                                   ASVC3     413
      GAIN=GAIN*CSVC                                                    ASVC3     414
      GAMA1=GAMA1*CSVC                                                  ASVC3     415
      GAMA2=GAMA2*CSVC                                                  ASVC3     416
      IF (IDDAT(JS+18).NE.0) THEN                                       ASVC3     417
C                                                                       ASVC3     418
         NXS=NXS+1                                                      ASVC3     419
         TS6I=DDAT(JS+18)                                               ASVC3     420
         CSVCT6=CSVC*TS6I                                               ASVC3     421
         A(NXS,NXS)=-TS6I                                               ASVC3     422
         GAIN1=GAIN*TS6I                                                ASVC3     423
C                                                                       ASVC3     424
         NXS1=NXS                                                       ASVC3     425
         IF (IDDAT(JS+6).NE.0) THEN                                     ASVC3     426
C                                                                       ASVC3     427
            NXS1=NXS1-1                                                 ASVC3     428
            A(NXS,NXS1)=CSVCT6*(1.0-T4T5)                               ASVC3     429
C                                                                       ASVC3     430
         END IF                                                         ASVC3     431
C                                                                       ASVC3     432
         IF (IDDAT(JS+4).NE.0) THEN                                     ASVC3     433
C                                                                       ASVC3     434
            NXS1=NXS1-1                                                 ASVC3     435
            A(NXS,NXS1)=CSVCT6*T4T5*(1.0-T2T3)                          ASVC3     436
C                                                                       ASVC3     437
         END IF                                                         ASVC3     438
C                                                                       ASVC3     439
         IF (IDDAT(JS+1).EQ.0) THEN                                     ASVC3     440
C                                                                       ASVC3     441
            IWS1=2*NSEN3                                                ASVC3     442
            B(NXS,IWS1-1)=GAMA1*TS6I                                    ASVC3     443
            B(NXS,IWS1)=GAMA2*TS6I                                      ASVC3     444
C                                                                       ASVC3     445
         ELSE                                                           ASVC3     446
C                                                                       ASVC3     447
            NXS1=NXS1-1                                                 ASVC3     448
            A(NXS,NXS1)=CSVCT6*T4T5*T2T3                                ASVC3     449
C                                                                       ASVC3     450
         END IF                                                         ASVC3     451
C                                                                       ASVC3     452
         NXS1=NXS1-1                                                    ASVC3     453
         A(NXS,NXS1)=-GAIN1                                             ASVC3     454
         CALL ASVC3U(NXS,NXS1,NSEN2,IDMSN,BETA1,BETA2,BETA3,            ASVC3     455
     *               GAIN1,T8T9,T11T12)                                 ASVC3     456
C                                                                       ASVC3     457
      END IF                                                            ASVC3     458
C                                                                       ASVC3     459
C     AK MATRIX                                                         ASVC3     460
C                                                                       ASVC3     461
      AK(1,IDMSN)=-EPQ*BSRAT                                            ASVC3     462
      AK(2,IDMSN)=EPD*BSRAT                                             ASVC3     463
C                                                                       ASVC3     464
C     YD MATRIX                                                         ASVC3     465
C                                                                       ASVC3     466
      YD(1,2)=YD(1,2)+BSVCS                                             ASVC3     467
      YD(2,1)=YD(2,1)-BSVCS                                             ASVC3     468
C                                                                       ASVC3     469
 1000 FORMAT(                                                           ASVC3     470
     *' *** ERROR  SVC INPUT ERROR PACC (MT1 =2) IS NOT AVAILABLE')     ASVC3     471
 1010 FORMAT(12X                                                        ASVC3     472
     *,'AS INPUT SIGNALS IN THE IMPLICIT INTEGRATION METHOD.')          ASVC3     473
 1020 FORMAT(12X                                                        ASVC3     474
     *,'SELECT AN EXPLICIT INTEGRATION METHOD AND TRY AGAIN.')          ASVC3     475
C                                                                       ASVC3     476
      RETURN                                                            ASVC3     477
      END                                                               ASVC3     478
C                                                                       ASVC3     479
C                                                                       ASVC3     480
      SUBROUTINE ASVC3U(NXS,NXS1,NSEN2,IDMSN,BETA1,BETA2,BETA3,         ASVC3     481
     *                  GAIN,T8T9,T11T12)                               ASVC3     482
CD                                                                      ASVC3     483
CD    TO PROCESS SOME INDIVIDUAL CONTROL BLOCKS IN TYPE 3 SVC WHEN      ASVC3     484
CD    FORMULATING THE JACOBIAN MATRICES.                                ASVC3     485
CD                                                                      ASVC3     486
      INCLUDE 'PARX.INS'                                                ASVC3     487
      INCLUDE 'CNB8.INS'                                                ASVC3     488
      INCLUDE 'CNEXC.INS'                                               ASVC3     489
      INCLUDE 'CNSVS.INS'                                               ASVC3     490
      INCLUDE 'CNYVAR.INS'                                              ASVC3     491
      INCLUDE 'CNPARX.INS'                                              ASVC3     492
      INCLUDE 'CNMDAT.INS'                                              ASVC3     493
      INCLUDE 'CNXSTA.INS'                                              ASVC3     494
      INCLUDE 'CNMSTA.INS'                                              ASVC3     495
C                                                                       ASVC3     496
      INCLUDE 'CNABAK.INS'                                              ASVC3     497
C                                                                       ASVC3     498
      NXS2=NXS1                                                         ASVC3     499
C                                                                       ASVC3     500
      IF (IDDAT(JS+43).NE.0) THEN                                       ASVC3     501
C                                                                       ASVC3     502
         NXS2=NXS2-1                                                    ASVC3     503
         A(NXS,NXS2)=GAIN*(1.0-T11T12)                                  ASVC3     504
C                                                                       ASVC3     505
      END IF                                                            ASVC3     506
C                                                                       ASVC3     507
      IF (IDDAT(JS+41).EQ.0) THEN                                       ASVC3     508
C                                                                       ASVC3     509
         IWS1=2*NSEN2                                                   ASVC3     510
         A(NXS,IDMSN)=A(NXS,IDMSN)+BETA1*GAIN                           ASVC3     511
         B(NXS,IWS1-1)=B(NXS,IWS1-1)+BETA2*GAIN                         ASVC3     512
         B(NXS,IWS1)=B(NXS,IWS1)+BETA3*GAIN                             ASVC3     513
C                                                                       ASVC3     514
      ELSE                                                              ASVC3     515
C                                                                       ASVC3     516
         NXS2=NXS2-1                                                    ASVC3     517
         A(NXS,NXS2)=GAIN*T11T12                                        ASVC3     518
C                                                                       ASVC3     519
      END IF                                                            ASVC3     520
C                                                                       ASVC3     521
      IF (IDDAT(JS+36).NE.0) THEN                                       ASVC3     522
C                                                                       ASVC3     523
         NXS2=NXS2-1                                                    ASVC3     524
         A(NXS,NXS2)=GAIN*(1.0-T8T9)                                    ASVC3     525
C                                                                       ASVC3     526
      END IF                                                            ASVC3     527
C                                                                       ASVC3     528
      IF (IDDAT(JS+34).EQ.0) THEN                                       ASVC3     529
C                                                                       ASVC3     530
         IF (MT1.EQ.0) THEN                                             ASVC3     531
C                                                                       ASVC3     532
            B(NXS,1)=B(NXS,1)+ALP1*GAIN                                 ASVC3     533
            B(NXS,2)=B(NXS,2)+ALP2*GAIN                                 ASVC3     534
            B(NXS,3)=B(NXS,3)+ALP3*GAIN                                 ASVC3     535
            B(NXS,4)=B(NXS,4)+ALP4*GAIN                                 ASVC3     536
C                                                                       ASVC3     537
         ELSE IF (MT1.EQ.1) THEN                                        ASVC3     538
C                                                                       ASVC3     539
            NXS2=NXS2-1                                                 ASVC3     540
            A(NXS,NXS2)=-ALP1*GAIN                                      ASVC3     541
            B(NXS,1)=B(NXS,1)+ALP2*GAIN                                 ASVC3     542
            B(NXS,2)=B(NXS,2)+ALP3*GAIN                                 ASVC3     543
C                                                                       ASVC3     544
         END IF                                                         ASVC3     545
C                                                                       ASVC3     546
      ELSE                                                              ASVC3     547
C                                                                       ASVC3     548
         NXS2=NXS2-1                                                    ASVC3     549
         A(NXS,NXS2)=GAIN*T8T9                                          ASVC3     550
C                                                                       ASVC3     551
      END IF                                                            ASVC3     552
C                                                                       ASVC3     553
      RETURN                                                            ASVC3     554
      END                                                               ASVC3     555
