CFPRIME RXDOT                                                           RXDOT       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 RXDOT                                                  RXDOT       3
CD                                                                      RXDOT       4
CD    TO CALCULATE THE DERIVATIVES OF THE STATES OF RANI FOR USE IN THE RXDOT       5
CD    TRAPEZOIDAL METHOD. THIS SUBROUTINE IS SIMILAR TO SUBROUTINE      RXDOT       6
CD    DERAN. THE DIFFERENCES ARE:                                       RXDOT       7
CD                                                                      RXDOT       8
CD    1. THE PARTS RELATED TO THE RUNGE-KUTTA METHOD ARE DELETED        RXDOT       9
CD                                                                      RXDOT      10
CD    2. THE JACOBIAN CLACULATION PATH IS ADDED                         RXDOT      11
CD                                                                      RXDOT      12
CD    3. THE STATE DERIVATIVE ARRAY, XDOT, IS HERE A GLOBAL ARRAY       RXDOT      13
CD                                                                      RXDOT      14
      INCLUDE 'PARX.INS'                                                RXDOT      15
      INCLUDE 'CNPT.INS'                                                RXDOT      16
      INCLUDE 'CNIPTR.INS'                                              RXDOT      17
      INCLUDE 'CNB4.INS'                                                RXDOT      18
      INCLUDE 'CNB9.INS'                                                RXDOT      19
      INCLUDE 'CNB91.INS'                                               RXDOT      20
      INCLUDE 'CNRAN.INS'                                               RXDOT      21
      INCLUDE 'CNUDM.INS'                                               RXDOT      22
      INCLUDE 'CNUDMA.INS'                                              RXDOT      23
      INCLUDE 'CNUDMB.INS'                                              RXDOT      24
      INCLUDE 'CNUDMK.INS'                                              RXDOT      25
      INCLUDE 'CNXSTA.INS'                                              RXDOT      26
      INCLUDE 'CNQSTA.INS'                                              RXDOT      27
      INCLUDE 'CNZSTA.INS'                                              RXDOT      28
      INCLUDE 'CNMDAT.INS'                                              RXDOT      29
      INCLUDE 'CNVOLT.INS'                                              RXDOT      30
      INCLUDE 'CNMYVA.INS'                                              RXDOT      31
      INCLUDE 'CNYVAR.INS'                                              RXDOT      32
      INCLUDE 'CNXDOT.INS'                                              RXDOT      33
      INCLUDE 'CNGEAR.INS'                                              RXDOT      34
      INCLUDE 'CNIMPR.INS'                                              RXDOT      35
      INCLUDE 'CNJCOB.INS'                                              RXDOT      36
      INCLUDE 'CNABAK.INS'                                              RXDOT      37
C                                                                       RXDOT      38
      CHARACTER*80 MSG                                                  RXDOT      39
      CHARACTER*2 LCKT                                                  RXDOT      40
      CHARACTER*4 CKID                                                  RXDOT      41
      INTEGER*4 JCKID                                                   RXDOT      42
      EQUIVALENCE (JCKID,CKID)                                          RXDOT      43
C                                                                       RXDOT      44
      DIMENSION CDEV(4),YSEL(4,4)                                       RXDOT      45
C                                                                       RXDOT      46
      BRANN=0.0                                                         RXDOT      47
      GRANN=0.0                                                         RXDOT      48
C                                                                       RXDOT      49
      DO 500 N=1,NRANI                                                  RXDOT      50
      JR=JRDAT(N)                                                       RXDOT      51
      JSTATE=JXRAN(N)                                                   RXDOT      52
      JY=JVRAN(N)                                                       RXDOT      53
      NRTYPN=IDDAT(JR+4)                                                RXDOT      54
      IRANF=IDDAT(JR+6)                                                 RXDOT      55
      IF (NRTYPN.NE.50) GO TO 500                                       RXDOT      56
C                                                                       RXDOT      57
C     GET THE INPUT VALUES                                              RXDOT      58
C                                                                       RXDOT      59
      LSTATE=0                                                          RXDOT      60
      JE0=JR+7                                                          RXDOT      61
      JE1=JE0+5                                                         RXDOT      62
      CALL RINUDM                                                       RXDOT      63
C                                                                       RXDOT      64
      K1=IDDAT(JR+1)                                                    RXDOT      65
      K13=K1*3                                                          RXDOT      66
      NLF1=NOLD(K1)                                                     RXDOT      67
      K2=IDDAT(JR+2)                                                    RXDOT      68
      JCKID=IDDAT(JR+3)                                                 RXDOT      69
      LCKT(1:2)=CKID(3:4)                                               RXDOT      70
      VRE1=REAL(VOLT(K1))                                               RXDOT      71
      VIM1=AIMAG(VOLT(K1))                                              RXDOT      72
      VMG1=SQRT(VRE1*VRE1+VIM1*VIM1)                                    RXDOT      73
      VRE2=REAL(VOLT(K2))                                               RXDOT      74
      VIM2=AIMAG(VOLT(K2))                                              RXDOT      75
      VMG2=SQRT(VRE2*VRE2+VIM2*VIM2)                                    RXDOT      76
      VRE=VRE1-VRE2                                                     RXDOT      77
      VIM=VIM1-VIM2                                                     RXDOT      78
      VMG=SQRT(VRE*VRE+VIM*VIM)                                         RXDOT      79
      VALIN(7)=VMG1                                                     RXDOT      80
      VALIN(8)=VMG2                                                     RXDOT      81
      VALIN(20)=RVREF(JY+1)                                             RXDOT      82
      IF (VMG1.GT.0.05) THEN                                            RXDOT      83
         VA1=ATAN2(VIM1,VRE1)                                           RXDOT      84
         VAGD=DDAT(JE0+2)-VA1                                           RXDOT      85
         DDAT(JE0+2)=VA1                                                RXDOT      86
         IF (VAGD.GT.3.15) THEN                                         RXDOT      87
            IDDAT(JE0+1)=IDDAT(JE0+1)+1                                 RXDOT      88
         ELSE IF (VAGD.LT.-3.15) THEN                                   RXDOT      89
            IDDAT(JE0+1)=IDDAT(JE0+1)-1                                 RXDOT      90
         END IF                                                         RXDOT      91
         VALIN(9)=VA1+6.2831853*IDDAT(JE0+1)                            RXDOT      92
      ELSE                                                              RXDOT      93
         VALIN(9)=DDAT(JE0+2)+6.2831853*IDDAT(JE0+1)                    RXDOT      94
      END IF                                                            RXDOT      95
      IF (VMG2.GT.0.05) THEN                                            RXDOT      96
         VA2=ATAN2(VIM2,VRE2)                                           RXDOT      97
         VAGD=DDAT(JE0+4)-VA2                                           RXDOT      98
         DDAT(JE0+4)=VA2                                                RXDOT      99
         IF (VAGD.GT.3.15) THEN                                         RXDOT     100
            IDDAT(JE0+3)=IDDAT(JE0+3)+1                                 RXDOT     101
         ELSE IF (VAGD.LT.-3.15) THEN                                   RXDOT     102
            IDDAT(JE0+3)=IDDAT(JE0+3)-1                                 RXDOT     103
         END IF                                                         RXDOT     104
         VALIN(10)=VA2+6.2831853*IDDAT(JE0+3)                           RXDOT     105
      ELSE                                                              RXDOT     106
         VALIN(10)=DDAT(JE0+4)+6.2831853*IDDAT(JE0+3)                   RXDOT     107
      END IF                                                            RXDOT     108
      BASERT=BASER(JY+4)                                                RXDOT     109
      IF (IRANF.EQ.0) THEN                                              RXDOT     110
         VALIN(1)=VMG*BDEV(JY+5)                                        RXDOT     111
         VALIN(2)=VMG*BTCR(JY+6)                                        RXDOT     112
         VALIN(3)=VMG*VALIN(1)                                          RXDOT     113
         VALIN(4)=VMG*VALIN(2)                                          RXDOT     114
         VALIN(5)=BDEV(JY+5)                                            RXDOT     115
         VALIN(6)=BTCR(JY+6)                                            RXDOT     116
         VALIN(11)=STCR(JY+7)                                           RXDOT     117
      ELSEIF(IRANF.EQ.1) THEN                                           RXDOT     118
         VALIN(1)=VMG*BDEV(JY+5)                                        RXDOT     119
         VALIN(12)=SRAN(JY+7)                                           RXDOT     120
         VALIN(15)=BDEV(JY+5)                                           RXDOT     121
         VALIN(16)=VMG*VALIN(1)                                         RXDOT     122
      ELSEIF(IRANF.EQ.2) THEN                                           RXDOT     123
         Y02=BRANO(JY+9)**2+BRANO(JY+3)**2                              RXDOT     124
         R0=BRANO(JY+9)/Y02                                             RXDOT     125
         X0=BRANO(JY+3)/Y02                                             RXDOT     126
         DX=BDEV(JY+5)*BASERT-BRANO(JY+10)                              RXDOT     127
         XT=X0+DX                                                       RXDOT     128
         ZT=SQRT(R0**2+XT**2)                                           RXDOT     129
         VALIN(1)=BASERT*VMG/ZT                                         RXDOT     130
         VALIN(3)=BDEV(JY+5)*VALIN(1)**2                                RXDOT     131
         VALIN(12)=STCR(JY+7)                                           RXDOT     132
         VALIN(17)=BDEV(JY+5)                                           RXDOT     133
      ELSEIF(IRANF.EQ.3) THEN                                           RXDOT     134
         VALIN(1)=BDEV(JY+5)                                            RXDOT     135
         VALIN(3)=VMG*VALIN(1)                                          RXDOT     136
         IF(VMG.GT.0.0001) THEN                                         RXDOT     137
            VALIN(5)=BDEV(JY+5)/VMG                                     RXDOT     138
         ELSE                                                           RXDOT     139
            VALIN(5)=0.0                                                RXDOT     140
         ENDIF                                                          RXDOT     141
         VALIN(12)=STCR(JY+7)                                           RXDOT     142
      END IF                                                            RXDOT     143
C                                                                       RXDOT     144
      JE0=0                                                             RXDOT     145
C                                                                       RXDOT     146
      KORD=0                                                            RXDOT     147
      CALL DEUDM(H,KORD,NLF1,K13,LCKT)                                  RXDOT     148
      JE0=1                                                             RXDOT     149
C                                                                       RXDOT     150
      DO 90 J=1,KORD                                                    RXDOT     151
         XDOT(JSTATE+J)=DSTATE(J)                                       RXDOT     152
   90 CONTINUE                                                          RXDOT     153
C                                                                       RXDOT     154
      IOUT=IDDAT(JE7+1)                                                 RXDOT     155
      BDEV(JY+5)=VALOUT(IOUT)                                           RXDOT     156
      IF(IRANF.EQ.0) THEN                                               RXDOT     157
         BRANI(JY+2)=VALOUT(IOUT)*BASERT                                RXDOT     158
         BTCR(JY+6)=VALIN(6)                                            RXDOT     159
         STCR(JY+7)=VALIN(11)                                           RXDOT     160
      ELSEIF(IRANF.EQ.1) THEN                                           RXDOT     161
         BRANI(JY+2)=VALOUT(IOUT)*BASERT                                RXDOT     162
         SRAN(JY+7)=VALIN(12)                                           RXDOT     163
      ELSEIF(IRANF.EQ.2) THEN                                           RXDOT     164
         Y02=BRANO(JY+9)**2+BRANO(JY+3)**2                              RXDOT     165
         R0=BRANO(JY+9)/Y02                                             RXDOT     166
         X0=BRANO(JY+3)/Y02                                             RXDOT     167
         DX=VALOUT(IOUT)*BASERT-BRANO(JY+10)                            RXDOT     168
         Z2=R0**2+(X0+DX)**2                                            RXDOT     169
         BRANI(JY+8)=R0/Z2                                              RXDOT     170
         BRANI(JY+2)=(X0+DX)/Z2                                         RXDOT     171
      ELSEIF(IRANF.EQ.3) THEN                                           RXDOT     172
         BRANI(JY+2)=VALOUT(IOUT)*BASERT                                RXDOT     173
         SRAN(JY+7)=VALIN(12)                                           RXDOT     174
      END IF                                                            RXDOT     175
C                                                                       RXDOT     176
      JYUDM=JY+10                                                       RXDOT     177
      DO 100 J=1,NUDB                                                   RXDOT     178
         YVAR(JYUDM+J)=VALOUT(J)                                        RXDOT     179
  100 CONTINUE                                                          RXDOT     180
C                                                                       RXDOT     181
C     UPDATE JACOBIAN MATRICES                                          RXDOT     182
C                                                                       RXDOT     183
      IF (NITER.GT.0) GOTO 410                                          RXDOT     184
C                                                                       RXDOT     185
      IBFARX=IDDAT(JR+5)                                                RXDOT     186
C                                                                       RXDOT     187
      CALL MOVE(0,MBUSR,MBUSR,70)                                       RXDOT     188
      CALL FMOVE(0,UDAT,UDAT,NXUDB**2)                                  RXDOT     189
      MBUSR(1)=K1                                                       RXDOT     190
      MBUSR(2)=K2                                                       RXDOT     191
C                                                                       RXDOT     192
      JEU=JE7-JE1+2                                                     RXDOT     193
      DO 110 I=1,JEU                                                    RXDOT     194
         UDAT(I)=DDAT(I+JE1-1)                                          RXDOT     195
  110 CONTINUE                                                          RXDOT     196
      IWS1=JR+11                                                        RXDOT     197
      JE1=JE1-IWS1                                                      RXDOT     198
      JE2=JE2-IWS1                                                      RXDOT     199
      JE3=JE3-IWS1                                                      RXDOT     200
      JE4=JE4-IWS1                                                      RXDOT     201
      JE5=JE5-IWS1                                                      RXDOT     202
      JE6=JE6-IWS1                                                      RXDOT     203
      JE7=JE7-IWS1                                                      RXDOT     204
C                                                                       RXDOT     205
C     FORM: DEL I = CDEV*DEL YC+YDEV*DEL V                              RXDOT     206
C                   (-YSEL*DEL V, AFTER INTERCONNECTION)                RXDOT     207
C                                                                       RXDOT     208
C          DEL U0 = XUI*DEL I+XUV*DEL V+XUY*DEL YB+XUREF*DEL VREF       RXDOT     209
C                                                                       RXDOT     210
      DO 50 I=1,20                                                      RXDOT     211
      DO 40 J=1,NXUDB                                                   RXDOT     212
      XUY(I,J)=0.0                                                      RXDOT     213
  40  CONTINUE                                                          RXDOT     214
      DO 50 J=1,LOUTP                                                   RXDOT     215
      XUI(I,J)=0.0                                                      RXDOT     216
      XUV(I,J)=0.0                                                      RXDOT     217
  50  CONTINUE                                                          RXDOT     218
C      CALL FMOVE(0,XUI,XUI,20*LOUTP)                                   RXDOT     219
C      CALL FMOVE(0,XUV,XUV,20*LOUTP)                                   RXDOT     220
C      CALL FMOVE(0,XUY,XUY,20*NXUDB)                                   RXDOT     221
C                                                                       RXDOT     222
      IBEND=IUDAT(JE7+1)                                                RXDOT     223
      IF(IRANF.EQ.0) THEN                                               RXDOT     224
         CDEV(1)=VIM                                                    RXDOT     225
         CDEV(2)=-VRE                                                   RXDOT     226
         CDEV(3)=-VIM                                                   RXDOT     227
         CDEV(4)=VRE                                                    RXDOT     228
C                                                                       RXDOT     229
         BRANNO=BRANO(JY+3)                                             RXDOT     230
         YSEL(1,1)=0.0                                                  RXDOT     231
         YSEL(1,2)=BRANNO                                               RXDOT     232
         YSEL(1,3)=0.0                                                  RXDOT     233
         YSEL(1,4)=-BRANNO                                              RXDOT     234
         YSEL(2,1)=-BRANNO                                              RXDOT     235
         YSEL(2,2)=0.0                                                  RXDOT     236
         YSEL(2,3)=BRANNO                                               RXDOT     237
         YSEL(2,4)=0.0                                                  RXDOT     238
         YSEL(3,1)=0.0                                                  RXDOT     239
         YSEL(3,2)=-BRANNO                                              RXDOT     240
         YSEL(3,3)=0.0                                                  RXDOT     241
         YSEL(3,4)=BRANNO                                               RXDOT     242
         YSEL(4,1)=BRANNO                                               RXDOT     243
         YSEL(4,2)=0.0                                                  RXDOT     244
         YSEL(4,3)=-BRANNO                                              RXDOT     245
         YSEL(4,4)=0.0                                                  RXDOT     246
C                                                                       RXDOT     247
         BRANN=BRANI(JY+2)                                              RXDOT     248
         YDEVS(1,1)=0.0                                                 RXDOT     249
         YDEVS(1,2)=BRANN                                               RXDOT     250
         YDEVS(1,3)=0.0                                                 RXDOT     251
         YDEVS(1,4)=-BRANN                                              RXDOT     252
         YDEVS(2,1)=-BRANN                                              RXDOT     253
         YDEVS(2,2)=0.0                                                 RXDOT     254
         YDEVS(2,3)=BRANN                                               RXDOT     255
         YDEVS(2,4)=0.0                                                 RXDOT     256
         YDEVS(3,1)=0.0                                                 RXDOT     257
         YDEVS(3,2)=-BRANN                                              RXDOT     258
         YDEVS(3,3)=0.0                                                 RXDOT     259
         YDEVS(3,4)=BRANN                                               RXDOT     260
         YDEVS(4,1)=BRANN                                               RXDOT     261
         YDEVS(4,2)=0.0                                                 RXDOT     262
         YDEVS(4,3)=-BRANN                                              RXDOT     263
         YDEVS(4,4)=0.0                                                 RXDOT     264
C                                                                       RXDOT     265
         FACT1=VALIN(5)/VMG                                             RXDOT     266
         FACT2=VALIN(6)/VMG                                             RXDOT     267
         XUV(1,1)=FACT1*VRE                                             RXDOT     268
         XUV(1,2)=FACT1*VIM                                             RXDOT     269
         XUV(1,3)=-FACT1*VRE                                            RXDOT     270
         XUV(1,4)=-FACT1*VIM                                            RXDOT     271
         XUV(2,1)=FACT2*VRE                                             RXDOT     272
         XUV(2,2)=FACT2*VIM                                             RXDOT     273
         XUV(2,3)=-FACT2*VRE                                            RXDOT     274
         XUV(2,4)=-FACT2*VIM                                            RXDOT     275
         XUV(3,1)=2.0*FACT1*VRE*VMG                                     RXDOT     276
         XUV(3,2)=2.0*FACT1*VIM*VMG                                     RXDOT     277
         XUV(3,3)=-2.0*FACT1*VRE*VMG                                    RXDOT     278
         XUV(3,4)=-2.0*FACT1*VIM*VMG                                    RXDOT     279
         XUV(4,1)=2.0*FACT2*VRE*VMG                                     RXDOT     280
         XUV(4,2)=2.0*FACT2*VIM*VMG                                     RXDOT     281
         XUV(4,3)=-2.0*FACT2*VRE*VMG                                    RXDOT     282
         XUV(4,4)=-2.0*FACT2*VIM*VMG                                    RXDOT     283
         XUY(1,IBEND)=VMG                                               RXDOT     284
         XUY(2,IBEND)=VMG                                               RXDOT     285
         XUY(3,IBEND)=VMG**2                                            RXDOT     286
         XUY(4,IBEND)=VMG**2                                            RXDOT     287
         XUY(5,IBEND)=1.0                                               RXDOT     288
         XUY(6,IBEND)=1.0                                               RXDOT     289
      ELSEIF(IRANF.EQ.1) THEN                                           RXDOT     290
         CDEV(1)=VRE                                                    RXDOT     291
         CDEV(2)=VIM                                                    RXDOT     292
         CDEV(3)=-VRE                                                   RXDOT     293
         CDEV(4)=-VIM                                                   RXDOT     294
C                                                                       RXDOT     295
         GRANNO=BRANO(JY+3)                                             RXDOT     296
         YSEL(1,1)=GRANNO                                               RXDOT     297
         YSEL(1,2)=0.0                                                  RXDOT     298
         YSEL(1,3)=-GRANNO                                              RXDOT     299
         YSEL(1,4)=0.0                                                  RXDOT     300
         YSEL(2,1)=0.0                                                  RXDOT     301
         YSEL(2,2)=GRANNO                                               RXDOT     302
         YSEL(2,3)=0.0                                                  RXDOT     303
         YSEL(2,4)=-GRANNO                                              RXDOT     304
         YSEL(3,1)=-GRANNO                                              RXDOT     305
         YSEL(3,2)=0.0                                                  RXDOT     306
         YSEL(3,3)=GRANNO                                               RXDOT     307
         YSEL(3,4)=0.0                                                  RXDOT     308
         YSEL(4,1)=0.0                                                  RXDOT     309
         YSEL(4,2)=-GRANNO                                              RXDOT     310
         YSEL(4,3)=0.0                                                  RXDOT     311
         YSEL(4,4)=GRANNO                                               RXDOT     312
C                                                                       RXDOT     313
         GRANN=BRANI(JY+2)                                              RXDOT     314
         YDEVS(1,1)=GRANN                                               RXDOT     315
         YDEVS(1,2)=0.0                                                 RXDOT     316
         YDEVS(1,3)=-GRANN                                              RXDOT     317
         YDEVS(1,4)=0.0                                                 RXDOT     318
         YDEVS(2,1)=0.0                                                 RXDOT     319
         YDEVS(2,2)=GRANN                                               RXDOT     320
         YDEVS(2,3)=0.0                                                 RXDOT     321
         YDEVS(2,4)=-GRANN                                              RXDOT     322
         YDEVS(3,1)=-GRANN                                              RXDOT     323
         YDEVS(3,2)=0.0                                                 RXDOT     324
         YDEVS(3,3)=GRANN                                               RXDOT     325
         YDEVS(3,4)=0.0                                                 RXDOT     326
         YDEVS(4,1)=0.0                                                 RXDOT     327
         YDEVS(4,2)=-GRANN                                              RXDOT     328
         YDEVS(4,3)=0.0                                                 RXDOT     329
         YDEVS(4,4)=GRANN                                               RXDOT     330
C                                                                       RXDOT     331
         FACT1=VALIN(15)/VMG                                            RXDOT     332
         XUV(1,1)=FACT1*VRE                                             RXDOT     333
         XUV(1,2)=FACT1*VIM                                             RXDOT     334
         XUV(1,3)=-FACT1*VRE                                            RXDOT     335
         XUV(1,4)=-FACT1*VIM                                            RXDOT     336
         XUV(16,1)=2.0*FACT1*VRE*VMG                                    RXDOT     337
         XUV(16,2)=2.0*FACT1*VIM*VMG                                    RXDOT     338
         XUV(16,3)=-2.0*FACT1*VRE*VMG                                   RXDOT     339
         XUV(16,4)=-2.0*FACT1*VIM*VMG                                   RXDOT     340
         XUY(1,IBEND)=VMG                                               RXDOT     341
         XUY(15,IBEND)=1.0                                              RXDOT     342
         XUY(16,IBEND)=VMG**2                                           RXDOT     343
      ELSEIF(IRANF.EQ.2) THEN                                           RXDOT     344
         GRANNO=BRANO(JY+9)                                             RXDOT     345
         BRANNO=BRANO(JY+3)                                             RXDOT     346
         GRANN=BRANI(JY+8)                                              RXDOT     347
         BRANN=BRANI(JY+2)                                              RXDOT     348
         Y02=GRANNO**2+BRANNO**2                                        RXDOT     349
         R0=GRANNO/Y02                                                  RXDOT     350
         X0=BRANNO/Y02                                                  RXDOT     351
         BDEVN=BDEV(JY+5)                                               RXDOT     352
         DX=BDEVN*BASERT-BRANO(JY+10)                                   RXDOT     353
         XT=X0+DX                                                       RXDOT     354
         ZT2=R0**2+XT**2                                                RXDOT     355
         ZT=SQRT(ZT2)                                                   RXDOT     356
C                                                                       RXDOT     357
         CDEV(1)=-2.0*VRE*R0*XT/ZT2/ZT2+VIM*(1.0-2.0*XT*XT/ZT2)/ZT2     RXDOT     358
         CDEV(2)=-2.0*VIM*R0*XT/ZT2/ZT2-VRE*(1.0-2.0*XT*XT/ZT2)/ZT2     RXDOT     359
         CDEV(3)=-CDEV(1)                                               RXDOT     360
         CDEV(4)=-CDEV(2)                                               RXDOT     361
C                                                                       RXDOT     362
         YSEL(1,1)=GRANNO                                               RXDOT     363
         YSEL(1,2)=BRANNO                                               RXDOT     364
         YSEL(1,3)=-GRANNO                                              RXDOT     365
         YSEL(1,4)=-BRANNO                                              RXDOT     366
         YSEL(2,1)=-BRANNO                                              RXDOT     367
         YSEL(2,2)=GRANNO                                               RXDOT     368
         YSEL(2,3)=BRANNO                                               RXDOT     369
         YSEL(2,4)=-GRANNO                                              RXDOT     370
         YSEL(3,1)=-GRANNO                                              RXDOT     371
         YSEL(3,2)=-BRANNO                                              RXDOT     372
         YSEL(3,3)=GRANNO                                               RXDOT     373
         YSEL(3,4)=BRANNO                                               RXDOT     374
         YSEL(4,1)=BRANNO                                               RXDOT     375
         YSEL(4,2)=-GRANNO                                              RXDOT     376
         YSEL(4,3)=-BRANNO                                              RXDOT     377
         YSEL(4,4)=GRANNO                                               RXDOT     378
C                                                                       RXDOT     379
         YDEVS(1,1)=GRANN                                               RXDOT     380
         YDEVS(1,2)=BRANN                                               RXDOT     381
         YDEVS(1,3)=-GRANN                                              RXDOT     382
         YDEVS(1,4)=-BRANN                                              RXDOT     383
         YDEVS(2,1)=-BRANN                                              RXDOT     384
         YDEVS(2,2)=GRANN                                               RXDOT     385
         YDEVS(2,3)=BRANN                                               RXDOT     386
         YDEVS(2,4)=-GRANN                                              RXDOT     387
         YDEVS(3,1)=-GRANN                                              RXDOT     388
         YDEVS(3,2)=-BRANN                                              RXDOT     389
         YDEVS(3,3)=GRANN                                               RXDOT     390
         YDEVS(3,4)=BRANN                                               RXDOT     391
         YDEVS(4,1)=BRANN                                               RXDOT     392
         YDEVS(4,2)=-GRANN                                              RXDOT     393
         YDEVS(4,3)=-BRANN                                              RXDOT     394
         YDEVS(4,4)=GRANN                                               RXDOT     395
C                                                                       RXDOT     396
         FACT1=BASERT/ZT                                                RXDOT     397
         FACT2=FACT1**2                                                 RXDOT     398
         XUV(1,1)=FACT1*VRE/VMG                                         RXDOT     399
         XUV(1,2)=FACT1*VIM/VMG                                         RXDOT     400
         XUV(1,3)=-XUV(1,1)                                             RXDOT     401
         XUV(1,4)=-XUV(1,2)                                             RXDOT     402
         XUV(3,1)=2.0*FACT2*BDEVN*VRE                                   RXDOT     403
         XUV(3,2)=2.0*FACT2*BDEVN*VIM                                   RXDOT     404
         XUV(3,3)=-XUV(3,1)                                             RXDOT     405
         XUV(3,4)=-XUV(3,2)                                             RXDOT     406
C                                                                       RXDOT     407
         XUY(1,IBEND)=-BASERT*FACT1*XT*VMG/ZT2                          RXDOT     408
         XUY(3,IBEND)=FACT2*VMG*VMG*(1.0-2.0*BDEVN*BASERT*XT/ZT2)       RXDOT     409
         XUY(17,IBEND)=1.0                                              RXDOT     410
      ELSEIF(IRANF.EQ.3) THEN                                           RXDOT     411
         CDEV(1)=VIM/VMG                                                RXDOT     412
         CDEV(2)=-VRE/VMG                                               RXDOT     413
         CDEV(3)=-VIM/VMG                                               RXDOT     414
         CDEV(4)=VRE/VMG                                                RXDOT     415
C                                                                       RXDOT     416
         BRANNO=BRANO(JY+3)                                             RXDOT     417
         YSEL(1,1)=0.0                                                  RXDOT     418
         YSEL(1,2)=BRANNO                                               RXDOT     419
         YSEL(1,3)=0.0                                                  RXDOT     420
         YSEL(1,4)=-BRANNO                                              RXDOT     421
         YSEL(2,1)=-BRANNO                                              RXDOT     422
         YSEL(2,2)=0.0                                                  RXDOT     423
         YSEL(2,3)=BRANNO                                               RXDOT     424
         YSEL(2,4)=0.0                                                  RXDOT     425
         YSEL(3,1)=0.0                                                  RXDOT     426
         YSEL(3,2)=-BRANNO                                              RXDOT     427
         YSEL(3,3)=0.0                                                  RXDOT     428
         YSEL(3,4)=BRANNO                                               RXDOT     429
         YSEL(4,1)=BRANNO                                               RXDOT     430
         YSEL(4,2)=0.0                                                  RXDOT     431
         YSEL(4,3)=-BRANNO                                              RXDOT     432
         YSEL(4,4)=0.0                                                  RXDOT     433
C                                                                       RXDOT     434
         BRANN=BRANI(JY+2)                                              RXDOT     435
         YDEVS(1,1)=-BRANN*VIM*VRE/VMG/VMG/VMG                          RXDOT     436
         YDEVS(1,2)=BRANN*VRE*VRE/VMG/VMG/VMG                           RXDOT     437
         YDEVS(1,3)=-YDEVS(1,1)                                         RXDOT     438
         YDEVS(1,4)=-YDEVS(1,2)                                         RXDOT     439
         YDEVS(2,1)=-BRANN*VIM*VIM/VMG/VMG/VMG                          RXDOT     440
         YDEVS(2,2)=BRANN*VIM*VRE/VMG/VMG/VMG                           RXDOT     441
         YDEVS(2,3)=-YDEVS(2,1)                                         RXDOT     442
         YDEVS(2,4)=-YDEVS(2,2)                                         RXDOT     443
         YDEVS(3,1)=-YDEVS(1,1)                                         RXDOT     444
         YDEVS(3,2)=-YDEVS(1,2)                                         RXDOT     445
         YDEVS(3,3)=-YDEVS(1,3)                                         RXDOT     446
         YDEVS(3,4)=-YDEVS(1,4)                                         RXDOT     447
         YDEVS(4,1)=-YDEVS(2,1)                                         RXDOT     448
         YDEVS(4,2)=-YDEVS(2,2)                                         RXDOT     449
         YDEVS(4,3)=-YDEVS(2,3)                                         RXDOT     450
         YDEVS(4,4)=-YDEVS(2,4)                                         RXDOT     451
C                                                                       RXDOT     452
         FACT1=VALIN(1)/VMG                                             RXDOT     453
         XUV(3,1)=FACT1*VRE                                             RXDOT     454
         XUV(3,2)=FACT1*VIM                                             RXDOT     455
         XUV(3,3)=-FACT1*VRE                                            RXDOT     456
         XUV(3,4)=-FACT1*VIM                                            RXDOT     457
         XUV(5,1)=-XUV(3,1)/VMG/VMG                                     RXDOT     458
         XUV(5,2)=-XUV(3,2)/VMG/VMG                                     RXDOT     459
         XUV(5,3)=-XUV(5,1)                                             RXDOT     460
         XUV(5,4)=-XUV(5,2)                                             RXDOT     461
C                                                                       RXDOT     462
         XUY(1,IBEND)=1.0                                               RXDOT     463
         XUY(3,IBEND)=VMG                                               RXDOT     464
         XUY(5,IBEND)=1.0/VMG                                           RXDOT     465
      END IF                                                            RXDOT     466
C                                                                       RXDOT     467
      XUV(7,1)=VRE1/VMG1                                                RXDOT     468
      XUV(7,2)=VIM1/VMG1                                                RXDOT     469
      XUV(8,3)=VRE2/VMG2                                                RXDOT     470
      XUV(8,4)=VIM2/VMG2                                                RXDOT     471
      XUV(9,1)=-VIM1/VMG1/VMG1                                          RXDOT     472
      XUV(9,2)=VRE1/VMG1/VMG1                                           RXDOT     473
      XUV(10,3)=-VIM2/VMG2/VMG2                                         RXDOT     474
      XUV(10,4)=VRE2/VMG2/VMG2                                          RXDOT     475
C                                                                       RXDOT     476
C     FORM THE REMOTE BUS ARRAY AND CONTROL A B C D MATRICES            RXDOT     477
C                                                                       RXDOT     478
      LCYO=1                                                            RXDOT     479
      LWIF=0                                                            RXDOT     480
      NBUSS=2                                                           RXDOT     481
      NBUSR=0                                                           RXDOT     482
      CALL AUDMB(LCYO,LWIF,NBUSR,NBUSS)                                 RXDOT     483
      IF (KERUDM.NE.0) GO TO 900                                        RXDOT     484
C                                                                       RXDOT     485
      IROWAK=4                                                          RXDOT     486
      ICOLBV=2                                                          RXDOT     487
      NBR(1)=K1                                                         RXDOT     488
      NBR(2)=K2                                                         RXDOT     489
      IF (NBUSR.NE.0) THEN                                              RXDOT     490
         DO 120 I=1,NBUSR                                               RXDOT     491
            ICOLBV=ICOLBV+1                                             RXDOT     492
            NBR(ICOLBV)=MBUSR(NBUSS+I)                                  RXDOT     493
  120    CONTINUE                                                       RXDOT     494
      END IF                                                            RXDOT     495
C                                                                       RXDOT     496
C     SOLVE THE CONTROL EQUATIONS                                       RXDOT     497
C                                                                       RXDOT     498
      LREM=2*NBUSR                                                      RXDOT     499
      CALL AUDMC(IROWAK,LCYO,LWIF,LREM)                                 RXDOT     500
      IF (KERUDM.NE.0) GO TO 900                                        RXDOT     501
C                                                                       RXDOT     502
C     FORM: DEL XDOT = AX*X+BXI*DEL I+BXV*DEL V(S&R)                    RXDOT     503
C              DEL I = CX*X+ADEV*DEL I+YDEV*DEL V+YDEVR*DEL VR          RXDOT     504
C                                                                       RXDOT     505
      DO 130 I=1,KORD                                                   RXDOT     506
         DO 140 J=1,KORD                                                RXDOT     507
            AX(I,J)=AXB(I,J)                                            RXDOT     508
  140    CONTINUE                                                       RXDOT     509
  130 CONTINUE                                                          RXDOT     510
C                                                                       RXDOT     511
      DO 150 I=1,KORD                                                   RXDOT     512
         DO 160 J=1,4                                                   RXDOT     513
            BXV(I,J)=BUV(I,J)                                           RXDOT     514
            BXI(I,J)=BUI(I,J)                                           RXDOT     515
            CX(J,I)=CDEV(J)*CYX(1,I)                                    RXDOT     516
  160    CONTINUE                                                       RXDOT     517
  150 CONTINUE                                                          RXDOT     518
C                                                                       RXDOT     519
      DO 170 I=1,4                                                      RXDOT     520
         DO 180 J=1,4                                                   RXDOT     521
            ADEV(J,I)=CDEV(J)*CYI(1,I)                                  RXDOT     522
            YDEVS(J,I)=YDEVS(J,I)+CDEV(J)*CYV(1,I)                      RXDOT     523
  180    CONTINUE                                                       RXDOT     524
  170 CONTINUE                                                          RXDOT     525
C                                                                       RXDOT     526
      IF (NBUSR.NE.0) THEN                                              RXDOT     527
         DO 190 I=1,KORD                                                RXDOT     528
            DO 200 J=1,2*NBUSR                                          RXDOT     529
               BXV(I,J+4)=BUVR(I,J)                                     RXDOT     530
  200       CONTINUE                                                    RXDOT     531
  190    CONTINUE                                                       RXDOT     532
         DO 210 I=1,2*NBUSR                                             RXDOT     533
            DO 220 J=1,4                                                RXDOT     534
               YDEVR(J,I)=CDEV(J)*CYVR(1,I)                             RXDOT     535
  220       CONTINUE                                                    RXDOT     536
  210    CONTINUE                                                       RXDOT     537
      END IF                                                            RXDOT     538
C                                                                       RXDOT     539
C     SOLVE THE DEVICE EQUATIONS                                        RXDOT     540
C                                                                       RXDOT     541
      LREF=1                                                            RXDOT     542
      CALL AUDMD(KORD,IROWAK,LREM,LREF)                                 RXDOT     543
      IF (KERUDM.NE.0) GO TO 900                                        RXDOT     544
C                                                                       RXDOT     545
C     STORE THE REMOTE BUS ADMITANCE                                    RXDOT     546
C                                                                       RXDOT     547
C      IF (NBUSR.NE.0) THEN                                             RXDOT     548
C         DO 230 K=1,NBUSR                                              RXDOT     549
C         DO 230 J=1,2                                                  RXDOT     550
C         DO 230 I=1,2                                                  RXDOT     551
C            KYUDM=KYUDM+1                                              RXDOT     552
C            YKUDM(KYUDM)=YDEVR(I,J+2*K-2)                              RXDOT     553
C  230    CONTINUE                                                      RXDOT     554
C      END IF                                                           RXDOT     555
C                                                                       RXDOT     556
C     LOAD A, B, C, D MATRICES TO WORKING ARRAYS                        RXDOT     557
C                                                                       RXDOT     558
      DO 240 I=1,KORD                                                   RXDOT     559
         DO 250 J=1,KORD                                                RXDOT     560
            A(I,J)=AX(I,J)                                              RXDOT     561
  250    CONTINUE                                                       RXDOT     562
         DO 260 J=1,2*ICOLBV                                            RXDOT     563
            B(I,J)=BXV(I,J)                                             RXDOT     564
  260    CONTINUE                                                       RXDOT     565
         AK(1,I)=CX(1,I)                                                RXDOT     566
         AK(2,I)=CX(2,I)                                                RXDOT     567
         AK(3,I)=CX(3,I)                                                RXDOT     568
         AK(4,I)=CX(4,I)                                                RXDOT     569
  240 CONTINUE                                                          RXDOT     570
      DO 245 I=1,4                                                      RXDOT     571
         DO 246 J=1,4                                                   RXDOT     572
            YD(I,J)=YDEVS(I,J)-YSEL(I,J)                                RXDOT     573
  246    CONTINUE                                                       RXDOT     574
  245 CONTINUE                                                          RXDOT     575
C                                                                       RXDOT     576
      GOTO 270                                                          RXDOT     577
C                                                                       RXDOT     578
  900 CONTINUE                                                          RXDOT     579
      MSG='RXDOT: ERROR IN USER DEFINED RANI'                           RXDOT     580
      CALL ASTOP(MSG,33)                                                RXDOT     581
C                                                                       RXDOT     582
  270 CONTINUE                                                          RXDOT     583
C                                                                       RXDOT     584
C     FINALLY FORM AG, BG, CG MATRICES (JACOBIAN MATRICES)              RXDOT     585
C                                                                       RXDOT     586
      NAIDEX=IAIDEX                                                     RXDOT     587
      NBIDEX=IBIDEX                                                     RXDOT     588
      NCIDEX=ICIDEX                                                     RXDOT     589
C                                                                       RXDOT     590
      IPATH=1                                                           RXDOT     591
      IF (IPATH.EQ.1) THEN                                              RXDOT     592
C                                                                       RXDOT     593
C     FOR USE IN THE NORMAL TRAPEZOIDAL INTEGRATION METHOD              RXDOT     594
C                                                                       RXDOT     595
      DO 280 I=1,KORD                                                   RXDOT     596
         DO 290 J=1,KORD                                                RXDOT     597
            IF (IA(I,J).EQ.0) GOTO 290                                  RXDOT     598
            A(I,J)=-CEFJM*A(I,J)                                        RXDOT     599
 290     CONTINUE                                                       RXDOT     600
         A(I,I)=A(I,I)+1.0                                              RXDOT     601
         DO 300 J=1,2*ICOLBV                                            RXDOT     602
            IF (IB(I,J).EQ.0) GOTO 300                                  RXDOT     603
            B(I,J)=-CEFJM*B(I,J)                                        RXDOT     604
 300     CONTINUE                                                       RXDOT     605
 280  CONTINUE                                                          RXDOT     606
C                                                                       RXDOT     607
C     PERFORM LU FACTORIZATION FOR A                                    RXDOT     608
C                                                                       RXDOT     609
      CALL LUDCM(KORD)                                                  RXDOT     610
C                                                                       RXDOT     611
C     COMPUTE INVERSE(A)*B                                              RXDOT     612
C                                                                       RXDOT     613
      CALL FBSUBA(KORD)                                                 RXDOT     614
C                                                                       RXDOT     615
C     STORE AK IN CJCOB ARRAY                                           RXDOT     616
C                                                                       RXDOT     617
      DO 310 I=1,4                                                      RXDOT     618
         DO 320 J=1,KORD                                                RXDOT     619
            NCIDEX=NCIDEX+1                                             RXDOT     620
            CJCOB(NCIDEX)=-AK(I,J)                                      RXDOT     621
 320     CONTINUE                                                       RXDOT     622
 310  CONTINUE                                                          RXDOT     623
C                                                                       RXDOT     624
C     STORE A AND B IN AJCOB AND BJCOB ARRAY                            RXDOT     625
C                                                                       RXDOT     626
      DO 330 I=1,KORD                                                   RXDOT     627
         DO 340 J=1,KORD                                                RXDOT     628
            NAIDEX=NAIDEX+1                                             RXDOT     629
            AJCOB(NAIDEX)=A(I,J)                                        RXDOT     630
  340    CONTINUE                                                       RXDOT     631
  330 CONTINUE                                                          RXDOT     632
C                                                                       RXDOT     633
      DO 350 I=1,ICOLBV                                                 RXDOT     634
         NBIDEX=NBIDEX+1                                                RXDOT     635
         IBJCOB(NBIDEX)=NBR(I)                                          RXDOT     636
         IWS1=2*I                                                       RXDOT     637
         DO 360 J=1,KORD                                                RXDOT     638
            NBIDEX=NBIDEX+2                                             RXDOT     639
            BJCOB(NBIDEX-1)=B(J,IWS1-1)                                 RXDOT     640
            BJCOB(NBIDEX)=B(J,IWS1)                                     RXDOT     641
  360    CONTINUE                                                       RXDOT     642
  350 CONTINUE                                                          RXDOT     643
      NBIDEX=NBIDEX+1                                                   RXDOT     644
      IBJCOB(NBIDEX)=0                                                  RXDOT     645
C                                                                       RXDOT     646
      ELSE                                                              RXDOT     647
C                                                                       RXDOT     648
C     FOR USE IN GEAR'S METHOD TO CALCULATE THE SECOND ORDER DERIVATIVESRXDOT     649
C                                                                       RXDOT     650
C      DO 370 ILR=1,ISTATE                                              RXDOT     651
C         DO 380 ILC=1,ISTATE                                           RXDOT     652
C            ADGEN(ILR,ILC,N)=A(ILR,ILC)                                RXDOT     653
C 380     CONTINUE                                                      RXDOT     654
C         DO 390 ILC=1,ICOLBV                                           RXDOT     655
C            BDGEN(ILR,ILC,N)=B(ILR,ILC)                                RXDOT     656
C 390     CONTINUE                                                      RXDOT     657
C         DO 400 ILC=1,IROWAK                                           RXDOT     658
C            AKDGEN(ILC,ILR,N)=-AK(ILC,ILR)                             RXDOT     659
C 400     CONTINUE                                                      RXDOT     660
C 370  CONTINUE                                                         RXDOT     661
C                                                                       RXDOT     662
      END IF                                                            RXDOT     663
C                                                                       RXDOT     664
  410 CONTINUE                                                          RXDOT     665
C                                                                       RXDOT     666
C     UPDATE COUNTERS                                                   RXDOT     667
C                                                                       RXDOT     668
      IAIDEX=IAIDEX+KORD*KORD                                           RXDOT     669
      ICIDEX=ICIDEX+4*KORD                                              RXDOT     670
C                                                                       RXDOT     671
  420 IBIDEX=IBIDEX+1                                                   RXDOT     672
      KS=IBJCOB(IBIDEX)                                                 RXDOT     673
      IF (KS.EQ.0) GOTO 500                                             RXDOT     674
      IBIDEX=IBIDEX+2*KORD                                              RXDOT     675
      GOTO 420                                                          RXDOT     676
C                                                                       RXDOT     677
  500 CONTINUE                                                          RXDOT     678
C                                                                       RXDOT     679
      RETURN                                                            RXDOT     680
      END                                                               RXDOT     681
