CFPRIME DE10                                                            DE10        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 DE10(H)                                                DE10        3
CD                                                                      DE10        4
CD    TO CALCULATE THE DERIVATIVES OF THE STATES OF TYPE 10 EXCITER,    DE10        5
CD    USED BY BOTH RUNGE-KUTTA AND TRAPEZOIDAL METHOD.                  DE10        6
CD                                                                      DE10        7
CD    THE DATA STRUCTURE FOR THIS TYPE OF EXCITER IS GIVEN BELOW.       DE10        8
CD                                                                      DE10        9
CD   3.9 Exciter type 10                                                DE10       10
CD                                                                      DE10       11
CD     Exciter data                                                     DE10       12
CD                                                                      DE10       13
CD     IDDAT(JE+ 1)   = IVTN         : sensing bus number               DE10       14
CD     DDAT(JE+ 2)    = KA                                              DE10       15
CD     DDAT(JE+ 3)    = TA                                              DE10       16
CD     DDAT(JE+ 4)    = KE                                              DE10       17
CD     DDAT(JE+ 5)    = TE                                              DE10       18
CD     DDAT(JE+ 6)    = SE(VSAT) or AEX                                 DE10       19
CD     DDAT(JE+ 7)    = SE(0.75VSAT) or BEX                             DE10       20
CD     DDAT(JE+ 8)    = VSAT                                            DE10       21
CD     DDAT(JE+ 9)    = (reserved for future use)                       DE10       22
CD     DDAT(JE+10)    = KF                                              DE10       23
CD     DDAT(JE+11)    = TF1                                             DE10       24
CD     DDAT(JE+12)    = TC                                              DE10       25
CD     DDAT(JE+13)    = TB                                              DE10       26
CD     DDAT(JE+14)    = TF3                                             DE10       27
CD     DDAT(JE+15)    = TF2                                             DE10       28
CD     DDAT(JE+16)    = VRMAX                                           DE10       29
CD     DDAT(JE+17)    = VRMIN                                           DE10       30
CD     DDAT(JE+18)    = TR                                              DE10       31
CD     DDAT(JE+19)    = RC                                              DE10       32
CD     DDAT(JE+20)    = XC                                              DE10       33
CD                                                                      DE10       34
CD     Exciter states                                                   DE10       35
CD                                                                      DE10       36
CD     XSTATE(JES+1)  = TR block     : compulsory                       DE10       37
CD     XSTATE(JES+2)  = TE block     : compulsory                       DE10       38
CD     XSTATE(JES+3)  = TA block     : compulsory                       DE10       39
CD     XSTATE(JES+4)  = TF2 block    : optional                         DE10       40
CD     XSTATE(JES+5)  = TF1 block    : optional                         DE10       41
CD     XSTATE(JES+6)  = TB block     : optional                         DE10       42
CD                                                                      DE10       43
CD     Exciter Y-variables                                              DE10       44
CD                                                                      DE10       45
CD     VREG(JYE+1)    = VC (input to the TR block)                      DE10       46
CD     VREF(JYE+2)    = reference value                                 DE10       47
CD     VRFIN(JYE+3)   = output of TA block                              DE10       48
CD                                                                      DE10       49
      INCLUDE 'PARX.INS'                                                DE10       50
      INCLUDE 'CNPT.INS'                                                DE10       51
      INCLUDE 'CNVOLT.INS'                                              DE10       52
      INCLUDE 'CNIPTR.INS'                                              DE10       53
      INCLUDE 'CNMDAT.INS'                                              DE10       54
      INCLUDE 'CNB3.INS'                                                DE10       55
      INCLUDE 'CNB5.INS'                                                DE10       56
      INCLUDE 'CNB8.INS'                                                DE10       57
      INCLUDE 'CNB9.INS'                                                DE10       58
      INCLUDE 'CNB10.INS'                                               DE10       59
      INCLUDE 'CNB19.INS'                                               DE10       60
      INCLUDE 'CNEXC.INS'                                               DE10       61
      INCLUDE 'CNXSTA.INS'                                              DE10       62
      INCLUDE 'CNQSTA.INS'                                              DE10       63
      INCLUDE 'CNMYVA.INS'                                              DE10       64
      INCLUDE 'CNYVAR.INS'                                              DE10       65
      INCLUDE 'CNFLAG.INS'                                              DE10       66
      INCLUDE 'CNUNIT.INS'                                              DE10       67
      INCLUDE 'CNPREV.INS'                                              DE10       68
      INCLUDE 'CNIMPR.INS'                                              DE10       69
C                                                                       DE10       70
      LOGICAL SLOGIC                                                    DE10       71
C                                                                       DE10       72
C     DECIDE IF SMALLER TIME STEP SHOULD BE TAKEN                       DE10       73
C                                                                       DE10       74
      LDEB=.FALSE.                                                      DE10       75
C                                                                       DE10       76
      DELT=0.0                                                          DE10       77
      IF (IDDAT(JE+24).NE.0) THEN                                       DE10       78
         IF (H.LE.DDAT(JE+25)) THEN                                     DE10       79
            SLOGIC=.FALSE.                                              DE10       80
            KTM=1                                                       DE10       81
         ELSE                                                           DE10       82
            SLOGIC=.TRUE.                                               DE10       83
            KTM=INT(H/DDAT(JE+25)/KSBINT)+1                             DE10       84
            DELT=H/KTM/KSBINT                                           DE10       85
         END IF                                                         DE10       86
      ELSE                                                              DE10       87
         SLOGIC=.FALSE.                                                 DE10       88
         KTM=1                                                          DE10       89
      END IF                                                            DE10       90
C                                                                       DE10       91
      VRMAX=DDAT(JE+16)                                                 DE10       92
      VRMIN=DDAT(JE+17)                                                 DE10       93
C                                                                       DE10       94
      KX1=3                                                             DE10       95
      DO 500 ITM=1,KTM                                                  DE10       96
C                                                                       DE10       97
      NXS=3                                                             DE10       98
C                                                                       DE10       99
C     RATE FEEDBACK BLOCK(S)                                            DE10      100
C                                                                       DE10      101
      XRATE=VRFIN(JYE+3)                                                DE10      102
C                                                                       DE10      103
      IF (IDDAT(JE+15).NE.0) THEN                                       DE10      104
         NXS=4                                                          DE10      105
         DSTATE(LSTATE+4)=(XRATE-XSTATE(JSTATE+4))/DDAT(JE+15)          DE10      106
         V2=XSTATE(JSTATE+4)+DSTATE(LSTATE+4)*DDAT(JE+14)               DE10      107
      ELSE                                                              DE10      108
         V2=XRATE                                                       DE10      109
      END IF                                                            DE10      110
C                                                                       DE10      111
      IF (IDDAT(JE+11).NE.0) THEN                                       DE10      112
         NXS=NXS+1                                                      DE10      113
         DSTATE(LSTATE+NXS)=(V2-XSTATE(JSTATE+NXS))/DDAT(JE+11)         DE10      114
         VF=DSTATE(LSTATE+NXS)*DDAT(JE+10)                              DE10      115
      ELSE                                                              DE10      116
         VF=0.0                                                         DE10      117
      END IF                                                            DE10      118
C                                                                       DE10      119
      VSUM=VREF(JYE+2)-V1-VF                                            DE10      120
C                                                                       DE10      121
      IF (ISTABN.GT.0) VSUM=VSUM+VSS(JYS+1)                             DE10      122
      IF (IUALN.NE.0) VSUM=VSUM+VUAL(JYU+1)                             DE10      123
      IF (ITEBN.NE.0) VSUM=VSUM+TEB(JYTB+1)                             DE10      124
      IF (IMXLN.NE.0) VSUM=VSUM-VMXL(JYMX+1)                            DE10      125
C                                                                       DE10      126
      V3=VSUM                                                           DE10      127
C                                                                       DE10      128
C     LEAD/LAG BLOCK                                                    DE10      129
C                                                                       DE10      130
      IF (IDDAT(JE+13).NE.0) THEN                                       DE10      131
         NXS=NXS+1                                                      DE10      132
         DSTATE(LSTATE+NXS)=(V3-XSTATE(JSTATE+NXS))/DDAT(JE+13)         DE10      133
         V3=XSTATE(JSTATE+NXS)+DSTATE(LSTATE+NXS)*DDAT(JE+12)           DE10      134
      END IF                                                            DE10      135
C                                                                       DE10      136
C     AMPILIFIER BLOCK                                                  DE10      137
C                                                                       DE10      138
      IF (IDDAT(JE+3).NE.0) THEN                                        DE10      139
         DSTATE(LSTATE+3)=(DDAT(JE+2)*V3-XSTATE(JSTATE+3))/DDAT(JE+3)   DE10      140
         VR=XSTATE(JSTATE+3)                                            DE10      141
      ELSE                                                              DE10      142
         VR=DDAT(JE+2)*V3                                               DE10      143
         DSTATE(LSTATE+3)=0.                                            DE10      144
         XSTATE(JSTATE+3)=VR                                            DE10      145
      END IF                                                            DE10      146
C                                                                       DE10      147
      IF (VR.GE.VRMAX) THEN                                             DE10      148
         VR=VRMAX                                                       DE10      149
         IF (DSTATE(LSTATE+3).GT.0.0) THEN                              DE10      150
            DSTATE(LSTATE+3)=0.0                                        DE10      151
            QSTATE(JSTATE+3)=0.0                                        DE10      152
         END IF                                                         DE10      153
      ELSE IF (VR.LE.VRMIN) THEN                                        DE10      154
         VR=VRMIN                                                       DE10      155
         IF (DSTATE(LSTATE+3).LT.0.0) THEN                              DE10      156
            DSTATE(LSTATE+3)=0.0                                        DE10      157
            QSTATE(JSTATE+3)=0.0                                        DE10      158
         END IF                                                         DE10      159
      END IF                                                            DE10      160
C                                                                       DE10      161
      VRFINJ=VR                                                         DE10      162
C                                                                       DE10      163
C     EULER FORWARD METHOD                                              DE10      164
C                                                                       DE10      165
      KX2=NXS                                                           DE10      166
      IF (SLOGIC) THEN                                                  DE10      167
         DO 310 JX=KX1,KX2                                              DE10      168
            XSTATE(JSTATE+JX)=XSTATE(JSTATE+JX)+DELT*DSTATE(LSTATE+JX)  DE10      169
  310    CONTINUE                                                       DE10      170
         IF (XSTATE(JSTATE+3).GT.VRMAX) THEN                            DE10      171
            XSTATE(JSTATE+3)=VRMAX                                      DE10      172
         ELSE IF (XSTATE(JSTATE+3).LT.VRMIN) THEN                       DE10      173
            XSTATE(JSTATE+3)=VRMIN                                      DE10      174
         END IF                                                         DE10      175
         IF (IDDAT(JE+3).NE.0) THEN                                     DE10      176
            VRFINJ=XSTATE(JSTATE+3)                                     DE10      177
         ELSE IF (IDDAT(JE+13).NE.0) THEN                               DE10      178
            VRFINJ=(XSTATE(JSTATE+KX2)+DSTATE(LSTATE+KX2)               DE10      179
     +                   *DDAT(JE+12))*DDAT(JE+2)                       DE10      180
            IF (VRFINJ.GT.VRMAX) THEN                                   DE10      181
               VRFINJ=VRMAX                                             DE10      182
            ELSE IF (VRFINJ.LT.VRMIN) THEN                              DE10      183
               VRFINJ=VRMIN                                             DE10      184
            END IF                                                      DE10      185
         ELSE                                                           DE10      186
            VRFINJ=VSUM*DDAT(JE+2)                                      DE10      187
            IF (VRFINJ.GT.VRMAX) THEN                                   DE10      188
               VRFINJ=VRMAX                                             DE10      189
            ELSE IF (VRFINJ.LT.VRMIN) THEN                              DE10      190
               VRFINJ=VRMIN                                             DE10      191
            END IF                                                      DE10      192
         END IF                                                         DE10      193
         VR=VRFINJ                                                      DE10      194
      END IF                                                            DE10      195
C                                                                       DE10      196
      VRFIN(JYE+3)=VRFINJ                                               DE10      197
C                                                                       DE10      198
  500 CONTINUE                                                          DE10      199
C                                                                       DE10      200
C     IF STATES WERE UPDATED BY INNER LOOP, FOOL THE RKG                DE10      201
C                                                                       DE10      202
      IF (SLOGIC) THEN                                                  DE10      203
         DO 320 JX=KX1,KX2                                              DE10      204
            DSTATE(LSTATE+JX)=0.0                                       DE10      205
  320    CONTINUE                                                       DE10      206
      END IF                                                            DE10      207
C                                                                       DE10      208
      SEKX=DDAT(JE+4)*XSTATE(JSTATE+2)                                  DE10      209
      SEKX=SEKX+DDAT(JE+6)*EXP(DDAT(JE+7)*XSTATE(JSTATE+2))             DE10      210
      VEIN=VR-SEKX                                                      DE10      211
      DSTATE(LSTATE+2)=VEIN/DDAT(JE+5)                                  DE10      212
      EFD(JYG+4)=XSTATE(JSTATE+2)                                       DE10      213
C                                                                       DE10      214
      LSTATE=LSTATE+NXS                                                 DE10      215
C                                                                       DE10      216
      RETURN                                                            DE10      217
C                                                                       DE10      218
      ENTRY DEI10(H)                                                    DE10      219
CD                                                                      DE10      220
CD    TO CALCULATE THE DERIVATIVES OF THE STATES OF TYPE 10 EXCITER,    DE10      221
CD    USED BY TRAPEZOIDAL METHOD.                                       DE10      222
CD                                                                      DE10      223
C                                                                       DE10      224
C     DECIDE IF SMALLER TIME STEP SHOULD BE TAKEN                       DE10      225
C                                                                       DE10      226
      DELT=0.0                                                          DE10      227
      IF (IDDAT(JE+24).NE.0) THEN                                       DE10      228
         IF (H.LE.DDAT(JE+25)) THEN                                     DE10      229
            SLOGIC=.FALSE.                                              DE10      230
            KTM=1                                                       DE10      231
         ELSE                                                           DE10      232
            SLOGIC=.TRUE.                                               DE10      233
            KTM=INT(H/DDAT(JE+25))+1                                    DE10      234
            DELT=H/KTM                                                  DE10      235
            IF (NITER.EQ.0) THEN                                        DE10      236
               IWS1=3                                                   DE10      237
               IF (IDDAT(JE+11).NE.0) IWS1=IWS1+1                       DE10      238
               IF (IDDAT(JE+13).NE.0) IWS1=IWS1+1                       DE10      239
               IF (IDDAT(JE+15).NE.0) IWS1=IWS1+1                       DE10      240
               DO 90 JX=3,IWS1                                          DE10      241
                  XSTATE(JSTATE+JX)=XPREV(1,JSTATE+JX)                  DE10      242
   90          CONTINUE                                                 DE10      243
            END IF                                                      DE10      244
         END IF                                                         DE10      245
      ELSE                                                              DE10      246
         SLOGIC=.FALSE.                                                 DE10      247
         KTM=1                                                          DE10      248
      END IF                                                            DE10      249
C                                                                       DE10      250
C     BYPASS IF SUBDIVISION IS ON AND NITER > 0                         DE10      251
C                                                                       DE10      252
      IF (SLOGIC.AND.NITER.GT.0) GOTO 130                               DE10      253
C                                                                       DE10      254
      VRMAX=DDAT(JE+16)                                                 DE10      255
      VRMIN=DDAT(JE+17)                                                 DE10      256
C                                                                       DE10      257
      KX1=3                                                             DE10      258
      DO 100 ITM=1,KTM                                                  DE10      259
C                                                                       DE10      260
      NXS=3                                                             DE10      261
C                                                                       DE10      262
C     RATE FEEDBACK BLOCK(S)                                            DE10      263
C                                                                       DE10      264
      XRATE=VRFIN(JYE+3)                                                DE10      265
C                                                                       DE10      266
      IF (IDDAT(JE+15).NE.0) THEN                                       DE10      267
         NXS=4                                                          DE10      268
         DSTATE(LSTATE+4)=(XRATE-XSTATE(JSTATE+4))/DDAT(JE+15)          DE10      269
         V2=XSTATE(JSTATE+4)+DSTATE(LSTATE+4)*DDAT(JE+14)               DE10      270
      ELSE                                                              DE10      271
         V2=XRATE                                                       DE10      272
      END IF                                                            DE10      273
C                                                                       DE10      274
      IF (IDDAT(JE+11).NE.0) THEN                                       DE10      275
         NXS=NXS+1                                                      DE10      276
         DSTATE(LSTATE+NXS)=(V2-XSTATE(JSTATE+NXS))/DDAT(JE+11)         DE10      277
         VF=DSTATE(LSTATE+NXS)*DDAT(JE+10)                              DE10      278
      ELSE                                                              DE10      279
         VF=0.0                                                         DE10      280
      END IF                                                            DE10      281
C                                                                       DE10      282
      VSUM=VREF(JYE+2)-V1-VF                                            DE10      283
C                                                                       DE10      284
      IF (ISTABN.GT.0) VSUM=VSUM+VSS(JYS+1)                             DE10      285
      IF (IUALN.NE.0) VSUM=VSUM+VUAL(JYU+1)                             DE10      286
      IF (ITEBN.NE.0) VSUM=VSUM+TEB(JYTB+1)                             DE10      287
      IF (IMXLN.NE.0) VSUM=VSUM-VMXL(JYMX+1)                            DE10      288
C                                                                       DE10      289
      V3=VSUM                                                           DE10      290
C                                                                       DE10      291
C     LEAD/LAG BLOCK                                                    DE10      292
C                                                                       DE10      293
      IF (IDDAT(JE+13).NE.0) THEN                                       DE10      294
         NXS=NXS+1                                                      DE10      295
         DSTATE(LSTATE+NXS)=(V3-XSTATE(JSTATE+NXS))/DDAT(JE+13)         DE10      296
         V3=XSTATE(JSTATE+NXS)+DSTATE(LSTATE+NXS)*DDAT(JE+12)           DE10      297
      END IF                                                            DE10      298
C                                                                       DE10      299
C     AMPILIFIER BLOCK                                                  DE10      300
C                                                                       DE10      301
      IF (IDDAT(JE+3).NE.0) THEN                                        DE10      302
         DSTATE(LSTATE+3)=(DDAT(JE+2)*V3-XSTATE(JSTATE+3))/DDAT(JE+3)   DE10      303
         VR=XSTATE(JSTATE+3)                                            DE10      304
      ELSE                                                              DE10      305
         VR=DDAT(JE+2)*V3                                               DE10      306
         DSTATE(LSTATE+3)=0.                                            DE10      307
         XSTATE(JSTATE+3)=VR                                            DE10      308
      END IF                                                            DE10      309
C                                                                       DE10      310
      IF (VR.GE.VRMAX) THEN                                             DE10      311
         VR=VRMAX                                                       DE10      312
         IF (DSTATE(LSTATE+3).GT.0.0) DSTATE(LSTATE+3)=0.0              DE10      313
      ELSE IF (VR.LE.VRMIN) THEN                                        DE10      314
         VR=VRMIN                                                       DE10      315
         IF (DSTATE(LSTATE+3).LT.0.0) DSTATE(LSTATE+3)=0.0              DE10      316
      END IF                                                            DE10      317
C                                                                       DE10      318
      VRFINJ=VR                                                         DE10      319
C                                                                       DE10      320
C     EULER FORWARD METHOD                                              DE10      321
C                                                                       DE10      322
      KX2=NXS                                                           DE10      323
      IF (SLOGIC) THEN                                                  DE10      324
         DO 110 JX=KX1,KX2                                              DE10      325
            XSTATE(JSTATE+JX)=XSTATE(JSTATE+JX)+DELT*DSTATE(LSTATE+JX)  DE10      326
  110    CONTINUE                                                       DE10      327
         IF (XSTATE(JSTATE+3).GT.VRMAX) THEN                            DE10      328
            XSTATE(JSTATE+3)=VRMAX                                      DE10      329
         ELSE IF (XSTATE(JSTATE+3).LT.VRMIN) THEN                       DE10      330
            XSTATE(JSTATE+3)=VRMIN                                      DE10      331
         END IF                                                         DE10      332
         IF (IDDAT(JE+3).NE.0) THEN                                     DE10      333
            VRFINJ=XSTATE(JSTATE+3)                                     DE10      334
         ELSE IF (IDDAT(JE+13).NE.0) THEN                               DE10      335
            VRFINJ=(XSTATE(JSTATE+KX2)+DSTATE(LSTATE+KX2)               DE10      336
     +                   *DDAT(JE+12))*DDAT(JE+2)                       DE10      337
            IF (VRFINJ.GT.VRMAX) THEN                                   DE10      338
               VRFINJ=VRMAX                                             DE10      339
            ELSE IF (VRFINJ.LT.VRMIN) THEN                              DE10      340
               VRFINJ=VRMIN                                             DE10      341
            END IF                                                      DE10      342
         ELSE                                                           DE10      343
            VRFINJ=VSUM*DDAT(JE+2)                                      DE10      344
            IF (VRFINJ.GT.VRMAX) THEN                                   DE10      345
               VRFINJ=VRMAX                                             DE10      346
            ELSE IF (VRFINJ.LT.VRMIN) THEN                              DE10      347
               VRFINJ=VRMIN                                             DE10      348
            END IF                                                      DE10      349
         END IF                                                         DE10      350
         VR=VRFINJ                                                      DE10      351
      END IF                                                            DE10      352
C                                                                       DE10      353
      VRFIN(JYE+3)=VRFINJ                                               DE10      354
C                                                                       DE10      355
  100 CONTINUE                                                          DE10      356
C                                                                       DE10      357
C     IF STATES WERE UPDATED BY INNER LOOP, FOOL THE RKG                DE10      358
C                                                                       DE10      359
  130 IF (SLOGIC) THEN                                                  DE10      360
         DO 120 JX=KX1,KX2                                              DE10      361
            DSTATE(LSTATE+JX)=0.0                                       DE10      362
  120    CONTINUE                                                       DE10      363
      END IF                                                            DE10      364
C                                                                       DE10      365
      SEKX=DDAT(JE+4)*XSTATE(JSTATE+2)                                  DE10      366
      SEKX=SEKX+DDAT(JE+6)*EXP(DDAT(JE+7)*XSTATE(JSTATE+2))             DE10      367
      VEIN=VR-SEKX                                                      DE10      368
      DSTATE(LSTATE+2)=VEIN/DDAT(JE+5)                                  DE10      369
      EFD(JYG+4)=XSTATE(JSTATE+2)                                       DE10      370
C                                                                       DE10      371
      LSTATE=LSTATE+NXS                                                 DE10      372
C                                                                       DE10      373
      RETURN                                                            DE10      374
      END                                                               DE10      375
