CFPRIME AGOV7                                                           AGOV7       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 AGOV7(ISTATE,HM)                                       AGOV7       3
CD                                                                      AGOV7       4
CD    TO FORMULATE THE JACOBIAN MATRICES OF TYPE 7 GOVERNOR.            AGOV7       5
CD                                                                      AGOV7       6
      INCLUDE 'PARX.INS'                                                AGOV7       7
      INCLUDE 'CNB8.INS'                                                AGOV7       8
      INCLUDE 'CNB19.INS'                                               AGOV7       9
      INCLUDE 'CNEXC.INS'                                               AGOV7      10
      INCLUDE 'CNPARX.INS'                                              AGOV7      11
      INCLUDE 'CNMDAT.INS'                                              AGOV7      12
      INCLUDE 'CNMSTA.INS'                                              AGOV7      13
      INCLUDE 'CNXSTA.INS'                                              AGOV7      14
      INCLUDE 'CNSTAB.INS'                                              AGOV7      15
C                                                                       AGOV7      16
      INCLUDE 'CNABAK.INS'                                              AGOV7      17
C                                                                       AGOV7      18
C     SUBSCRIPTS                                                        AGOV7      19
C                                                                       AGOV7      20
      ISUB1=ISTATE+1                                                    AGOV7      21
      ISUB2=ISTATE+2                                                    AGOV7      22
      ISUB3=ISTATE+3                                                    AGOV7      23
C                                                                       AGOV7      24
      T2T3=0.0                                                          AGOV7      25
      IDDAT4=IDDAT(JGG+4)                                               AGOV7      26
      ICASE=IDDAT(JGG+11)                                               AGOV7      27
C                                                                       AGOV7      28
      IF (ICASE.EQ.1) THEN                                              AGOV7      29
C                                                                       AGOV7      30
C     CASE 1 -- NORMAL CASE                                             AGOV7      31
C                                                                       AGOV7      32
C--------------------------                                             AGOV7      33
C                                                                       AGOV7      34
C     T1 BLOCK                                                          AGOV7      35
C                                                                       AGOV7      36
         T1I=1.0/DDAT(JGG+2)                                            AGOV7      37
         A(ISUB1,ISUB1)=-T1I                                            AGOV7      38
         A(ISUB1,1)=-T1I/(WXBASE*DDAT(JGG+1))                           AGOV7      39
C                                                                       AGOV7      40
C     T2, T3 BLOCK                                                      AGOV7      41
C                                                                       AGOV7      42
         IF (IDDAT4.NE.0) THEN                                          AGOV7      43
            T3I=1.0/DDAT(JGG+4)                                         AGOV7      44
            T2T3=DDAT(JGG+3)*T3I                                        AGOV7      45
            A(ISUB2,ISUB2)=-T3I                                         AGOV7      46
            A(ISUB2,ISUB1)=T3I-T1I*T2T3                                 AGOV7      47
            A(ISUB2,1)=-T1I*T2T3/(WXBASE*DDAT(JGG+1))                   AGOV7      48
         END IF                                                         AGOV7      49
C                                                                       AGOV7      50
C     T4 BLOCK                                                          AGOV7      51
C                                                                       AGOV7      52
         IF (IDDAT(JGG+8).NE.0) THEN                                    AGOV7      53
            T4I=1.0/DDAT(JGG+8)                                         AGOV7      54
            A(ISUB3,ISUB3)=-T4I                                         AGOV7      55
            A(ISUB3,ISUB2)=T4I                                          AGOV7      56
         END IF                                                         AGOV7      57
C                                                                       AGOV7      58
      ELSE                                                              AGOV7      59
C                                                                       AGOV7      60
C     CASE 2 -- LOWER PATH IS ACTIVE FOR LGV                            AGOV7      61
C                                                                       AGOV7      62
C-------------------------------------------                            AGOV7      63
C                                                                       AGOV7      64
C     T1 BLOCK                                                          AGOV7      65
C                                                                       AGOV7      66
         T1I=1.0/DDAT(JGG+2)                                            AGOV7      67
         A(ISUB1,ISUB1)=-T1I                                            AGOV7      68
C                                                                       AGOV7      69
C     T2, T3 BLOCK                                                      AGOV7      70
C                                                                       AGOV7      71
         IF (IDDAT4.NE.0) THEN                                          AGOV7      72
            T3I=1.0/DDAT(JGG+4)                                         AGOV7      73
            T2T3=DDAT(JGG+3)*T3I                                        AGOV7      74
            A(ISUB2,ISUB2)=-T3I                                         AGOV7      75
            A(ISUB2,ISUB1)=T3I-T1I*T2T3                                 AGOV7      76
         END IF                                                         AGOV7      77
C                                                                       AGOV7      78
C     T4 BLOCK                                                          AGOV7      79
C                                                                       AGOV7      80
         CCT=DDAT(JGG+9)                                                AGOV7      81
         IF (IDDAT(JGG+8).EQ.0) THEN                                    AGOV7      82
            IF (IDDAT4.NE.0) THEN                                       AGOV7      83
               A(ISUB1,ISUB2)=-T1I*CCT                                  AGOV7      84
               A(ISUB2,ISUB2)=A(ISUB2,ISUB2)-T1I*T2T3*CCT               AGOV7      85
            ELSE                                                        AGOV7      86
               A(ISUB1,ISUB1)=A(ISUB1,ISUB1)-T1I*CCT                    AGOV7      87
            END IF                                                      AGOV7      88
         ELSE                                                           AGOV7      89
            T4I=1.0/DDAT(JGG+8)                                         AGOV7      90
            A(ISUB3,ISUB3)=-T4I                                         AGOV7      91
            A(ISUB3,ISUB2)=T4I                                          AGOV7      92
            A(ISUB1,ISUB3)=-T1I*CCT                                     AGOV7      93
            IF (IDDAT4.NE.0) A(ISUB2,ISUB3)=-T1I*T2T3*CCT               AGOV7      94
         END IF                                                         AGOV7      95
C                                                                       AGOV7      96
      END IF                                                            AGOV7      97
C                                                                       AGOV7      98
C     INTEGRATION WITH MACHINE (OUTPUT EQUATION)                        AGOV7      99
C                                                                       AGOV7     100
      PFL=HM*DDAT(JGG+5)                                                AGOV7     101
      IF (IDDAT4.NE.0) THEN                                             AGOV7     102
         A(1,ISUB2)=PFL                                                 AGOV7     103
      ELSE                                                              AGOV7     104
         A(1,ISUB1)=PFL                                                 AGOV7     105
      END IF                                                            AGOV7     106
C                                                                       AGOV7     107
      DWTERM=-PFL*DDAT(JGG+7)/WXBASE                                    AGOV7     108
      A(1,1)=A(1,1)+DWTERM                                              AGOV7     109
C                                                                       AGOV7     110
      ISTATE=ISTATE+3                                                   AGOV7     111
C                                                                       AGOV7     112
      RETURN                                                            AGOV7     113
      END                                                               AGOV7     114
