CFPRIME AGOV1                                                           AGOV1       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 AGOV1(ISTATE,HM)                                       AGOV1       3
CD                                                                      AGOV1       4
CD    TO FORMULATE THE JACOBIAN MATRICES OF TYPES 1 AND 2 GOVERNORS.    AGOV1       5
CD                                                                      AGOV1       6
      INCLUDE 'PARX.INS'                                                AGOV1       7
      INCLUDE 'CNB8.INS'                                                AGOV1       8
      INCLUDE 'CNB19.INS'                                               AGOV1       9
      INCLUDE 'CNEXC.INS'                                               AGOV1      10
      INCLUDE 'CNPARX.INS'                                              AGOV1      11
      INCLUDE 'CNPRGV.INS'                                              AGOV1      12
      INCLUDE 'CNMDAT.INS'                                              AGOV1      13
      INCLUDE 'CNMSTA.INS'                                              AGOV1      14
      INCLUDE 'CNXSTA.INS'                                              AGOV1      15
      INCLUDE 'CNYVAR.INS'                                              AGOV1      16
      INCLUDE 'CNUDMA.INS'                                              AGOV1      17
C                                                                       AGOV1      18
      INCLUDE 'CNABAK.INS'                                              AGOV1      19
C                                                                       AGOV1      20
      DO 50 I=1,NXUDB2                                                  AGOV1      21
      DO 20 J=1,NXUDB2                                                  AGOV1      22
      AXB(I,J)=0.0                                                      AGOV1      23
      BUB(I,J)=0.0                                                      AGOV1      24
  20  CONTINUE                                                          AGOV1      25
      DO 50 J=1,NXUDB                                                   AGOV1      26
      CXB(J,I)=0.0                                                      AGOV1      27
      DUB(J,I)=0.0                                                      AGOV1      28
  50  CONTINUE                                                          AGOV1      29
C                                                                       AGOV1      30
      GAIN=0.0                                                          AGOV1      31
      ILNN=IDDAT(JGG+65)                                                AGOV1      32
C                                                                       AGOV1      33
C     FIRST PART      INPUT  -- VG, VG2                                 AGOV1      34
C                     OUTPUT -- PMECH                                   AGOV1      35
C                                                                       AGOV1      36
C     X DOT = AXB*X + BUB*[VG VG2]                                      AGOV1      37
C     PMECH = CXB*X + DUB*[VG VG2]                                      AGOV1      38
C                                                                       AGOV1      39
C     STATE NUMBER 1 TO 4                                               AGOV1      40
C                                                                       AGOV1      41
C-----------------------------------------------------------------------AGOV1      42
C                                                                       AGOV1      43
C     GAIN OF CONTROL VALVE CHARACTERISTIC                              AGOV1      44
C                                                                       AGOV1      45
      VG=XSTATE(JSTATE+5)                                               AGOV1      46
      IF (VG.GT.DDAT(JGG+57)) THEN                                      AGOV1      47
         GAINC=(1.0-DDAT(JGG+58))/(1.0-DDAT(JGG+57))                    AGOV1      48
      ELSE IF (VG.GT.DDAT(JGG+55)) THEN                                 AGOV1      49
         GAINC=(DDAT(JGG+58)-DDAT(JGG+56))/(DDAT(JGG+57)-DDAT(JGG+55))  AGOV1      50
      ELSE                                                              AGOV1      51
         GAINC=DDAT(JGG+56)/DDAT(JGG+55)                                AGOV1      52
      END IF                                                            AGOV1      53
C                                                                       AGOV1      54
C     GAIN OF INTERCEPT VALVE CHARACTERISTIC                            AGOV1      55
C                                                                       AGOV1      56
      VG2=XSTATE(JSTATE+8)                                              AGOV1      57
      IF (VG2.GT.DDAT(JGG+39)) THEN                                     AGOV1      58
         GAINI=(1.0-DDAT(JGG+40))/(1.0-DDAT(JGG+39))                    AGOV1      59
      ELSE IF (VG2.GT.DDAT(JGG+37)) THEN                                AGOV1      60
         GAINI=(DDAT(JGG+40)-DDAT(JGG+38))/(DDAT(JGG+39)-DDAT(JGG+37))  AGOV1      61
      ELSE                                                              AGOV1      62
         GAINI=DDAT(JGG+38)/DDAT(JGG+37)                                AGOV1      63
      END IF                                                            AGOV1      64
C                                                                       AGOV1      65
C     HP SECTION                                                        AGOV1      66
C                                                                       AGOV1      67
      AXB(1,1)=-1.0/DDAT(JGG+17)                                        AGOV1      68
      AXB(1,2)=(1.0-DDAT(JGG+21))/DDAT(JGG+17)                          AGOV1      69
      BUB(1,1)=GAINC*DDAT(JGG+21)*BLRPR(JYP+3)/DDAT(JGG+17)             AGOV1      70
      CXB(1,1)=DDAT(JGG+22)*DDAT(JGG+24)                                AGOV1      71
      ATERM=GAINC*DDAT(JGG+21)*VG/DDAT(JGG+17)                          AGOV1      72
C                                                                       AGOV1      73
C     REHEATER (RH)                                                     AGOV1      74
C                                                                       AGOV1      75
      AXB(2,2)=-AIV(JYP+5)*GAINI*VG2/DDAT(JGG+18)                       AGOV1      76
      AXB(2,1)=1.0/DDAT(JGG+18)                                         AGOV1      77
      BUB(2,2)=-AIV(JYP+5)*GAINI*XSTATE(JSTATE+2)/DDAT(JGG+18)          AGOV1      78
C                                                                       AGOV1      79
C     IP SECTION                                                        AGOV1      80
C                                                                       AGOV1      81
      IF (IDDAT(JGG+19).NE.0) THEN                                      AGOV1      82
         AXB(3,3)=-1.0/DDAT(JGG+19)                                     AGOV1      83
         AXB(3,2)=AIV(JYP+5)*GAINI*VG2/DDAT(JGG+19)                     AGOV1      84
         BUB(3,2)=AIV(JYP+5)*GAINI*XSTATE(JSTATE+2)/DDAT(JGG+19)        AGOV1      85
         CXB(1,3)=DDAT(JGG+23)*DDAT(JGG+24)                             AGOV1      86
      ELSE                                                              AGOV1      87
         CXB(1,2)=DDAT(JGG+23)*DDAT(JGG+24)*AIV(JYP+5)*GAINI*VG2        AGOV1      88
         DUB(1,2)=DDAT(JGG+23)*DDAT(JGG+24)*AIV(JYP+5)*GAINI            AGOV1      89
     &            *XSTATE(JSTATE+2)                                     AGOV1      90
      END IF                                                            AGOV1      91
C                                                                       AGOV1      92
C     LP SECTION                                                        AGOV1      93
C                                                                       AGOV1      94
      AXB(4,4)=-1.0/DDAT(JGG+20)                                        AGOV1      95
      IF (IDDAT(JGG+19).NE.0) THEN                                      AGOV1      96
         AXB(4,3)=1.0/DDAT(JGG+20)                                      AGOV1      97
      ELSE                                                              AGOV1      98
         AXB(4,2)=AIV(JYP+5)*GAINI*VG2/DDAT(JGG+20)                     AGOV1      99
         BUB(4,2)=AIV(JYP+5)*GAINI*XSTATE(JSTATE+2)/DDAT(JGG+20)        AGOV1     100
      END IF                                                            AGOV1     101
      CXB(1,4)=(1.0-DDAT(JGG+22)-DDAT(JGG+23))*DDAT(JGG+24)             AGOV1     102
C                                                                       AGOV1     103
C     SECOND PART      INPUT  -- XGVS                                   AGOV1     104
C                      OUTPUT -- VG                                     AGOV1     105
C                                                                       AGOV1     106
C     X DOT = AXB*X + BUB*XGVS                                          AGOV1     107
C     VG    = CXB*X + DUB*XGVS                                          AGOV1     108
C                                                                       AGOV1     109
C     STATE NUMBER 5 TO 7                                               AGOV1     110
C                                                                       AGOV1     111
C-----------------------------------------------------------------------AGOV1     112
C                                                                       AGOV1     113
C     C.V. LINEARITY COMPENSATION                                       AGOV1     114
C                                                                       AGOV1     115
      GAINFB=1.0                                                        AGOV1     116
      GAINFF=1.0                                                        AGOV1     117
      IF (ILNN.EQ.0) GOTO 100                                           AGOV1     118
C                                                                       AGOV1     119
      IF (ILNN.EQ.1) THEN                                               AGOV1     120
C                                                                       AGOV1     121
C     FEEDBACK GAIN                                                     AGOV1     122
C                                                                       AGOV1     123
         IF (VG.LT.DDAT(JGG+59).AND.IDDAT(JGG+59).NE.0) THEN            AGOV1     124
            GAINFB=DDAT(JGG+60)/DDAT(JGG+59)                            AGOV1     125
         ELSE IF (VG.LT.DDAT(JGG+61).AND.IDDAT(JGG+61).NE.0) THEN       AGOV1     126
            GAINFB=(DDAT(JGG+62)-DDAT(JGG+60))/                         AGOV1     127
     *             (DDAT(JGG+61)-DDAT(JGG+59))                          AGOV1     128
         ELSE                                                           AGOV1     129
            GAINFB=(1.0-DDAT(JGG+62))/(1.0-DDAT(JGG+61))                AGOV1     130
         END IF                                                         AGOV1     131
C                                                                       AGOV1     132
      ELSE                                                              AGOV1     133
C                                                                       AGOV1     134
C     FEEDFORWARD GAIN                                                  AGOV1     135
C                                                                       AGOV1     136
         XCVPD=XSTATE(JSTATE+7)                                         AGOV1     137
         IF (IDDAT(JGG+51).NE.0) XCVPD=XCVPD+DDAT(JGG+50)*              AGOV1     138
     *                                 DSTATE(ISTATE+7)                 AGOV1     139
         IF (XCVPD.LT.DDAT(JGG+59).AND.IDDAT(JGG+59).NE.0) THEN         AGOV1     140
            GAINFF=DDAT(JGG+60)/DDAT(JGG+59)                            AGOV1     141
         ELSE IF (XCVPD.LT.DDAT(JGG+61).AND.IDDAT(JGG+61).NE.0) THEN    AGOV1     142
            GAINFF=(DDAT(JGG+62)-DDAT(JGG+60))/                         AGOV1     143
     *             (DDAT(JGG+61)-DDAT(JGG+59))                          AGOV1     144
         ELSE                                                           AGOV1     145
            GAINFF=(1.0-DDAT(JGG+62))/(1.0-DDAT(JGG+61))                AGOV1     146
         END IF                                                         AGOV1     147
C                                                                       AGOV1     148
      END IF                                                            AGOV1     149
  100 CONTINUE                                                          AGOV1     150
C                                                                       AGOV1     151
      IF (IDDAT(JGG+47).NE.0) THEN                                      AGOV1     152
         AXB(5,6)=1.0/DDAT(JGG+49)                                      AGOV1     153
         AXB(6,6)=-1.0/DDAT(JGG+47)                                     AGOV1     154
         AXB(6,5)=GAINFB/(DDAT(JGG+47)*DDAT(JGG+48))                    AGOV1     155
         IF (IDDAT(JGG+51).EQ.0) THEN                                   AGOV1     156
            BUB(6,3)=GAINFF/(DDAT(JGG+47)*DDAT(JGG+48))                 AGOV1     157
         ELSE                                                           AGOV1     158
            AXB(6,7)=GAINFF*(1.0-DDAT(JGG+50)/DDAT(JGG+51))             AGOV1     159
     *               /(DDAT(JGG+47)*DDAT(JGG+48))                       AGOV1     160
            BUB(6,3)=GAINFF*DDAT(JGG+50)/(DDAT(JGG+51)*                 AGOV1     161
     *               DDAT(JGG+47)*DDAT(JGG+48))                         AGOV1     162
            AXB(7,7)=-1.0/DDAT(JGG+51)                                  AGOV1     163
            BUB(7,3)=1.0/DDAT(JGG+51)                                   AGOV1     164
         END IF                                                         AGOV1     165
      ELSE                                                              AGOV1     166
         AXB(5,5)=GAINFB/(DDAT(JGG+48)*DDAT(JGG+49))                    AGOV1     167
         IF (IDDAT(JGG+51).EQ.0) THEN                                   AGOV1     168
            BUB(5,3)=GAINFF/(DDAT(JGG+48)*DDAT(JGG+49))                 AGOV1     169
         ELSE                                                           AGOV1     170
            AXB(5,7)=GAINFF*(1.0-DDAT(JGG+50)/DDAT(JGG+51))             AGOV1     171
     *               /(DDAT(JGG+48)*DDAT(JGG+49))                       AGOV1     172
            BUB(5,3)=GAINFF*DDAT(JGG+50)/(DDAT(JGG+51)*                 AGOV1     173
     *               DDAT(JGG+48)*DDAT(JGG+49))                         AGOV1     174
            AXB(7,7)=-1.0/DDAT(JGG+51)                                  AGOV1     175
            BUB(7,3)=1.0/DDAT(JGG+51)                                   AGOV1     176
         END IF                                                         AGOV1     177
      END IF                                                            AGOV1     178
      CXB(2,5)=1.0                                                      AGOV1     179
C                                                                       AGOV1     180
C     THIRD PART      INPUT  -- XGVS                                    AGOV1     181
C                     OUTPUT -- VG2                                     AGOV1     182
C                                                                       AGOV1     183
C     X DOT = AXB*X + BUB*XGVS                                          AGOV1     184
C     VG2   = CXB*X + DUB*XGVS                                          AGOV1     185
C                                                                       AGOV1     186
C     STATE NUMBER 8 TO 10                                              AGOV1     187
C                                                                       AGOV1     188
C-----------------------------------------------------------------------AGOV1     189
C                                                                       AGOV1     190
C     C.V. LINEARITY COMPENSATION                                       AGOV1     191
C                                                                       AGOV1     192
      GAINFB=1.0                                                        AGOV1     193
      GAINFF=1.0                                                        AGOV1     194
      IF (ILNN.EQ.0) GOTO 110                                           AGOV1     195
C                                                                       AGOV1     196
      IF (ILNN.EQ.1) THEN                                               AGOV1     197
C                                                                       AGOV1     198
C     FEEDBACK GAIN                                                     AGOV1     199
C                                                                       AGOV1     200
         IF (VG2.LT.DDAT(JGG+59).AND.IDDAT(JGG+59).NE.0) THEN           AGOV1     201
            GAINFB=DDAT(JGG+60)/DDAT(JGG+59)                            AGOV1     202
         ELSE IF (VG2.LT.DDAT(JGG+61).AND.IDDAT(JGG+61).NE.0) THEN      AGOV1     203
            GAINFB=(DDAT(JGG+62)-DDAT(JGG+60))/                         AGOV1     204
     *             (DDAT(JGG+61)-DDAT(JGG+59))                          AGOV1     205
         ELSE                                                           AGOV1     206
            GAINFB=(1.0-DDAT(JGG+62))/(1.0-DDAT(JGG+61))                AGOV1     207
         END IF                                                         AGOV1     208
C                                                                       AGOV1     209
      ELSE                                                              AGOV1     210
C                                                                       AGOV1     211
C     FEEDFORWARD GAIN                                                  AGOV1     212
C                                                                       AGOV1     213
         XSIV=XSTATE(JSTATE+10)                                         AGOV1     214
         IF (IDDAT(JGG+33).NE.0) XSIV=XSIV+DDAT(JGG+32)*                AGOV1     215
     *                                DSTATE(ISTATE+10)                 AGOV1     216
         XSIV=DDAT(JGG+8)*(XSIV+DDAT(JGG+36))                           AGOV1     217
         IF (XSIV.LT.DDAT(JGG+59).AND.IDDAT(JGG+59).NE.0) THEN          AGOV1     218
            GAINFF=DDAT(JGG+60)/DDAT(JGG+59)                            AGOV1     219
         ELSE IF (XSIV.LT.DDAT(JGG+61).AND.IDDAT(JGG+61).NE.0) THEN     AGOV1     220
            GAINFF=(DDAT(JGG+62)-DDAT(JGG+60))/                         AGOV1     221
     *             (DDAT(JGG+61)-DDAT(JGG+59))                          AGOV1     222
         ELSE                                                           AGOV1     223
            GAINFF=(1.0-DDAT(JGG+62))/(1.0-DDAT(JGG+61))                AGOV1     224
         END IF                                                         AGOV1     225
C                                                                       AGOV1     226
      END IF                                                            AGOV1     227
  110 CONTINUE                                                          AGOV1     228
C                                                                       AGOV1     229
      IF (IDDAT(JGG+30).NE.0) THEN                                      AGOV1     230
         AXB(8,9)=1.0/DDAT(JGG+31)                                      AGOV1     231
         AXB(9,9)=-1.0/DDAT(JGG+29)                                     AGOV1     232
         AXB(9,8)=GAINFB/(DDAT(JGG+29)*DDAT(JGG+30))                    AGOV1     233
         IF (IDDAT(JGG+33).EQ.0) THEN                                   AGOV1     234
            BUB(9,3)=GAINFF*DDAT(JGG+8)/(DDAT(JGG+29)*DDAT(JGG+30))     AGOV1     235
         ELSE                                                           AGOV1     236
            AXB(9,10)=GAINFF*DDAT(JGG+8)*(1.0-DDAT(JGG+32)/DDAT(JGG+33))AGOV1     237
     *                /(DDAT(JGG+29)*DDAT(JGG+30))                      AGOV1     238
            BUB(9,3)=GAINFF*DDAT(JGG+8)*DDAT(JGG+32)/(DDAT(JGG+33)*     AGOV1     239
     *               DDAT(JGG+29)*DDAT(JGG+30))                         AGOV1     240
            AXB(10,10)=-1.0/DDAT(JGG+33)                                AGOV1     241
            BUB(10,3)=1.0/DDAT(JGG+33)                                  AGOV1     242
         END IF                                                         AGOV1     243
      ELSE                                                              AGOV1     244
         AXB(8,8)=GAINFB/(DDAT(JGG+30)*DDAT(JGG+31))                    AGOV1     245
         IF (IDDAT(JGG+33).EQ.0) THEN                                   AGOV1     246
            BUB(8,3)=GAINFF*DDAT(JGG+8)/(DDAT(JGG+30)*DDAT(JGG+31))     AGOV1     247
         ELSE                                                           AGOV1     248
            AXB(8,10)=GAINFF*DDAT(JGG+8)*(1.0-DDAT(JGG+32)/DDAT(JGG+33))AGOV1     249
     *                /(DDAT(JGG+30)*DDAT(JGG+31))                      AGOV1     250
            BUB(8,1)=GAINFF*DDAT(JGG+8)*DDAT(JGG+32)/(DDAT(JGG+33)*     AGOV1     251
     *               DDAT(JGG+30)*DDAT(JGG+31))                         AGOV1     252
            AXB(10,10)=-1.0/DDAT(JGG+33)                                AGOV1     253
            BUB(10,3)=1.0/DDAT(JGG+33)                                  AGOV1     254
         END IF                                                         AGOV1     255
      END IF                                                            AGOV1     256
      CXB(3,8)=1.0                                                      AGOV1     257
C                                                                       AGOV1     258
C     FOURTH PART      INPUT  -- OMEGA                                  AGOV1     259
C                      OUTPUT -- XGVS                                   AGOV1     260
C                                                                       AGOV1     261
C     X DOT = AXB*X + BUB*OMEGA                                         AGOV1     262
C     XGVS  = CXB*X + DUB*OMEGA                                         AGOV1     263
C                                                                       AGOV1     264
C     STATE NUMBER 11                                                   AGOV1     265
C                                                                       AGOV1     266
C     NOTE THAT TYPE 1 AND 2 CODES ARE DIFFERENT FOR THIS PART          AGOV1     267
C                                                                       AGOV1     268
      IF (IGVN.EQ.1) THEN                                               AGOV1     269
         GAIN=DDAT(JGG+1)                                               AGOV1     270
         OVSPD=XSPU-DDAT(JGG+3)                                         AGOV1     271
         IF (OVSPD.GT.0.0) GAIN=DDAT(JGG+2)                             AGOV1     272
      ELSE IF (IGVN.EQ.2) THEN                                          AGOV1     273
         GAIN=DDAT(JGG+1)                                               AGOV1     274
         IF (XSPU.GT.DDAT(JGG+3)) GAIN=GAIN+DDAT(JGG+2)                 AGOV1     275
      END IF                                                            AGOV1     276
C                                                                       AGOV1     277
      IF (IDDAT(JGG+9).NE.0) THEN                                       AGOV1     278
         AXB(11,11)=-1.0/DDAT(JGG+9)                                    AGOV1     279
         BUB(11,4)=-GAIN/DDAT(JGG+9)                                    AGOV1     280
         CXB(4,11)=1.0                                                  AGOV1     281
      ELSE                                                              AGOV1     282
         DUB(4,4)=-GAIN                                                 AGOV1     283
      END IF                                                            AGOV1     284
C                                                                       AGOV1     285
C     ELIMINATE INTERMIDIATE VARIABLES                                  AGOV1     286
C                                                                       AGOV1     287
C     EQUATIONS ARE NOW IN THE FOLLOWING FORM                           AGOV1     288
C                                                                       AGOV1     289
C     X DOT = AXB*X + BUB*U                                             AGOV1     290
C     Y     = CXB*X + DUB*U                                             AGOV1     291
C                                                                       AGOV1     292
C     WHERE                                                             AGOV1     293
C             U = [VG  VG2  XGVS  OMEGA]                                AGOV1     294
C             Y = [PMECH  VG  VG2  XGVS]                                AGOV1     295
C                                                                       AGOV1     296
C     NOTE THAT THE LOWER LEFT 3X3 SUBMATRIX OF DUB IS ZERO             AGOV1     297
C                                                                       AGOV1     298
      DO 120 I=1,11                                                     AGOV1     299
         DO 130 J=1,11                                                  AGOV1     300
            A(ISTATE+I,ISTATE+J)=AXB(I,J)                               AGOV1     301
            DO 140 K=1,3                                                AGOV1     302
               A(ISTATE+I,ISTATE+J)=A(ISTATE+I,ISTATE+J)+               AGOV1     303
     *                              BUB(I,K)*CXB(K+1,J)                 AGOV1     304
  140       CONTINUE                                                    AGOV1     305
  130    CONTINUE                                                       AGOV1     306
         WS1=BUB(I,4)                                                   AGOV1     307
         DO 150 J=1,3                                                   AGOV1     308
            WS1=WS1+BUB(I,J)*DUB(J+1,4)                                 AGOV1     309
  150    CONTINUE                                                       AGOV1     310
         A(ISTATE+I,1)=WS1/WXBASE                                       AGOV1     311
         WS1=CXB(1,I)                                                   AGOV1     312
         DO 160 J=1,3                                                   AGOV1     313
            WS1=WS1+BUB(1,J)*CXB(J+1,I)                                 AGOV1     314
  160    CONTINUE                                                       AGOV1     315
         A(1,ISTATE+I)=HM*WS1                                           AGOV1     316
  120 CONTINUE                                                          AGOV1     317
C                                                                       AGOV1     318
      DWTERM=0.0                                                        AGOV1     319
      ISTATE=ISTATE+11                                                  AGOV1     320
C                                                                       AGOV1     321
      RETURN                                                            AGOV1     322
      END                                                               AGOV1     323
