CFPRIME MOTOLN                                                          MOTOLN      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 MOTOLN(IPATH,K)                                        MOTOLN      3
CD                                                                      MOTOLN      4
CD    TO FORMULATE JACOBIAN MATRICES OF INDUCTION MOTOR (ALL TYPES) FOR MOTOLN      5
CD    USE IN IMPLICIT INTEGRATION METHOD.                               MOTOLN      6
CD                                                                      MOTOLN      7
      INCLUDE 'PARX.INS'                                                MOTOLN      8
      INCLUDE 'CNPT.INS'                                                MOTOLN      9
      INCLUDE 'CNB4.INS'                                                MOTOLN     10
      INCLUDE 'CNB9.INS'                                                MOTOLN     11
      INCLUDE 'CNB19.INS'                                               MOTOLN     12
      INCLUDE 'CNMPAR.INS'                                              MOTOLN     13
      INCLUDE 'CNPARX.INS'                                              MOTOLN     14
      INCLUDE 'CNFLAG.INS'                                              MOTOLN     15
      INCLUDE 'CNJCOB.INS'                                              MOTOLN     16
      INCLUDE 'CNIMPR.INS'                                              MOTOLN     17
      INCLUDE 'CNIPTR.INS'                                              MOTOLN     18
      INCLUDE 'CNXSTA.INS'                                              MOTOLN     19
      INCLUDE 'CNQSTA.INS'                                              MOTOLN     20
      INCLUDE 'CNZSTA.INS'                                              MOTOLN     21
      INCLUDE 'CNMDAT.INS'                                              MOTOLN     22
      INCLUDE 'CNVOLT.INS'                                              MOTOLN     23
      INCLUDE 'CNMYVA.INS'                                              MOTOLN     24
      INCLUDE 'CNYVAR.INS'                                              MOTOLN     25
      INCLUDE 'CNABAK.INS'                                              MOTOLN     26
C                                                                       MOTOLN     27
      LDEB=.FALSE.                                                      MOTOLN     28
C                                                                       MOTOLN     29
      DXLRBS=0.0                                                        MOTOLN     30
      DRRBYS=0.0                                                        MOTOLN     31
      RLR=0.0                                                           MOTOLN     32
      XS=0.0                                                            MOTOLN     33
      XLR=0.0                                                           MOTOLN     34
C                                                                       MOTOLN     35
      I=NMOLD(K)                                                        MOTOLN     36
      IF (NTHM(2,I).EQ.0) RETURN                                        MOTOLN     37
      JM=JMDAT(K)                                                       MOTOLN     38
      JZT=JXIMO(K)                                                      MOTOLN     39
      JY=JVIMO(K)                                                       MOTOLN     40
      MOTYPK=IDDAT(JM+1)                                                MOTOLN     41
      ILTYPE=IDDAT(JM+5)                                                MOTOLN     42
C                                                                       MOTOLN     43
      IF (MOTYPK.LT.10) THEN                                            MOTOLN     44
         VT2=CABS(VOLT(I))                                              MOTOLN     45
      ELSE                                                              MOTOLN     46
         VT2=SQRT(DDAT(JM+36)**2+DDAT(JM+37)**2)                        MOTOLN     47
         MOTYPK=MOTYPK-10                                               MOTOLN     48
      END IF                                                            MOTOLN     49
C                                                                       MOTOLN     50
      IF (MOTYPK.LE.3) THEN                                             MOTOLN     51
         V1D=XSTATE(JZT+1)                                              MOTOLN     52
         V1Q=XSTATE(JZT+2)                                              MOTOLN     53
         SA=ABS(XSTATE(JZT+3))                                          MOTOLN     54
         NOSAT=3                                                        MOTOLN     55
      ELSE                                                              MOTOLN     56
         V1D=VC1D(JY+10)                                                MOTOLN     57
         V1Q=VC1Q(JY+11)                                                MOTOLN     58
         SA=ABS(XSTATE(JZT+1))                                          MOTOLN     59
         NOSAT=1                                                        MOTOLN     60
      END IF                                                            MOTOLN     61
      SA1=1.0-SA                                                        MOTOLN     62
      XMMK=DDAT(JM+16)/AJCOB(IAIDEX+1)                                  MOTOLN     63
      IF (MOTYPK.EQ.2.OR.MOTYPK.EQ.7) THEN                              MOTOLN     64
         IF (SA.GE.1.E-04) THEN                                         MOTOLN     65
            B2=DDAT(JM+19)*SQRT(SA)                                     MOTOLN     66
            DEM=COSH(B2)-COS(B2)                                        MOTOLN     67
            XR=DDAT(JM+20)*B2*.5/SA*(SINH(B2)-SIN(B2))/DEM              MOTOLN     68
            RR=DDAT(JM+20)*B2*.5*(SINH(B2)+SIN(B2))/DEM                 MOTOLN     69
         ELSE                                                           MOTOLN     70
            XR=DDAT(JM+20)*DDAT(JM+19)*DDAT(JM+19)/6.                   MOTOLN     71
            RR=DDAT(JM+20)                                              MOTOLN     72
         END IF                                                         MOTOLN     73
C         XB=XMMK+DDAT(JM+25)+XR*DDAT(JM+22)                            MOTOLN     74
         XB=XMMK+2.0*DDAT(JM+25)+XR*DDAT(JM+22)                         MOTOLN     75
      ELSE IF (MOTYPK.EQ.3.OR.MOTYPK.EQ.8) THEN                         MOTOLN     76
         RRO=DDAT(JM+20)*DDAT(JM+33)/(DDAT(JM+20)+DDAT(JM+33))          MOTOLN     77
         QM=(DDAT(JM+20)+DDAT(JM+33))/DDAT(JM+32)                       MOTOLN     78
         RX=QM*RRO/(QM*QM+SA*SA)                                        MOTOLN     79
         XR=DDAT(JM+20)/DDAT(JM+33)*RX                                  MOTOLN     80
         RR=RX*(QM+SA*SA*DDAT(JM+20)/RRO)                               MOTOLN     81
         XB=XMMK+DDAT(JM+25)+XR*DDAT(JM+22)                             MOTOLN     82
      ELSE                                                              MOTOLN     83
         XR=DDAT(JM+19)                                                 MOTOLN     84
         RR=DDAT(JM+20)                                                 MOTOLN     85
         XB=XMMK+DDAT(JM+25)+DDAT(JM+19)*DDAT(JM+22)+XR                 MOTOLN     86
      END IF                                                            MOTOLN     87
C                                                                       MOTOLN     88
C     SATURATION                                                        MOTOLN     89
C                                                                       MOTOLN     90
      D=1.0                                                             MOTOLN     91
      DR=1.0                                                            MOTOLN     92
      DS=1.0                                                            MOTOLN     93
      IF (IDDAT(JM+4).EQ.0) THEN                                        MOTOLN     94
         XR=XR+DDAT(JM+25)                                              MOTOLN     95
         XS=DDAT(JM+24)+DDAT(JM+17)                                     MOTOLN     96
      ELSE                                                              MOTOLN     97
         IF (SA.LT.1.E-04) GO TO 110                                    MOTOLN     98
         CROMK=DDAT(JM+27)                                              MOTOLN     99
         CSOMK=DDAT(JM+26)                                              MOTOLN    100
         XS1=DDAT(JM+21)                                                MOTOLN    101
         RS=DDAT(JM+18)                                                 MOTOLN    102
         CRD=V1Q/XMMK-XMMK/XB*CDM(JY+8)                                 MOTOLN    103
         CRQ=-V1D/XMMK-XMMK/XB*CQM(JY+9)                                MOTOLN    104
         CR=SQRT(CRD*CRD+CRQ*CRQ)                                       MOTOLN    105
         CS=SQRT(CDM(JY+8)*CDM(JY+8)+CQM(JY+9)*CQM(JY+9))               MOTOLN    106
         D=1.0                                                          MOTOLN    107
         DR=1.0                                                         MOTOLN    108
         IF (CR.LE.CROMK) GO TO 70                                      MOTOLN    109
         RATIO=CROMK/CR                                                 MOTOLN    110
         FACT=SQRT(1.0-RATIO*RATIO)                                     MOTOLN    111
         ANGX=ATAN(RATIO/FACT)                                          MOTOLN    112
         D=(ANGX+RATIO*FACT)*PI                                         MOTOLN    113
         DR=D                                                           MOTOLN    114
70       CONTINUE                                                       MOTOLN    115
         IF (MOTYPK.EQ.2.OR.MOTYPK.EQ.7) THEN                           MOTOLN    116
            XR=DDAT(JM+25)+DDAT(JM+25)*D+XR                             MOTOLN    117
         ELSEIF (MOTYPK.EQ.3.OR.MOTYPK.EQ.8) THEN                       MOTOLN    118
            XR=DDAT(JM+25)+XR+DDAT(JM+19)*D                             MOTOLN    119
         ELSE                                                           MOTOLN    120
            XR=DDAT(JM+25)+XR*D                                         MOTOLN    121
         END IF                                                         MOTOLN    122
         DDAT(JM+22)=D                                                  MOTOLN    123
         D=1.0                                                          MOTOLN    124
         DS=1.0                                                         MOTOLN    125
         IF (CS.LE.CSOMK) GO TO 100                                     MOTOLN    126
         RATIO=CSOMK/CS                                                 MOTOLN    127
         FACT=SQRT(1.0-RATIO*RATIO)                                     MOTOLN    128
         ANGX=ATAN(RATIO/FACT)                                          MOTOLN    129
         D=(ANGX+RATIO*FACT)*PI                                         MOTOLN    130
         DS=1.0                                                         MOTOLN    131
100      CONTINUE                                                       MOTOLN    132
         XS=DDAT(JM+24)+DDAT(JM+17)*D                                   MOTOLN    133
         DDAT(JM+23)=D                                                  MOTOLN    134
         VMR=REAL(VOLT(I))-RS*CDM(JY+8)+XS*CQM(JY+9)                    MOTOLN    135
         VMI=AIMAG(VOLT(I))-RS*CQM(JY+9)-XS*CDM(JY+8)                   MOTOLN    136
         VM=SQRT(VMR*VMR+VMI*VMI)                                       MOTOLN    137
         V1=DDAT(JM+28)                                                 MOTOLN    138
         V2=DDAT(JM+29)                                                 MOTOLN    139
         G1=DDAT(JM+30)                                                 MOTOLN    140
         G2=DDAT(JM+31)                                                 MOTOLN    141
         CALL ISATFU (VM,V1,V2,G1,G2,DDI)                               MOTOLN    142
         AJCOB(IAIDEX+1)=DDI                                            MOTOLN    143
         XMMK=DDAT(JM+16)/DDI                                           MOTOLN    144
         XA=XMMK+XR                                                     MOTOLN    145
         XS1K=XS+XMMK*XR/XA                                             MOTOLN    146
         DDAT(JM+21)=XS1K                                               MOTOLN    147
C                                                                       MOTOLN    148
C     CALCULATE BSM & GSM                                               MOTOLN    149
C                                                                       MOTOLN    150
         RSK=DDAT(JM+18)                                                MOTOLN    151
         YS1=1.0/(RSK**2+XS1K**2)                                       MOTOLN    152
         RSK=RSK*YS1                                                    MOTOLN    153
         XS1K=XS1K*YS1                                                  MOTOLN    154
         BSM(JY+5)=XS1K                                                 MOTOLN    155
         GSM(JY+4)=RSK                                                  MOTOLN    156
      END IF                                                            MOTOLN    157
C                                                                       MOTOLN    158
110   CONTINUE                                                          MOTOLN    159
C                                                                       MOTOLN    160
      WXBASE=DDAT(JM+13)                                                MOTOLN    161
      AR=RR*WXBASE/(XMMK+XR)                                            MOTOLN    162
      SW=WXBASE*SA                                                      MOTOLN    163
      XSD=XMMK+XS-DDAT(JM+21)                                           MOTOLN    164
C                                                                       MOTOLN    165
      IF (MOTYPK.GE.6) THEN                                             MOTOLN    166
         TRSW=WXBASE*SA/AR                                              MOTOLN    167
         Z12=XSD/(TRSW*TRSW+1.0)                                        MOTOLN    168
         Z11=Z12*TRSW                                                   MOTOLN    169
         V1D=Z11*CDM(JY+8)-Z12*CQM(JY+9)                                MOTOLN    170
         V1Q=Z12*CDM(JY+8)+Z11*CQM(JY+9)                                MOTOLN    171
         VC1D(JY+10)=V1D                                                MOTOLN    172
         VC1Q(JY+11)=V1Q                                                MOTOLN    173
         RSK=DDAT(JM+18)                                                MOTOLN    174
         XS1K=DDAT(JM+21)                                               MOTOLN    175
         Z11=RSK+Z11                                                    MOTOLN    176
         Z12=XS1K+Z12                                                   MOTOLN    177
         YS1=1.0/(Z11**2+Z12**2)                                        MOTOLN    178
         Z11=Z11*YS1                                                    MOTOLN    179
         Z12=Z12*YS1                                                    MOTOLN    180
         GSM(JY+4)=Z11                                                  MOTOLN    181
         BSM(JY+5)=Z12                                                  MOTOLN    182
      END IF                                                            MOTOLN    183
C                                                                       MOTOLN    184
C     ACTUAL JACOBIAN CALCULATIONS                                      MOTOLN    185
C                                                                       MOTOLN    186
      A(1,1)=-AR-(WXBASE*RR*XMMK*XMMK*BSM(JY+5)/((XMMK+XR)*(XMMK+XR)))  MOTOLN    187
      A(1,2)=WXBASE*(SA+(RR*XMMK*XMMK*GSM(JY+4)/((XMMK+XR)*(XMMK+XR)))) MOTOLN    188
      A(1,3)=WXBASE*V1Q                                                 MOTOLN    189
      B(1,1)=WXBASE*RR*XMMK*XMMK*BSM(JY+5)/((XMMK+XR)*(XMMK+XR))        MOTOLN    190
      B(1,2)=-WXBASE*RR*XMMK*XMMK*GSM(JY+4)/((XMMK+XR)*(XMMK+XR))       MOTOLN    191
      A(2,1)=-A(1,2)                                                    MOTOLN    192
      A(2,2)=A(1,1)                                                     MOTOLN    193
      A(2,3)=-WXBASE*V1D                                                MOTOLN    194
      B(2,1)=-B(1,2)                                                    MOTOLN    195
      B(2,2)=B(1,1)                                                     MOTOLN    196
      A(3,1)=DDAT(JM+6)*(GSM(JY+4)*(2.0*V1D-REAL(VOLT(I)))              MOTOLN    197
     1       -BSM(JY+5)*AIMAG(VOLT(I)))                                 MOTOLN    198
      A(3,2)=DDAT(JM+6)*(GSM(JY+4)*(2.0*V1Q-AIMAG(VOLT(I)))             MOTOLN    199
     1       +BSM(JY+5)*REAL(VOLT(I)))                                  MOTOLN    200
C                                                                       MOTOLN    201
      IF (ILTYPE.EQ.1) THEN                                             MOTOLN    202
         EXPN=DDAT(JM+7)                                                MOTOLN    203
         EXPM=DDAT(JM+8)                                                MOTOLN    204
         COFK1=DDAT(JM+9)                                               MOTOLN    205
         COFK2=DDAT(JM+10)                                              MOTOLN    206
         IF (SA.LT.1.0) THEN                                            MOTOLN    207
            A(3,3)=DDAT(JM+6)*(-EXPN*COFK1*SA1**(EXPN-1.0)              MOTOLN    208
     1            +COFK2*EXPM*SA**(EXPM-1.0))                           MOTOLN    209
         ELSE                                                           MOTOLN    210
            A(3,3)=0.0                                                  MOTOLN    211
         END IF                                                         MOTOLN    212
      ELSE IF (ILTYPE.EQ.2) THEN                                        MOTOLN    213
         ALL=DDAT(JM+7)                                                 MOTOLN    214
         BLL=DDAT(JM+8)                                                 MOTOLN    215
         IF (SA.LT.1.0) THEN                                            MOTOLN    216
            A(3,3)=-DDAT(JM+6)*(2.0*ALL*SA1+BLL*SA)                     MOTOLN    217
         ELSE                                                           MOTOLN    218
            A(3,3)=0.0                                                  MOTOLN    219
         END IF                                                         MOTOLN    220
      ELSE                                                              MOTOLN    221
         A(3,3)=0.0                                                     MOTOLN    222
      END IF                                                            MOTOLN    223
C                                                                       MOTOLN    224
      B(3,1)=-GSM(JY+4)*V1D+BSM(JY+5)*V1Q                               MOTOLN    225
      B(3,2)=-BSM(JY+5)*V1D-GSM(JY+4)*V1Q                               MOTOLN    226
      B(3,1)=DDAT(JM+6)*B(3,1)                                          MOTOLN    227
      B(3,2)=DDAT(JM+6)*B(3,2)                                          MOTOLN    228
C                                                                       MOTOLN    229
      AK(1,1)=GSM(JY+4)                                                 MOTOLN    230
      AK(1,2)=BSM(JY+5)                                                 MOTOLN    231
      AK(2,1)=-BSM(JY+5)                                                MOTOLN    232
      AK(2,2)=GSM(JY+4)                                                 MOTOLN    233
      AK(1,3)=0.0                                                       MOTOLN    234
      AK(2,3)=0.0                                                       MOTOLN    235
C                                                                       MOTOLN    236
      IF (MOTYPK.EQ.2.OR.MOTYPK.EQ.7) THEN                              MOTOLN    237
      IF (SA.GT.1.E-04) THEN                                            MOTOLN    238
         BST=DDAT(JM+19)                                                MOTOLN    239
         RRZ=DDAT(JM+20)                                                MOTOLN    240
         SNH=SINH(BST*SQRT(SA))                                         MOTOLN    241
         SNN=SIN(BST*SQRT(SA))                                          MOTOLN    242
         CNH=COSH(BST*SQRT(SA))                                         MOTOLN    243
         CNN=COS(BST*SQRT(SA))                                          MOTOLN    244
         DRRBYS=RRZ*BST*0.25*(((SNH+SNN)/(SQRT(SA)*(CNH-CNN)))-         MOTOLN    245
     *   (BST*2.0*SNH*SNN/((CNH-CNN)*(CNH-CNN))))                       MOTOLN    246
         DXLRBS=RRZ*BST*0.25*((-(SNH-SNN)/(SQRT(SA)*(CNH-CNN)))+        MOTOLN    247
     *   (BST*2.0*(1.0-(CNH*CNN))/((CNH-CNN)*(CNH-CNN))))               MOTOLN    248
         DXLRBS=DXLRBS/SA                                               MOTOLN    249
         XLR=DDAT(JM+25)+(RRZ*BST*0.5*DR*(SNH-SNN)/                     MOTOLN    250
     *   (SQRT(SA)*(CNH-CNN)))                                          MOTOLN    251
         RLR=RRZ*BST*0.5*SQRT(SA)*(SNH+SNN)/(CNH-CNN)                   MOTOLN    252
      ELSE                                                              MOTOLN    253
         DRRBYS=0.0                                                     MOTOLN    254
         DXLRBS=0.0                                                     MOTOLN    255
         XLR=DDAT(JM+20)*DDAT(JM+19)*DDAT(JM+19)/6.                     MOTOLN    256
         RLR=DDAT(JM+20)                                                MOTOLN    257
      END IF                                                            MOTOLN    258
      ELSE IF (MOTYPK.EQ.3.OR.MOTYPK.EQ.8) THEN                         MOTOLN    259
         QM=(DDAT(JM+20)+DDAT(JM+33))/DDAT(JM+32)                       MOTOLN    260
         RMZ=DDAT(JM+20)*DDAT(JM+33)/(DDAT(JM+20)+DDAT(JM+33))          MOTOLN    261
         QMS2=QM*QM+SA*SA                                               MOTOLN    262
         QMSLP=QM*SA                                                    MOTOLN    263
         QMSLP2=QM*SA*SA                                                MOTOLN    264
         DRRBYS=RMZ*((QMS2*2.0*QMSLP*DDAT(JM+20)/RMZ)-                  MOTOLN    265
     *   (2.0*SA*((QM*QM)+(QMSLP2*DDAT(JM+20)/RMZ))))/(QMS2*QMS2)       MOTOLN    266
         DXLRBS=-RMZ*QM*DDAT(JM+20)*2.0*SA/(DDAT(JM+33)*QMS2*QMS2)      MOTOLN    267
         XLR=DDAT(JM+25)+(DDAT(JM+19)*DR*RMZ*QM*DDAT(JM+20)/            MOTOLN    268
     *   (DDAT(JM+33)*QMS2))                                            MOTOLN    269
         RLR=RMZ*(QM*QM+(QM*SA*SA*DDAT(JM+20)/RMZ))/QMS2                MOTOLN    270
      END IF                                                            MOTOLN    271
C                                                                       MOTOLN    272
      IF ((MOTYPK.NE.1).AND.(MOTYPK.NE.7)) THEN                         MOTOLN    273
         XLS=DDAT(JM+24)+DDAT(JM+17)*DS                                 MOTOLN    274
         AXLSM=XLS+XMMK                                                 MOTOLN    275
         RLS=DDAT(JM+18)                                                MOTOLN    276
         AXLRM=XLR+XMMK                                                 MOTOLN    277
         AXLRM2=AXLRM*AXLRM                                             MOTOLN    278
         DFFA=WXBASE*(AXLRM*DRRBYS-RLR*DXLRBS)/AXLRM2                   MOTOLN    279
         AX1=XLR*AXLSM+XLS*XMMK                                         MOTOLN    280
         AX2=RLS*AXLRM                                                  MOTOLN    281
         DFFB=WXBASE*XMMK*XMMK*((AXLRM*(AX2*AX2+AX1*AX1)*(AX1*DRRBYS+   MOTOLN    282
     *   AX2*DXLRBS))-(RLR*AX1*(AX2*AX2+AX1*AX1)*DXLRBS)+               MOTOLN    283
     *   (AXLRM*((RLS*RLS*2.0*AXLRM)+(2.0*AX1*AXLSM))*DXLRBS))          MOTOLN    284
         DFFB=DFFB/(((AX1*AX1+AX2*AX2)*AXLRM)**2)                       MOTOLN    285
         DFFC=WXBASE*RLS*XMMK*XMMK*((AX2*AX2+AX1*AX1)*DRRBYS-           MOTOLN    286
     *   RLR*(RLS*RLS*2.0*AXLRM+2.0*AX1*AXLSM)*DXLRBS)                  MOTOLN    287
         DFFC=DFFC/((AX1*AX1+AX2*AX2)**2)                               MOTOLN    288
         DFFD=RLS*(AX1*DXLRBS-AXLRM*AXLSM*DXLRBS)/(AX1*AX1)             MOTOLN    289
         DFFE=(AX2*AX2+AX1*AX1)*(AXLSM*AXLRM+AX1)*DXLRBS-               MOTOLN    290
     *   (AX1*AXLRM*(2.0*RLS*RLS*AXLRM+2.0*AX1*AXLSM)*DXLRBS)           MOTOLN    291
         DFFE=DFFE/(AX2*AX2+AX1*AX1)                                    MOTOLN    292
C                                                                       MOTOLN    293
         A(1,3)=(WXBASE+DFFC)*V1Q-V1D*(DFFA+DFFB)+REAL(VOLT(I))*DFFB-   MOTOLN    294
     *   AIMAG(VOLT(I))*DFFC                                            MOTOLN    295
         A(2,3)=-(WXBASE+DFFC)*V1D-V1Q*(DFFA+DFFB)+REAL(VOLT(I))*DFFC+  MOTOLN    296
     *   AIMAG(VOLT(I))*DFFB                                            MOTOLN    297
C                                                                       MOTOLN    298
         IF (ILTYPE.EQ.1) THEN                                          MOTOLN    299
            EXPN=DDAT(JM+7)                                             MOTOLN    300
            EXPM=DDAT(JM+8)                                             MOTOLN    301
            COFK1=DDAT(JM+9)                                            MOTOLN    302
            COFK2=DDAT(JM+10)                                           MOTOLN    303
            IF (SA.LT.1.0) THEN                                         MOTOLN    304
               A(3,3)=DDAT(JM+6)*(-EXPN*COFK1*SA1**(EXPN-1.0)           MOTOLN    305
     1               +COFK2*EXPM*SA**(EXPM-1.0))                        MOTOLN    306
            ELSE                                                        MOTOLN    307
               A(3,3)=0.0                                               MOTOLN    308
            END IF                                                      MOTOLN    309
         ELSE IF (ILTYPE.EQ.2) THEN                                     MOTOLN    310
            ALL=DDAT(JM+7)                                              MOTOLN    311
            BLL=DDAT(JM+8)                                              MOTOLN    312
            IF (SA.LT.1.0) THEN                                         MOTOLN    313
               A(3,3)=-DDAT(JM+6)*(2.0*ALL*SA1+BLL*SA)                  MOTOLN    314
            ELSE                                                        MOTOLN    315
               A(3,3)=0.0                                               MOTOLN    316
            END IF                                                      MOTOLN    317
         ELSE                                                           MOTOLN    318
            A(3,3)=0.0                                                  MOTOLN    319
         END IF                                                         MOTOLN    320
C                                                                       MOTOLN    321
         A(3,3)=A(3,3)+DDAT(JM+6)*((V1D*V1D+V1Q*V1Q-V1D*REAL(VOLT(I))-  MOTOLN    322
     *   V1Q*AIMAG(VOLT(I)))*DFFD+(REAL(VOLT(I))*V1Q-                   MOTOLN    323
     *   AIMAG(VOLT(I))*V1D)*DFFE)                                      MOTOLN    324
C                                                                       MOTOLN    325
         AK(1,3)=V1Q*DFFE+V1D*DFFD                                      MOTOLN    326
         AK(2,3)=-V1D*DFFE+V1Q*DFFD                                     MOTOLN    327
C                                                                       MOTOLN    328
      END IF                                                            MOTOLN    329
C                                                                       MOTOLN    330
C     FOR MOTYPK.GE.6, ELIMINATE THE FIRST TWO ROWS AND COLUMNS         MOTOLN    331
C                                                                       MOTOLN    332
      IF (MOTYPK.GE.6) THEN                                             MOTOLN    333
         DET=-1.0/(A(1,1)**2+A(2,2)**2)                                 MOTOLN    334
         WS1=DET*A(1,1)                                                 MOTOLN    335
         A(1,1)=DET*A(2,2)                                              MOTOLN    336
         A(2,2)=WS1                                                     MOTOLN    337
         A(1,2)=-DET*A(1,2)                                             MOTOLN    338
         A(2,1)=-DET*A(2,1)                                             MOTOLN    339
         WS1=A(1,1)*A(1,3)+A(1,2)*A(2,3)                                MOTOLN    340
         A(2,3)=A(2,1)*A(1,3)+A(2,2)*A(2,3)                             MOTOLN    341
         A(1,3)=WS1                                                     MOTOLN    342
         WS1=A(1,1)*B(1,1)+A(1,2)*B(2,1)                                MOTOLN    343
         B(2,1)=A(2,1)*B(1,1)+A(2,2)*B(2,1)                             MOTOLN    344
         B(1,1)=WS1                                                     MOTOLN    345
         WS1=A(1,1)*B(1,2)+A(1,2)*B(2,2)                                MOTOLN    346
         B(2,2)=A(2,1)*B(1,2)+A(2,2)*B(2,2)                             MOTOLN    347
         B(1,2)=WS1                                                     MOTOLN    348
C                                                                       MOTOLN    349
         A(3,3)=A(3,3)+A(3,1)*A(1,3)+A(3,2)*A(2,3)                      MOTOLN    350
         B(3,1)=B(3,1)+A(3,1)*B(1,1)+A(3,2)*B(2,1)                      MOTOLN    351
         B(3,2)=B(3,2)+A(3,1)*B(1,2)+A(3,2)*B(2,2)                      MOTOLN    352
         AK(1,3)=AK(1,3)+AK(1,1)*A(1,3)+AK(1,2)*A(2,3)                  MOTOLN    353
         AK(2,3)=AK(2,3)+AK(2,1)*A(1,3)+AK(2,2)*A(2,3)                  MOTOLN    354
C                                                                       MOTOLN    355
         A(1,1)=A(3,3)                                                  MOTOLN    356
         B(1,1)=B(3,1)                                                  MOTOLN    357
         B(1,2)=B(3,2)                                                  MOTOLN    358
         AK(1,1)=AK(1,3)                                                MOTOLN    359
         AK(2,1)=AK(2,3)                                                MOTOLN    360
      END IF                                                            MOTOLN    361
C                                                                       MOTOLN    362
      ICOLBV=1                                                          MOTOLN    363
      NAIDEX=IAIDEX+1                                                   MOTOLN    364
      NBIDEX=IBIDEX                                                     MOTOLN    365
      NCIDEX=ICIDEX                                                     MOTOLN    366
C                                                                       MOTOLN    367
      IF (IPATH.EQ.1) THEN                                              MOTOLN    368
C                                                                       MOTOLN    369
      DO 130 IJK=1,NOSAT                                                MOTOLN    370
         DO 120 IJJ=1,NOSAT                                             MOTOLN    371
            A(IJK,IJJ)=-CEFJM*A(IJK,IJJ)                                MOTOLN    372
 120     CONTINUE                                                       MOTOLN    373
         A(IJK,IJK)=A(IJK,IJK)+1.0                                      MOTOLN    374
C                                                                       MOTOLN    375
        B(IJK,1)=-CEFJM*B(IJK,1)                                        MOTOLN    376
        B(IJK,2)=-CEFJM*B(IJK,2)                                        MOTOLN    377
C                                                                       MOTOLN    378
 130  CONTINUE                                                          MOTOLN    379
C                                                                       MOTOLN    380
      CALL LUDCM(NOSAT)                                                 MOTOLN    381
C                                                                       MOTOLN    382
      CALL FBSUBA(NOSAT)                                                MOTOLN    383
C                                                                       MOTOLN    384
         DO 140 IJJ=1,NOSAT                                             MOTOLN    385
         NCIDEX=NCIDEX+1                                                MOTOLN    386
         CJCOB(NCIDEX)=-AK(1,IJJ)                                       MOTOLN    387
         CJCOB(NCIDEX+NOSAT)=-AK(2,IJJ)                                 MOTOLN    388
 140  CONTINUE                                                          MOTOLN    389
         NCIDEX=NCIDEX+NOSAT                                            MOTOLN    390
C                                                                       MOTOLN    391
      DO 150 IJK=1,NOSAT                                                MOTOLN    392
         DO 150 IJJ=1,NOSAT                                             MOTOLN    393
            NAIDEX=NAIDEX+1                                             MOTOLN    394
            AJCOB(NAIDEX)=A(IJK,IJJ)                                    MOTOLN    395
 150  CONTINUE                                                          MOTOLN    396
C                                                                       MOTOLN    397
C  STORE A-1*B                                                          MOTOLN    398
C                                                                       MOTOLN    399
       NBIDEX=NBIDEX+1                                                  MOTOLN    400
       IBJCOB(NBIDEX)=I                                                 MOTOLN    401
       DO 160 IJK=1,NOSAT                                               MOTOLN    402
       NBIDEX=NBIDEX+2                                                  MOTOLN    403
       BJCOB(NBIDEX-1)=B(IJK,1)                                         MOTOLN    404
       BJCOB(NBIDEX)=B(IJK,2)                                           MOTOLN    405
 160  CONTINUE                                                          MOTOLN    406
      NBIDEX=NBIDEX+1                                                   MOTOLN    407
      IBJCOB(NBIDEX)=0                                                  MOTOLN    408
C                                                                       MOTOLN    409
      END IF                                                            MOTOLN    410
C                                                                       MOTOLN    411
      RETURN                                                            MOTOLN    412
C                                                                       MOTOLN    413
      END                                                               MOTOLN    414
