CFPRIME ISTAB9                                                          ISTAB9      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 ISTAB9(ISMAX,ISMIN,KBUSNO)                             ISTAB9      3
CD                                                                      ISTAB9      4
CD    TO PERFORM INITIALIZATION AND DATA CHECK FOR STABILIZER TYPE 9.   ISTAB9      5
CD                                                                      ISTAB9      6
CD    THE DATA STRUCTURE AFTER THE INITIALIZATION IS GIVEN BELOW.       ISTAB9      7
CD                                                                      ISTAB9      8
CD   4.8 Stabilizer type 9                                              ISTAB9      9
CD                                                                      ISTAB9     10
CD     Stabilizer data                                                  ISTAB9     11
CD                                                                      ISTAB9     12
CD     IDDAT(JS+ 1)   = BUSR         : sensing bus number               ISTAB9     13
CD     IDDAT(JS +2)   = TYPE         : type of input signal:            ISTAB9     14
CD                                     = 1 rotor speed                  ISTAB9     15
CD                                     = 2 acceleration power           ISTAB9     16
CD                                     = 3 bus frequency                ISTAB9     17
CD                                     = 4 electrical power             ISTAB9     18
CD                                     = 5 bus voltage magnitude        ISTAB9     19
CD                                     = 6 voltage deviation from steadyISTAB9     20
CD                                        state value                   ISTAB9     21
CD     IDDAT(JS+ 3)   = 0                                               ISTAB9     22
CD     IDDAT(JS+ 4)   = 4                                               ISTAB9     23
CD     IDDAT(JS+ 5)   = N                                               ISTAB9     24
CD     IDDAT(JS+ 6)   = M                                               ISTAB9     25
CD     DDAT(JS+ 7)    = T11                                             ISTAB9     26
CD     DDAT(JS+ 8)    = T12                                             ISTAB9     27
CD     DDAT(JS+ 9)    = T1                                              ISTAB9     28
CD     DDAT(JS+10)    = T2                                              ISTAB9     29
CD     DDAT(JS+11)    = T3                                              ISTAB9     30
CD     DDAT(JS+12)    = T4                                              ISTAB9     31
CD     DDAT(JS+13)    = VSMAX                                           ISTAB9     32
CD     DDAT(JS+14)    = VSMIN                                           ISTAB9     33
CD     DDAT(JS+15)    = KS1                                             ISTAB9     34
CD     DDAT(JS+16)    = T5                                              ISTAB9     35
CD     DDAT(JS+17)    = T6                                              ISTAB9     36
CD     DDAT(JS+18)    = T7                                              ISTAB9     37
CD     DDAT(JS+19)    = KS2                                             ISTAB9     38
CD     DDAT(JS+20)    = T8                                              ISTAB9     39
CD     DDAT(JS+21)    = T9                                              ISTAB9     40
CD     DDAT(JS+22)    = T10                                             ISTAB9     41
CD     DDAT(JS+23)    = KS3                                             ISTAB9     42
CD     DDAT(JS+24)    = TFD                                             ISTAB9     43
CD     DDAT(JS+25)    = TFG                                             ISTAB9     44
CD     DDAT(JS+26)    = TF                                              ISTAB9     45
CD     DDAT(JS+27)    = RC                                              ISTAB9     46
CD     DDAT(JS+28)    = XC                                              ISTAB9     47
CD     DDAT(JS+29)    = PTHR                                            ISTAB9     48
CD                                                                      ISTAB9     49
CD     Stabilizer states                                                ISTAB9     50
CD                                                                      ISTAB9     51
CD     XSTATE(JSS+1)  = TF block if input is bus frequency              ISTAB9     52
CD                                                  : optional          ISTAB9     53
CD     XSTATE(JSS+2)  = T5 block                    : optional          ISTAB9     54
CD     XSTATE(JSS+3)  = T6 block                    : optional          ISTAB9     55
CD     XSTATE(JSS+4)  = T7 block                    : optional          ISTAB9     56
CD     XSTATE(JSS+5)  = T8 block                    : optional          ISTAB9     57
CD     XSTATE(JSS+6)  = T9 block                    : optional          ISTAB9     58
CD     XSTATE(JSS+7)  = T10 block                   : optional          ISTAB9     59
CD     XSTATE(JSS+8)  = state no. 1 In TFG block         : optional     ISTAB9     60
CD                                                  : all optional      ISTAB9     61
CD     XSTATE(JSS+N+7)         = state no. N in TFG block          : optISTAB9     62
CD     XSTATE(JSS+N+8)         = T11 block                         : optISTAB9     63
CD     XSTATE(JSS+N+9)         = T2 block                          : optISTAB9     64
CD     XSTATE(JSS+N+10) = T4 block                       : optional     ISTAB9     65
CD                                                                      ISTAB9     66
CD     Where N = IDDAT(JS+5)                                            ISTAB9     67
CD                                                                      ISTAB9     68
CD     Stabilizer Y-variables                                           ISTAB9     69
CD                                                                      ISTAB9     70
CD     VSS(JYS+1)     = stabilizer output                               ISTAB9     71
CD                                                                      ISTAB9     72
      INCLUDE 'PARX.INS'                                                ISTAB9     73
      INCLUDE 'CNB1.INS'                                                ISTAB9     74
      INCLUDE 'CNB4.INS'                                                ISTAB9     75
      INCLUDE 'CNMDAT.INS'                                              ISTAB9     76
      INCLUDE 'CNSTN.INS'                                               ISTAB9     77
      INCLUDE 'CNVOLT.INS'                                              ISTAB9     78
      INCLUDE 'CNXSTA.INS'                                              ISTAB9     79
      INCLUDE 'CNEXC.INS'                                               ISTAB9     80
      INCLUDE 'CNB19.INS'                                               ISTAB9     81
      INCLUDE 'CNYVAR.INS'                                              ISTAB9     82
      INCLUDE 'CNFLAG.INS'                                              ISTAB9     83
      INCLUDE 'CNUNIT.INS'                                              ISTAB9     84
      INCLUDE 'CNIMPR.INS'                                              ISTAB9     85
      INCLUDE 'CNMSG.INS'                                               ISTAB9     86
C                                                                       ISTAB9     87
      DATA BIG/99.9/                                                    ISTAB9     88
C                                                                       ISTAB9     89
      LDEB=(JDEB(74).NE.0)                                              ISTAB9     90
C                                                                       ISTAB9     91
      IF (IDDAT(JS+2).EQ.0) IDDAT(JS+2)=1                               ISTAB9     92
C                                                                       ISTAB9     93
C  INPUT TIME CONSTANTS CHECK AND RESET                                 ISTAB9     94
C                                                                       ISTAB9     95
      IF(DDAT(JS+8).LT.TMIN.AND.IDDAT(JS+8).NE.0)THEN                   ISTAB9     96
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       ISTAB9     97
     *                     ,NDGC(N)                                     ISTAB9     98
         WRITE(MSG(2),9020) 'T12',DDAT(JS+8),TMIN                       ISTAB9     99
         IF(MTFLAG.EQ.0) THEN                                           ISTAB9    100
            CALL PRTMSG(2)                                              ISTAB9    101
         ELSE                                                           ISTAB9    102
            WRITE(MSG(3),9030) 'T12',0.0                                ISTAB9    103
            CALL PRTMSG(3)                                              ISTAB9    104
            DDAT(JS+8)=0.0                                              ISTAB9    105
         ENDIF                                                          ISTAB9    106
      ENDIF                                                             ISTAB9    107
C                                                                       ISTAB9    108
      IF(DDAT(JS+10).LT.TMIN.AND.IDDAT(JS+10).NE.0)THEN                 ISTAB9    109
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       ISTAB9    110
     *                     ,NDGC(N)                                     ISTAB9    111
         WRITE(MSG(2),9020) 'T2',DDAT(JS+10),TMIN                       ISTAB9    112
         IF(MTFLAG.EQ.0) THEN                                           ISTAB9    113
            CALL PRTMSG(2)                                              ISTAB9    114
         ELSE                                                           ISTAB9    115
            WRITE(MSG(3),9030) 'T2',0.0                                 ISTAB9    116
            CALL PRTMSG(3)                                              ISTAB9    117
            DDAT(JS+10)=0.0                                             ISTAB9    118
         ENDIF                                                          ISTAB9    119
      ENDIF                                                             ISTAB9    120
C                                                                       ISTAB9    121
      IF(DDAT(JS+12).LT.TMIN.AND.IDDAT(JS+12).NE.0)THEN                 ISTAB9    122
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       ISTAB9    123
     *                     ,NDGC(N)                                     ISTAB9    124
         WRITE(MSG(2),9020) 'T4',DDAT(JS+12),TMIN                       ISTAB9    125
         IF(MTFLAG.EQ.0) THEN                                           ISTAB9    126
            CALL PRTMSG(2)                                              ISTAB9    127
         ELSE                                                           ISTAB9    128
            WRITE(MSG(3),9030) 'T4',0.0                                 ISTAB9    129
            CALL PRTMSG(3)                                              ISTAB9    130
            DDAT(JS+12)=0.0                                             ISTAB9    131
         ENDIF                                                          ISTAB9    132
      ENDIF                                                             ISTAB9    133
C                                                                       ISTAB9    134
      IF(DDAT(JS+16).LT.TMIN.AND.IDDAT(JS+16).NE.0)THEN                 ISTAB9    135
         WRITE(MSG(1),9040) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       ISTAB9    136
     *                     ,NDGC(N)                                     ISTAB9    137
         WRITE(MSG(2),9020) 'T5',DDAT(JS+16),TMIN                       ISTAB9    138
         CALL PRTMSG(2)                                                 ISTAB9    139
         MSG(1)='STABILIZER DATA ERROR'                                 ISTAB9    140
         CALL ASTOP(MSG(1),21)                                          ISTAB9    141
      ENDIF                                                             ISTAB9    142
C                                                                       ISTAB9    143
      IF(DDAT(JS+17).LT.TMIN.AND.IDDAT(JS+17).NE.0)THEN                 ISTAB9    144
         WRITE(MSG(1),9040) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       ISTAB9    145
     *                     ,NDGC(N)                                     ISTAB9    146
         WRITE(MSG(2),9020) 'T6',DDAT(JS+17),TMIN                       ISTAB9    147
         CALL PRTMSG(2)                                                 ISTAB9    148
         MSG(1)='STABILIZER DATA ERROR'                                 ISTAB9    149
         CALL ASTOP(MSG(1),21)                                          ISTAB9    150
      ENDIF                                                             ISTAB9    151
C                                                                       ISTAB9    152
      IF(DDAT(JS+18).LT.TMIN.AND.IDDAT(JS+18).NE.0)THEN                 ISTAB9    153
         WRITE(MSG(1),9040) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       ISTAB9    154
     *                     ,NDGC(N)                                     ISTAB9    155
         WRITE(MSG(2),9020) 'T7',DDAT(JS+18),TMIN                       ISTAB9    156
         IF(MTFLAG.EQ.0) THEN                                           ISTAB9    157
            CALL PRTMSG(2)                                              ISTAB9    158
         ELSE                                                           ISTAB9    159
            WRITE(MSG(3),9030) 'T7',0.0                                 ISTAB9    160
            CALL PRTMSG(3)                                              ISTAB9    161
            DDAT(JS+18)=0.0                                             ISTAB9    162
         ENDIF                                                          ISTAB9    163
      ENDIF                                                             ISTAB9    164
C                                                                       ISTAB9    165
      IF(DDAT(JS+20).LT.TMIN.AND.IDDAT(JS+20).NE.0)THEN                 ISTAB9    166
         WRITE(MSG(1),9040) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       ISTAB9    167
     *                     ,NDGC(N)                                     ISTAB9    168
         WRITE(MSG(2),9020) 'T8',DDAT(JS+20),TMIN                       ISTAB9    169
         CALL PRTMSG(2)                                                 ISTAB9    170
         MSG(1)='STABILIZER DATA ERROR'                                 ISTAB9    171
         CALL ASTOP(MSG(1),21)                                          ISTAB9    172
      ENDIF                                                             ISTAB9    173
C                                                                       ISTAB9    174
      IF(DDAT(JS+21).LT.TMIN.AND.IDDAT(JS+21).NE.0)THEN                 ISTAB9    175
         WRITE(MSG(1),9040) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       ISTAB9    176
     *                     ,NDGC(N)                                     ISTAB9    177
         WRITE(MSG(2),9020) 'T9',DDAT(JS+21),TMIN                       ISTAB9    178
         CALL PRTMSG(2)                                                 ISTAB9    179
         MSG(1)='STABILIZER DATA ERROR'                                 ISTAB9    180
         CALL ASTOP(MSG(1),21)                                          ISTAB9    181
      ENDIF                                                             ISTAB9    182
C                                                                       ISTAB9    183
      IF(DDAT(JS+22).LT.TMIN.AND.IDDAT(JS+22).NE.0)THEN                 ISTAB9    184
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       ISTAB9    185
     *                     ,NDGC(N)                                     ISTAB9    186
         WRITE(MSG(2),9020) 'T10',DDAT(JS+22),TMIN                      ISTAB9    187
         IF(MTFLAG.EQ.0) THEN                                           ISTAB9    188
            CALL PRTMSG(2)                                              ISTAB9    189
         ELSE                                                           ISTAB9    190
            WRITE(MSG(3),9030) 'T10',0.0                                ISTAB9    191
            CALL PRTMSG(3)                                              ISTAB9    192
            DDAT(JS+22)=0.0                                             ISTAB9    193
         ENDIF                                                          ISTAB9    194
      ENDIF                                                             ISTAB9    195
C                                                                       ISTAB9    196
      IF(DDAT(JS+25).LT.TMIN.AND.IDDAT(JS+25).NE.0)THEN                 ISTAB9    197
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       ISTAB9    198
     *                     ,NDGC(N)                                     ISTAB9    199
         WRITE(MSG(2),9020) 'TFG',DDAT(JS+25),TMIN                      ISTAB9    200
         IF(MTFLAG.EQ.0) THEN                                           ISTAB9    201
            CALL PRTMSG(2)                                              ISTAB9    202
         ELSE                                                           ISTAB9    203
            WRITE(MSG(3),9030) 'TFG',0.0                                ISTAB9    204
            CALL PRTMSG(3)                                              ISTAB9    205
            DDAT(JS+25)=0.0                                             ISTAB9    206
         ENDIF                                                          ISTAB9    207
      ENDIF                                                             ISTAB9    208
C                                                                       ISTAB9    209
C     DDAT(JS+30) THROUGH DDAT(JS+39) ARE USED TO STORE THE             ISTAB9    210
C     SUBSCRIPTS OF OPTIONAL BLOCKS. IF ZERO, THE CORRESPONDING         ISTAB9    211
C     BLOCK IS NOT PRESENT.                                             ISTAB9    212
C                                                                       ISTAB9    213
         IDDAT(JS+30)=0                                                 ISTAB9    214
         IDDAT(JS+31)=0                                                 ISTAB9    215
         IDDAT(JS+32)=0                                                 ISTAB9    216
         IDDAT(JS+33)=0                                                 ISTAB9    217
         IDDAT(JS+34)=0                                                 ISTAB9    218
         IDDAT(JS+35)=0                                                 ISTAB9    219
         IDDAT(JS+36)=0                                                 ISTAB9    220
         IDDAT(JS+37)=0                                                 ISTAB9    221
         IDDAT(JS+38)=0                                                 ISTAB9    222
         IDDAT(JS+39)=0                                                 ISTAB9    223
C                                                                       ISTAB9    224
C   TYPE 9 STABILIZER -- PSS2A                                          ISTAB9    225
C                                                                       ISTAB9    226
        IF (IDDAT(JS+13).EQ.0.AND.IDDAT(JS+14).EQ.0) THEN               ISTAB9    227
           DDAT(JS+13)=BIG                                              ISTAB9    228
           DDAT(JS+14)=-BIG                                             ISTAB9    229
        ENDIF                                                           ISTAB9    230
        IF (DDAT(JS+13).LT.0.0.OR.DDAT(JS+14).GT.0.0) THEN              ISTAB9    231
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       ISTAB9    232
     *                     ,NDGC(N)                                     ISTAB9    233
         WRITE(MSG(2),9060) DDAT(JS+13),DDAT(JS+14)                     ISTAB9    234
         CALL PRTMSG(2)                                                 ISTAB9    235
        END IF                                                          ISTAB9    236
        ISMAX=JS+13                                                     ISTAB9    237
        ISMIN=JS+14                                                     ISTAB9    238
C                                                                       ISTAB9    239
        IF (IDDAT(JS+16).EQ.0.AND.IDDAT(JS+17).NE.0) THEN               ISTAB9    240
           DDAT(JS+16)=DDAT(JS+17)                                      ISTAB9    241
           DDAT(JS+17)=0.0                                              ISTAB9    242
        ENDIF                                                           ISTAB9    243
        IF (IDDAT(JS+20).EQ.0.AND.IDDAT(JS+21).NE.0) THEN               ISTAB9    244
           DDAT(JS+20)=DDAT(JS+21)                                      ISTAB9    245
           DDAT(JS+21)=0.0                                              ISTAB9    246
        ENDIF                                                           ISTAB9    247
C                                                                       ISTAB9    248
        VSI1=VSI1*DDAT(JS+15)                                           ISTAB9    249
        IF (IDDAT(JS+16).NE.0) THEN                                     ISTAB9    250
           KSTATE=KSTATE+1                                              ISTAB9    251
           XSTATE(JSTATE+KSTATE)=VSI1                                   ISTAB9    252
           VSI1=0.0                                                     ISTAB9    253
           IDDAT(JS+30)=JSTATE+KSTATE-NSTATE                            ISTAB9    254
        ENDIF                                                           ISTAB9    255
        IF (IDDAT(JS+17).NE.0) THEN                                     ISTAB9    256
           KSTATE=KSTATE+1                                              ISTAB9    257
           XSTATE(JSTATE+KSTATE)=0.0                                    ISTAB9    258
           IDDAT(JS+31)=JSTATE+KSTATE-NSTATE                            ISTAB9    259
        ENDIF                                                           ISTAB9    260
        IF (IDDAT(JS+18).NE.0) THEN                                     ISTAB9    261
           KSTATE=KSTATE+1                                              ISTAB9    262
           XSTATE(JSTATE+KSTATE)=VSI1                                   ISTAB9    263
           IDDAT(JS+32)=JSTATE+KSTATE-NSTATE                            ISTAB9    264
        ENDIF                                                           ISTAB9    265
        IF (IDDAT(JS+20).NE.0) THEN                                     ISTAB9    266
           KSTATE=KSTATE+1                                              ISTAB9    267
           XSTATE(JSTATE+KSTATE)=VSI2                                   ISTAB9    268
           VSI2=0.0                                                     ISTAB9    269
           IDDAT(JS+33)=JSTATE+KSTATE-NSTATE                            ISTAB9    270
        ENDIF                                                           ISTAB9    271
        IF (IDDAT(JS+21).NE.0) THEN                                     ISTAB9    272
           KSTATE=KSTATE+1                                              ISTAB9    273
           XSTATE(JSTATE+KSTATE)=0.0                                    ISTAB9    274
           IDDAT(JS+34)=JSTATE+KSTATE-NSTATE                            ISTAB9    275
        ENDIF                                                           ISTAB9    276
        VSI2=VSI2*DDAT(JS+19)                                           ISTAB9    277
        IF (IDDAT(JS+22).NE.0) THEN                                     ISTAB9    278
           KSTATE=KSTATE+1                                              ISTAB9    279
           XSTATE(JSTATE+KSTATE)=VSI2                                   ISTAB9    280
           IDDAT(JS+35)=JSTATE+KSTATE-NSTATE                            ISTAB9    281
        ENDIF                                                           ISTAB9    282
C                                                                       ISTAB9    283
        VSUM=VSI1+VSI2*DDAT(JS+23)                                      ISTAB9    284
        IF (IDDAT(JS+25).NE.0) THEN                                     ISTAB9    285
           IDDAT(JS+36)=JSTATE+KSTATE+1-NSTATE                          ISTAB9    286
           NSTF=IDDAT(JS+5)                                             ISTAB9    287
           DO 210 NST=1,NSTF                                            ISTAB9    288
             KSTATE=KSTATE+1                                            ISTAB9    289
             XSTATE(JSTATE+KSTATE)=VSUM                                 ISTAB9    290
  210      CONTINUE                                                     ISTAB9    291
        ENDIF                                                           ISTAB9    292
C                                                                       ISTAB9    293
        VSUM=VSUM-VSI2                                                  ISTAB9    294
        IF (IDDAT(JS+7).NE.0.AND.IDDAT(JS+8).NE.0) THEN                 ISTAB9    295
           KSTATE=KSTATE+1                                              ISTAB9    296
           XSTATE(JSTATE+KSTATE)=VSUM                                   ISTAB9    297
           VSUM=0.0                                                     ISTAB9    298
           IDDAT(JS+37)=JSTATE+KSTATE-NSTATE                            ISTAB9    299
        ENDIF                                                           ISTAB9    300
C                                                                       ISTAB9    301
        IF(VSUM.NE.0.0)THEN                                             ISTAB9    302
           WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)     ISTAB9    303
     &                       ,NDGC(N)                                   ISTAB9    304
           WRITE(MSG(2),7110)                                           ISTAB9    305
           WRITE(MSG(3),7120) VSUM                                      ISTAB9    306
           CALL PRTMSG(3)                                               ISTAB9    307
        ENDIF                                                           ISTAB9    308
C                                                                       ISTAB9    309
        IF (IDDAT(JS+10).NE.0) THEN                                     ISTAB9    310
           KSTATE=KSTATE+1                                              ISTAB9    311
           XSTATE(JSTATE+KSTATE)=VSUM                                   ISTAB9    312
           IDDAT(JS+38)=JSTATE+KSTATE-NSTATE                            ISTAB9    313
        ENDIF                                                           ISTAB9    314
        IF (IDDAT(JS+12).NE.0) THEN                                     ISTAB9    315
           KSTATE=KSTATE+1                                              ISTAB9    316
           XSTATE(JSTATE+KSTATE)=VSUM                                   ISTAB9    317
           IDDAT(JS+39)=JSTATE+KSTATE-NSTATE                            ISTAB9    318
        ENDIF                                                           ISTAB9    319
C                                                                       ISTAB9    320
       IF(LDEB)WRITE(IUD6,1000)JSTATE,KSTATE,ISTABN,                    ISTAB9    321
     &    (XSTATE(JSTATE+LS),LS=1,KSTATE)                               ISTAB9    322
C                                                                       ISTAB9    323
       JSTATE=JSTATE+KSTATE                                             ISTAB9    324
C                                                                       ISTAB9    325
 1000  FORMAT(' %DEBUG IN ISTAB9 : JSTATE = ',I5,' KSTATE = ',I5,       ISTAB9    326
     &        ' ISTABN = ',I5,/,10G12.5)                                ISTAB9    327
 7110 FORMAT(5X,'TYPE 9 STABILIZER INITIAL OUTPUT IS NOT ZERO BUT')     ISTAB9    328
 7120 FORMAT(5X,'EQUALS TO ',G12.5,'. CHECK YOUR INPUT DATA')           ISTAB9    329
 9000 FORMAT(' *** WARNING GENERATOR AT BUS: ',I5,' STATION: ',3A4      ISTAB9    330
     *,' GID:',A4)                                                      ISTAB9    331
 9020 FORMAT(5X,'TYPE 9 STABILIZER ',A,'=',F8.6                         ISTAB9    332
     *,' IS BELOW THE LIMIT VALUE OF ',F4.2)                            ISTAB9    333
 9030 FORMAT(5X,A,' HAS BEEN SET TO ',F4.2)                             ISTAB9    334
 9040 FORMAT(' *** DATA ERROR GENERATOR AT BUS: ',I5,' STATION: ',3A4   ISTAB9    335
     *,' GID:',A4)                                                      ISTAB9    336
 9060 FORMAT(5X,'TYPE 9 STABILIZER DATA ERROR. VSMAX=',F10.5            ISTAB9    337
     *,' VSMIN=',F10.5)                                                 ISTAB9    338
       RETURN                                                           ISTAB9    339
       END                                                              ISTAB9    340
