CFPRIME ASTF1                                                           ASTF1       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 ASTF1(ISTATE)                                          ASTF1       3
CD                                                                      ASTF1       4
CD    TO FORMULATE THE JACOBIAN MATRICES OF TYPE 1 STABILIZER TORSIONAL ASTF1       5
CD    FILTER.                                                           ASTF1       6
CD                                                                      ASTF1       7
      INCLUDE 'PARX.INS'                                                ASTF1       8
      INCLUDE 'CNB8.INS'                                                ASTF1       9
      INCLUDE 'CNEXC.INS'                                               ASTF1      10
      INCLUDE 'CNSTAB.INS'                                              ASTF1      11
      INCLUDE 'CNPARX.INS'                                              ASTF1      12
      INCLUDE 'CNMDAT.INS'                                              ASTF1      13
      INCLUDE 'CNXSTA.INS'                                              ASTF1      14
      INCLUDE 'CNMSTA.INS'                                              ASTF1      15
      INCLUDE 'CNUDMB.INS'                                              ASTF1      16
C                                                                       ASTF1      17
      INCLUDE 'CNABAK.INS'                                              ASTF1      18
C                                                                       ASTF1      19
      GAIN=0.0                                                          ASTF1      20
      A4I=0.0                                                           ASTF1      21
      A6A4=0.0                                                          ASTF1      22
      A5A3=0.0                                                          ASTF1      23
      A2I=0.0                                                           ASTF1      24
      A0A2=0.0                                                          ASTF1      25
      A7A1=0.0                                                          ASTF1      26
      IE1=IE                                                            ASTF1      27
C                                                                       ASTF1      28
C     T6 BLOCK                                                          ASTF1      29
C                                                                       ASTF1      30
      IF (IDDAT(JF+1).NE.0) THEN                                        ASTF1      31
         IE=IE+1                                                        ASTF1      32
         T6I=1.0/DDAT(JF+1)                                             ASTF1      33
         A(ISTATE+IE,ISTATE+IE)=-T6I                                    ASTF1      34
         DO 10 I=1,IE1                                                  ASTF1      35
            IWS1=IOUTS(I)                                               ASTF1      36
            A(ISTATE+IE,IWS1)=T6I*ROUTS(I)                              ASTF1      37
   10    CONTINUE                                                       ASTF1      38
         INSTA(IE,1)=ISTATE+IE                                          ASTF1      39
         RINSTA(IE,1)=T6I*DSTB1                                         ASTF1      40
         RINSTA(IE,2)=T6I*DSTB2                                         ASTF1      41
      END IF                                                            ASTF1      42
C                                                                       ASTF1      43
C     A3, A4 BLOCK                                                      ASTF1      44
C                                                                       ASTF1      45
      IF (IDDAT(JF+5).NE.0) THEN                                        ASTF1      46
         IE=IE+2                                                        ASTF1      47
         A4I=1.0/DDAT(JF+5)                                             ASTF1      48
         A6A4=DDAT(JF+4)*A4I                                            ASTF1      49
         A(ISTATE+IE-1,ISTATE+IE)=1.0                                   ASTF1      50
         A(ISTATE+IE,ISTATE+IE-1)=-A4I                                  ASTF1      51
         A(ISTATE+IE,ISTATE+IE)=-DDAT(JF+3)*A4I                         ASTF1      52
         IF (IDDAT(JF+1).NE.0) THEN                                     ASTF1      53
            A(ISTATE+IE,ISTATE+IE-2)=1.0                                ASTF1      54
            INSTA(IE,1)=ISTATE+IE                                       ASTF1      55
            RINSTA(IE,1)=0.0                                            ASTF1      56
            RINSTA(IE,2)=0.0                                            ASTF1      57
         ELSE                                                           ASTF1      58
            DO 20 I=1,IE1                                               ASTF1      59
               IWS1=IOUTS(I)                                            ASTF1      60
               A(ISTATE+IE,IWS1)=ROUTS(I)                               ASTF1      61
   20       CONTINUE                                                    ASTF1      62
            INSTA(IE,1)=ISTATE+IE                                       ASTF1      63
            RINSTA(IE,1)=DSTB1                                          ASTF1      64
            RINSTA(IE,2)=DSTB2                                          ASTF1      65
         END IF                                                         ASTF1      66
         INSTA(IE-1,1)=ISTATE+IE-1                                      ASTF1      67
         RINSTA(IE-1,1)=0.0                                             ASTF1      68
         RINSTA(IE-1,2)=0.0                                             ASTF1      69
      ELSE IF (IDDAT(JF+3).NE.0) THEN                                   ASTF1      70
         IE=IE+1                                                        ASTF1      71
         A3I=1.0/DDAT(JF+3)                                             ASTF1      72
         A5A3=DDAT(JF+2)*A3I                                            ASTF1      73
         A(ISTATE+IE,ISTATE+IE)=-A3I                                    ASTF1      74
         IF (IDDAT(JF+1).NE.0) THEN                                     ASTF1      75
            A(ISTATE+IE,ISTATE+IE-1)=A3I                                ASTF1      76
            INSTA(IE,1)=ISTATE+IE                                       ASTF1      77
            RINSTA(IE,1)=0.0                                            ASTF1      78
            RINSTA(IE,2)=0.0                                            ASTF1      79
         ELSE                                                           ASTF1      80
            DO 30 I=1,IE1                                               ASTF1      81
               IWS1=IOUTS(I)                                            ASTF1      82
               A(ISTATE+IE,IWS1)=A3I*ROUTS(I)                           ASTF1      83
   30       CONTINUE                                                    ASTF1      84
            INSTA(IE,1)=ISTATE+IE                                       ASTF1      85
            RINSTA(IE,1)=A3I*DSTB1                                      ASTF1      86
            RINSTA(IE,2)=A3I*DSTB2                                      ASTF1      87
         END IF                                                         ASTF1      88
      END IF                                                            ASTF1      89
C                                                                       ASTF1      90
C     A1, A2 BLOCK                                                      ASTF1      91
C                                                                       ASTF1      92
      IF (IDDAT(JF+7).NE.0) THEN                                        ASTF1      93
         IE=IE+2                                                        ASTF1      94
         A2I=1.0/DDAT(JF+7)                                             ASTF1      95
         A0A2=DDAT(JF+8)*A2I                                            ASTF1      96
         A(ISTATE+IE-1,ISTATE+IE)=1.0                                   ASTF1      97
         A(ISTATE+IE,ISTATE+IE-1)=-A2I                                  ASTF1      98
         A(ISTATE+IE,ISTATE+IE)=-DDAT(JF+6)*A2I                         ASTF1      99
         IF (IDDAT(JF+5).NE.0) THEN                                     ASTF1     100
            A(ISTATE+IE,ISTATE+IE-2)=A4I*(DDAT(JF+2)-DDAT(JF+3)*A6A4)   ASTF1     101
            A(ISTATE+IE,ISTATE+IE-3)=A4I*(1.0-A6A4)                     ASTF1     102
            GAIN=A6A4                                                   ASTF1     103
         ELSE IF (IDDAT(JF+3).NE.0) THEN                                ASTF1     104
            A(ISTATE+IE,ISTATE+IE-2)=1.0-A5A3                           ASTF1     105
            GAIN=A5A3                                                   ASTF1     106
         END IF                                                         ASTF1     107
         IF (IDDAT(JF+1).NE.0) THEN                                     ASTF1     108
            A(ISTATE+IE,ISTATE+IE1+1)=GAIN                              ASTF1     109
            INSTA(IE,1)=ISTATE+IE                                       ASTF1     110
            RINSTA(IE,1)=0.0                                            ASTF1     111
            RINSTA(IE,2)=0.0                                            ASTF1     112
         ELSE                                                           ASTF1     113
            DO 40 I=1,IE1                                               ASTF1     114
               IWS1=IOUTS(I)                                            ASTF1     115
               A(ISTATE+IE,IWS1)=GAIN*ROUTS(I)                          ASTF1     116
   40       CONTINUE                                                    ASTF1     117
            INSTA(IE,1)=ISTATE+IE                                       ASTF1     118
            RINSTA(IE,1)=GAIN*DSTB1                                     ASTF1     119
            RINSTA(IE,2)=GAIN*DSTB2                                     ASTF1     120
         END IF                                                         ASTF1     121
         INSTA(IE-1,1)=ISTATE+IE-1                                      ASTF1     122
         RINSTA(IE-1,1)=0.0                                             ASTF1     123
         RINSTA(IE-1,2)=0.0                                             ASTF1     124
      ELSE IF (IDDAT(JF+6).NE.0) THEN                                   ASTF1     125
         IE=IE+1                                                        ASTF1     126
         A1I=1.0/DDAT(JF+6)                                             ASTF1     127
         A7A1=DDAT(JF+11)*A1I                                           ASTF1     128
         A(ISTATE+IE,ISTATE+IE)=-A1I                                    ASTF1     129
         IF (IDDAT(JF+5).NE.0) THEN                                     ASTF1     130
            A(ISTATE+IE,ISTATE+IE-1)=A1I*A4I*(DDAT(JF+2)-               ASTF1     131
     *                               DDAT(JF+3)*A6A4)                   ASTF1     132
            A(ISTATE+IE,ISTATE+IE-2)=A1I*A4I*(1.0-A6A4)                 ASTF1     133
            GAIN=A6A4                                                   ASTF1     134
         ELSE IF (IDDAT(JF+3).NE.0) THEN                                ASTF1     135
            A(ISTATE+IE,ISTATE+IE-1)=A1I*(1.0-A5A3)                     ASTF1     136
            GAIN=A5A3                                                   ASTF1     137
         END IF                                                         ASTF1     138
         IF (IDDAT(JF+1).NE.0) THEN                                     ASTF1     139
            A(ISTATE+IE,ISTATE+IE1+1)=GAIN                              ASTF1     140
            INSTA(IE,1)=ISTATE+IE                                       ASTF1     141
            RINSTA(IE,1)=0.0                                            ASTF1     142
            RINSTA(IE,2)=0.0                                            ASTF1     143
         ELSE                                                           ASTF1     144
            DO 50 I=1,IE1                                               ASTF1     145
               IWS1=IOUTS(I)                                            ASTF1     146
               A(ISTATE+IE,IWS1)=GAIN*ROUTS(I)                          ASTF1     147
   50       CONTINUE                                                    ASTF1     148
            INSTA(IE,1)=ISTATE+IE                                       ASTF1     149
            RINSTA(IE,1)=GAIN*DSTB1                                     ASTF1     150
            RINSTA(IE,2)=GAIN*DSTB2                                     ASTF1     151
         END IF                                                         ASTF1     152
      END IF                                                            ASTF1     153
C                                                                       ASTF1     154
C     OUTPUT EQUATION                                                   ASTF1     155
C                                                                       ASTF1     156
      IE2=IE+1                                                          ASTF1     157
      IF (IDDAT(JF+7).NE.0) THEN                                        ASTF1     158
         IE2=IE2-2                                                      ASTF1     159
         IOUTS(IE2+1)=ISTATE+IE2+1                                      ASTF1     160
         ROUTS(IE2+1)=A2I*(DDAT(JF+11)-DDAT(JF+6)*A0A2)                 ASTF1     161
         IOUTS(IE2)=ISTATE+IE2                                          ASTF1     162
         ROUTS(IE2)=A2I*(1.0-A0A2)                                      ASTF1     163
         GAIN=A0A2                                                      ASTF1     164
      ELSE                                                              ASTF1     165
         IE2=IE2-1                                                      ASTF1     166
         IOUTS(IE2)=ISTATE+IE2                                          ASTF1     167
         ROUTS(IE2)=1.0-A7A1                                            ASTF1     168
         GAIN=A7A1                                                      ASTF1     169
      END IF                                                            ASTF1     170
      IF (IDDAT(JF+5).NE.0) THEN                                        ASTF1     171
         IE2=IE2-2                                                      ASTF1     172
         IOUTS(IE2+1)=ISTATE+IE2+1                                      ASTF1     173
         ROUTS(IE2+1)=GAIN*A4I*(DDAT(JF+2)-DDAT(JF+3)*A6A4)             ASTF1     174
         IOUTS(IE2)=ISTATE+IE2                                          ASTF1     175
         ROUTS(IE2)=GAIN*A4I*(1.0-A6A4)                                 ASTF1     176
         GAIN=GAIN*A6A4                                                 ASTF1     177
      ELSE                                                              ASTF1     178
         IE2=IE2-1                                                      ASTF1     179
         IOUTS(IE2)=ISTATE+IE2                                          ASTF1     180
         ROUTS(IE2)=GAIN*(1.0-A5A3)                                     ASTF1     181
         GAIN=GAIN*A5A3                                                 ASTF1     182
      END IF                                                            ASTF1     183
      IF (IDDAT(JF+1).NE.0) THEN                                        ASTF1     184
         IE2=IE2-1                                                      ASTF1     185
         IOUTS(IE2)=ISTATE+IE2                                          ASTF1     186
         ROUTS(IE2)=GAIN                                                ASTF1     187
         DO 60 I=1,IE1                                                  ASTF1     188
            ROUTS(I)=0.0                                                ASTF1     189
   60    CONTINUE                                                       ASTF1     190
         DSTB1=0.0                                                      ASTF1     191
         DSTB2=0.0                                                      ASTF1     192
      ELSE                                                              ASTF1     193
         DO 70 I=1,IE1                                                  ASTF1     194
            ROUTS(I)=GAIN*ROUTS(I)                                      ASTF1     195
   70    CONTINUE                                                       ASTF1     196
         DSTB1=GAIN*DSTB1                                               ASTF1     197
         DSTB2=GAIN*DSTB2                                               ASTF1     198
      END IF                                                            ASTF1     199
C                                                                       ASTF1     200
      RETURN                                                            ASTF1     201
      END                                                               ASTF1     202
