CFPRIME INUAL                                                           INUAL       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 INUAL                                                  INUAL       3
CD                                                                      INUAL       4
CD    TO PERFORM INITIALIZATION AND DATA CHECK FOR ALL TYPES OF         INUAL       5
CD    UNDEREXCITED CURRENT LIMITER.                                     INUAL       6
CD                                                                      INUAL       7
CD    THE DATA STRUCTURE AFTER THE INITIALIZATION IS GIVEN BELOW.       INUAL       8
CD                                                                      INUAL       9
CD   8.1 Under excitation current limiter types 1 and 11                INUAL      10
CD                                                                      INUAL      11
CD     Under excitation current limiter data                            INUAL      12
CD                                                                      INUAL      13
CD     DDAT(JU+ 1)    = K1                                              INUAL      14
CD     DDAT(JU+ 2)    = K2                                              INUAL      15
CD     DDAT(JU+ 3)    = K3                                              INUAL      16
CD     DDAT(JU+ 4)    = K4                                              INUAL      17
CD     DDAT(JU+ 5)    = K5                                              INUAL      18
CD     DDAT(JU+ 6)    = K6                                              INUAL      19
CD     DDAT(JU+ 7)    = T9                                              INUAL      20
CD     DDAT(JU+ 8)    = (reserved for future use)                       INUAL      21
CD     DDAT(JU+ 9)    = T1                                              INUAL      22
CD     DDAT(JU+10)    = T2                                              INUAL      23
CD     DDAT(JU+11)    = T3                                              INUAL      24
CD     DDAT(JU+12)    = T4                                              INUAL      25
CD     DDAT(JU+13)    = T5                                              INUAL      26
CD     DDAT(JU+14)    = T6                                              INUAL      27
CD     DDAT(JU+15)    = T7                                              INUAL      28
CD     DDAT(JU+16)    = T8                                              INUAL      29
CD                                                                      INUAL      30
CD     Under excitation current limiter states                          INUAL      31
CD                                                                      INUAL      32
CD     XSTATE(JUS+1)  = first state of T1, T2 block :     optional      INUAL      33
CD     XSTATE(JUS+2)  = second state of T1, T2 block     :     optional INUAL      34
CD     XSTATE(JUS+3)  = first state of T5, T6 block :     optional      INUAL      35
CD     XSTATE(JUS+4)  = second state of T5, T6 block     :     optional INUAL      36
CD     XSTATE(JUS+5)  = first state of T3, T4 block :     optional      INUAL      37
CD     XSTATE(JUS+6)  = second state of T3, T4 block     :     optional INUAL      38
CD     XSTATE(JUS+7)  = first state of T7, T8 block :     optional      INUAL      39
CD     XSTATE(JUS+8)  = second state of T7, T8 block     :     optional INUAL      40
CD                                                                      INUAL      41
CD     Under excitation current limiter Y-variables                     INUAL      42
CD                                                                      INUAL      43
CD     VUAL(JYU+1)    = UEL output                                      INUAL      44
CD                                                                      INUAL      45
CD   8.2 Under excitation current limiter types 2 and 12                INUAL      46
CD                                                                      INUAL      47
CD     Under excitation current limiter data                            INUAL      48
CD                                                                      INUAL      49
CD     DDAT(JU+ 1)    = K1                                              INUAL      50
CD     DDAT(JU+ 2)    = K2                                              INUAL      51
CD     DDAT(JU+ 3)    = K3                                              INUAL      52
CD     DDAT(JU+ 4)    = K4                                              INUAL      53
CD     DDAT(JU+ 5)    = K5                                              INUAL      54
CD     DDAT(JU+ 6)    = (reserved for future use)                       INUAL      55
CD     DDAT(JU+ 7)    = T9                                              INUAL      56
CD     DDAT(JU+ 8)    = (reserved for future use)                       INUAL      57
CD     DDAT(JU+ 9)    = T1                                              INUAL      58
CD     DDAT(JU+10)    = T2                                              INUAL      59
CD     DDAT(JU+11)    = T3                                              INUAL      60
CD     DDAT(JU+12)    = T4                                              INUAL      61
CD     DDAT(JU+13)    = T5                                              INUAL      62
CD     DDAT(JU+14)    = T6                                              INUAL      63
CD     DDAT(JU+15)    = T7                                              INUAL      64
CD     DDAT(JU+16)    = T8                                              INUAL      65
CD                                                                      INUAL      66
CD     Under excitation current limiter states                          INUAL      67
CD                                                                      INUAL      68
CD     XSTATE(JUS+1)  = T1 block                    : optional          INUAL      69
CD     XSTATE(JUS+2)  = T2 block                    : optional          INUAL      70
CD     XSTATE(JUS+3)  = T3 block                    : optional          INUAL      71
CD     XSTATE(JUS+4)  = T4 block                    : optional          INUAL      72
CD     XSTATE(JUS+5)  = T5 block                    : optional          INUAL      73
CD     XSTATE(JUS+6)  = T6 block                    : optional          INUAL      74
CD     XSTATE(JUS+7)  = first state of T7, T8 block : optional          INUAL      75
CD     XSTATE(JUS+8)  = second state of T7, T8 block     : optional     INUAL      76
CD                                                                      INUAL      77
CD     Under excitation current limiter Y-variables                     INUAL      78
CD                                                                      INUAL      79
CD     VUAL(JYU+1)    = UEL output                                      INUAL      80
CD                                                                      INUAL      81
CD   8.3 Under excitation current limiter types 3 and 13                INUAL      82
CD                                                                      INUAL      83
CD     Under excitation current limiter data                            INUAL      84
CD                                                                      INUAL      85
CD     DDAT(JU+ 1)    = K1                                              INUAL      86
CD     DDAT(JU+ 2)    = K2                                              INUAL      87
CD     DDAT(JU+ 3)    = K3                                              INUAL      88
CD     DDAT(JU+ 4)    = K4                                              INUAL      89
CD     DDAT(JU+ 5)    = K5                                              INUAL      90
CD     DDAT(JU+ 6)    = K6                                              INUAL      91
CD     DDAT(JU+ 7)    = (reserved for future use)                       INUAL      92
CD     DDAT(JU+ 8)    = (reserved for future use)                       INUAL      93
CD     DDAT(JU+ 9)    = T1                                              INUAL      94
CD     DDAT(JU+10)    = T2                                              INUAL      95
CD     DDAT(JU+11)    = T3                                              INUAL      96
CD     DDAT(JU+12)    = T4                                              INUAL      97
CD     DDAT(JU+13)    = T5                                              INUAL      98
CD     DDAT(JU+14)    = T6                                              INUAL      99
CD                                                                      INUAL     100
CD     Under excitation current limiter states                          INUAL     101
CD                                                                      INUAL     102
CD     XSTATE(JUS+1)  = T1 block                    : optional          INUAL     103
CD     XSTATE(JUS+2)  = T2 block                    : optional          INUAL     104
CD     XSTATE(JUS+3)  = T3 block                    : optional          INUAL     105
CD     XSTATE(JUS+4)  = T6 block                    : optional          INUAL     106
CD     XSTATE(JUS+5)  = T4 block                    : optional          INUAL     107
CD     XSTATE(JUS+6)  = T5 block                    : optional          INUAL     108
CD                                                                      INUAL     109
CD     Under excitation current limiter Y-variables                     INUAL     110
CD                                                                      INUAL     111
CD     VUAL(JYU+1)    = UEL output                                      INUAL     112
CD                                                                      INUAL     113
      INCLUDE 'PARX.INS'                                                INUAL     114
      INCLUDE 'CNMDAT.INS'                                              INUAL     115
      INCLUDE 'CNSTN.INS'                                               INUAL     116
      INCLUDE 'CNVOLT.INS'                                              INUAL     117
      INCLUDE 'CNB1.INS'                                                INUAL     118
      INCLUDE 'CNB4.INS'                                                INUAL     119
      INCLUDE 'CNB5.INS'                                                INUAL     120
      INCLUDE 'CNMSTA.INS'                                              INUAL     121
      INCLUDE 'CNXSTA.INS'                                              INUAL     122
      INCLUDE 'CNB8.INS'                                                INUAL     123
      INCLUDE 'CNB10.INS'                                               INUAL     124
      INCLUDE 'CNB19.INS'                                               INUAL     125
      INCLUDE 'CNEXC.INS'                                               INUAL     126
      INCLUDE 'CNMYVA.INS'                                              INUAL     127
      INCLUDE 'CNYVAR.INS'                                              INUAL     128
      INCLUDE 'CNUNIT.INS'                                              INUAL     129
      INCLUDE 'CNMSG.INS'                                               INUAL     130
C                                                                       INUAL     131
      KSTATE=0                                                          INUAL     132
      KUALN=IUALN                                                       INUAL     133
      VUALN=0.0                                                         INUAL     134
C                                                                       INUAL     135
C  INPUT TIME CONSTANTS CHECK AND RESET                                 INUAL     136
C                                                                       INUAL     137
      GOTO (400,480,480,620,620,620,620,620,620,620), KUALN             INUAL     138
 400  CONTINUE                                                          INUAL     139
C                                                                       INUAL     140
C   TYPE 1 LIMITER                                                      INUAL     141
C                                                                       INUAL     142
      IF (IDDAT(JU+9).NE.0)THEN                                         INUAL     143
      KSTATE=KSTATE+1                                                   INUAL     144
      XSTATE(JSTATE+KSTATE)=0.0                                         INUAL     145
      ENDIF                                                             INUAL     146
      IF (IDDAT(JU+10).NE.0)THEN                                        INUAL     147
      KSTATE=KSTATE+1                                                   INUAL     148
      XSTATE(JSTATE+KSTATE)=0.0                                         INUAL     149
      ENDIF                                                             INUAL     150
      IF (KSTATE.EQ.0)THEN                                              INUAL     151
      ETIN=ET*DDAT(JU+1)*DDAT(JU+3)                                     INUAL     152
      ELSE                                                              INUAL     153
      XSTATE(JSTATE+KSTATE)=ET*DDAT(JU+1)                               INUAL     154
      ETIN=XSTATE(JSTATE+KSTATE)*DDAT(JU+3)                             INUAL     155
      ENDIF                                                             INUAL     156
      QDET=PQGN*DDAT(JU+2)/ET                                           INUAL     157
      PDET=PDGN*DDAT(JU+2)/ET                                           INUAL     158
      IF (IDDAT(JU+13).NE.0)THEN                                        INUAL     159
      KSTATE=KSTATE+1                                                   INUAL     160
      XSTATE(JSTATE+KSTATE)=0.0                                         INUAL     161
      ENDIF                                                             INUAL     162
      IF (IDDAT(JU+14).NE.0)THEN                                        INUAL     163
      KSTATE=KSTATE+1                                                   INUAL     164
      XSTATE(JSTATE+KSTATE)=0.0                                         INUAL     165
      ENDIF                                                             INUAL     166
      IF (IDDAT(JU+14).EQ.0.AND.IDDAT(JU+13).EQ.0)THEN                  INUAL     167
      XIT1=QDET*DDAT(JU+5)                                              INUAL     168
      ELSE                                                              INUAL     169
      XSTATE(JSTATE+KSTATE)=QDET                                        INUAL     170
      XIT1=XSTATE(JSTATE+KSTATE)*DDAT(JU+5)                             INUAL     171
      ENDIF                                                             INUAL     172
      IF (IDDAT(JU+11).NE.0)THEN                                        INUAL     173
      KSTATE=KSTATE+1                                                   INUAL     174
      XSTATE(JSTATE+KSTATE)=0.0                                         INUAL     175
      ENDIF                                                             INUAL     176
      IF (IDDAT(JU+12).NE.0)THEN                                        INUAL     177
      KSTATE=KSTATE+1                                                   INUAL     178
      XSTATE(JSTATE+KSTATE)=0.0                                         INUAL     179
      ENDIF                                                             INUAL     180
      IF (IDDAT(JU+12).EQ.0.AND.IDDAT(JU+11).EQ.0)THEN                  INUAL     181
      XIT2=PDET*DDAT(JU+4)                                              INUAL     182
      ELSE                                                              INUAL     183
      XSTATE(JSTATE+KSTATE)=PDET                                        INUAL     184
      XIT2=XSTATE(JSTATE+KSTATE)*DDAT(JU+4)                             INUAL     185
      ENDIF                                                             INUAL     186
      VSUM=XIT2-ETIN-XIT1                                               INUAL     187
      IF (IDDAT(JU+15).NE.0)THEN                                        INUAL     188
      KSTATE=KSTATE+1                                                   INUAL     189
      XSTATE(JSTATE+KSTATE)=0.0                                         INUAL     190
      ENDIF                                                             INUAL     191
      IF (IDDAT(JU+16).NE.0)THEN                                        INUAL     192
      KSTATE=KSTATE+1                                                   INUAL     193
      XSTATE(JSTATE+KSTATE)=0.0                                         INUAL     194
      ENDIF                                                             INUAL     195
      IF (IDDAT(JU+15).EQ.0.AND.IDDAT(JU+16).EQ.0)THEN                  INUAL     196
      VUALN=VSUM*DDAT(JU+6)                                             INUAL     197
      ELSE                                                              INUAL     198
      XSTATE(JSTATE+KSTATE)=VSUM*DDAT(JU+6)                             INUAL     199
      VUALN=XSTATE(JSTATE+KSTATE)                                       INUAL     200
      ENDIF                                                             INUAL     201
      GO TO 620                                                         INUAL     202
C                                                                       INUAL     203
C   TYPE 2 AND TYPE 3  LIMITERS                                         INUAL     204
C                                                                       INUAL     205
 480  CONTINUE                                                          INUAL     206
      IF(DDAT(JU+9).LT.TMIN.AND.IDDAT(JU+9).NE.0)THEN                   INUAL     207
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       INUAL     208
     *                     ,NDGC(N)                                     INUAL     209
         WRITE(MSG(2),9020) IUALN,'T1',DDAT(JU+9),TMIN                  INUAL     210
         IF(MTFLAG.EQ.0) THEN                                           INUAL     211
            CALL PRTMSG(2)                                              INUAL     212
         ELSE                                                           INUAL     213
            WRITE(MSG(3),9030) 'T1',0.0                                 INUAL     214
            CALL PRTMSG(3)                                              INUAL     215
            DDAT(JU+9)=0.0                                              INUAL     216
         ENDIF                                                          INUAL     217
      ENDIF                                                             INUAL     218
C                                                                       INUAL     219
      IF(DDAT(JU+10).LT.TMIN.AND.IDDAT(JU+10).NE.0)THEN                 INUAL     220
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       INUAL     221
     *                     ,NDGC(N)                                     INUAL     222
         WRITE(MSG(2),9020) IUALN,'T2',DDAT(JU+10),TMIN                 INUAL     223
         IF(MTFLAG.EQ.0) THEN                                           INUAL     224
            CALL PRTMSG(2)                                              INUAL     225
         ELSE                                                           INUAL     226
            WRITE(MSG(3),9030) 'T2',0.0                                 INUAL     227
            CALL PRTMSG(3)                                              INUAL     228
            DDAT(JU+10)=0.0                                             INUAL     229
         ENDIF                                                          INUAL     230
      ENDIF                                                             INUAL     231
C                                                                       INUAL     232
      IF(DDAT(JU+11).LT.TMIN.AND.IDDAT(JU+11).NE.0)THEN                 INUAL     233
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       INUAL     234
     *                     ,NDGC(N)                                     INUAL     235
         WRITE(MSG(2),9020) IUALN,'T3',DDAT(JU+11),TMIN                 INUAL     236
         IF(MTFLAG.EQ.0) THEN                                           INUAL     237
            CALL PRTMSG(2)                                              INUAL     238
         ELSE                                                           INUAL     239
            WRITE(MSG(3),9030) 'T3',0.0                                 INUAL     240
            CALL PRTMSG(3)                                              INUAL     241
            DDAT(JU+11)=0.0                                             INUAL     242
         ENDIF                                                          INUAL     243
      ENDIF                                                             INUAL     244
C                                                                       INUAL     245
      IF(DDAT(JU+12).LT.TMIN.AND.IDDAT(JU+12).NE.0)THEN                 INUAL     246
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       INUAL     247
     *                     ,NDGC(N)                                     INUAL     248
         WRITE(MSG(2),9020) IUALN,'T4',DDAT(JU+12),TMIN                 INUAL     249
         IF(MTFLAG.EQ.0) THEN                                           INUAL     250
            CALL PRTMSG(2)                                              INUAL     251
         ELSE                                                           INUAL     252
            WRITE(MSG(3),9030) 'T4',0.0                                 INUAL     253
            CALL PRTMSG(3)                                              INUAL     254
            DDAT(JU+12)=0.0                                             INUAL     255
         ENDIF                                                          INUAL     256
      ENDIF                                                             INUAL     257
C                                                                       INUAL     258
      IF(DDAT(JU+13).LT.TMIN.AND.IDDAT(JU+13).NE.0)THEN                 INUAL     259
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       INUAL     260
     *                     ,NDGC(N)                                     INUAL     261
         WRITE(MSG(2),9020) IUALN,'T5',DDAT(JU+13),TMIN                 INUAL     262
         IF(MTFLAG.EQ.0) THEN                                           INUAL     263
            CALL PRTMSG(2)                                              INUAL     264
         ELSE                                                           INUAL     265
            WRITE(MSG(3),9030) 'T5',0.0                                 INUAL     266
            CALL PRTMSG(3)                                              INUAL     267
            DDAT(JU+13)=0.0                                             INUAL     268
         ENDIF                                                          INUAL     269
      ENDIF                                                             INUAL     270
C                                                                       INUAL     271
      IF(DDAT(JU+14).LT.TMIN.AND.IDDAT(JU+14).NE.0)THEN                 INUAL     272
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       INUAL     273
     *                     ,NDGC(N)                                     INUAL     274
         WRITE(MSG(2),9020) IUALN,'T6',DDAT(JU+14),TMIN                 INUAL     275
         IF(MTFLAG.EQ.0) THEN                                           INUAL     276
            CALL PRTMSG(2)                                              INUAL     277
         ELSE                                                           INUAL     278
            WRITE(MSG(3),9030) 'T6',0.0                                 INUAL     279
            CALL PRTMSG(3)                                              INUAL     280
            DDAT(JU+14)=0.0                                             INUAL     281
         ENDIF                                                          INUAL     282
      ENDIF                                                             INUAL     283
C                                                                       INUAL     284
      PTIN=PDGN*DDAT(JU+1)                                              INUAL     285
      IF (IDDAT(JU+9).NE.0)THEN                                         INUAL     286
      KSTATE=KSTATE+1                                                   INUAL     287
      XSTATE(JSTATE+KSTATE)=PTIN                                        INUAL     288
      ENDIF                                                             INUAL     289
      QTIN=PQGN*DDAT(JU+2)                                              INUAL     290
      IF (IDDAT(JU+10).NE.0)THEN                                        INUAL     291
      KSTATE=KSTATE+1                                                   INUAL     292
      XSTATE(JSTATE+KSTATE)=QTIN                                        INUAL     293
      ENDIF                                                             INUAL     294
      ETKX=ET*DDAT(JU+3)                                                INUAL     295
      IF (KUALN.EQ.2) ETKX=ETKX*ETKX*DDAT(JU+4)                         INUAL     296
      IF (IDDAT(JU+11).NE.0)THEN                                        INUAL     297
      KSTATE=KSTATE+1                                                   INUAL     298
      XSTATE(JSTATE+KSTATE)=ETKX                                        INUAL     299
      ENDIF                                                             INUAL     300
      ETIN=ETKX                                                         INUAL     301
C                                                                       INUAL     302
      IF (KUALN.EQ.2)THEN                                               INUAL     303
      VSUM=PTIN-QTIN-ETIN                                               INUAL     304
      IF (IDDAT(JU+12).NE.0)THEN                                        INUAL     305
      KSTATE=KSTATE+1                                                   INUAL     306
      XSTATE(JSTATE+KSTATE)=VSUM*DDAT(JU+5)                             INUAL     307
      ENDIF                                                             INUAL     308
      VSUM=VSUM*DDAT(JU+5)                                              INUAL     309
      IF (IDDAT(JU+13).NE.0)THEN                                        INUAL     310
      KSTATE=KSTATE+1                                                   INUAL     311
      XSTATE(JSTATE+KSTATE)=VSUM                                        INUAL     312
      ENDIF                                                             INUAL     313
      IF (IDDAT(JU+14).NE.0)THEN                                        INUAL     314
      KSTATE=KSTATE+1                                                   INUAL     315
      XSTATE(JSTATE+KSTATE)=VSUM                                        INUAL     316
      ENDIF                                                             INUAL     317
      IF (IDDAT(JU+15).NE.0)THEN                                        INUAL     318
      KSTATE=KSTATE+1                                                   INUAL     319
      XSTATE(JSTATE+KSTATE)=0.0                                         INUAL     320
      ENDIF                                                             INUAL     321
      IF (IDDAT(JU+16).NE.0)THEN                                        INUAL     322
      KSTATE=KSTATE+1                                                   INUAL     323
      XSTATE(JSTATE+KSTATE)=0.0                                         INUAL     324
      ENDIF                                                             INUAL     325
      IF (IDDAT(JU+15).EQ.0.AND.IDDAT(JU+16).EQ.0)THEN                  INUAL     326
      VUALN=VSUM                                                        INUAL     327
      ELSE                                                              INUAL     328
      XSTATE(JSTATE+KSTATE)=VSUM                                        INUAL     329
      VUALN=VSUM                                                        INUAL     330
      ENDIF                                                             INUAL     331
C                                                                       INUAL     332
C   KUALN=3                                                             INUAL     333
C                                                                       INUAL     334
      ELSE                                                              INUAL     335
C                                                                       INUAL     336
      VSUM=PTIN+QTIN+ETIN                                               INUAL     337
      EFDIN=EFDN*DDAT(JU+6)                                             INUAL     338
      IF(IDDAT(JU+14).NE.0)THEN                                         INUAL     339
      KSTATE=KSTATE+1                                                   INUAL     340
      XSTATE(JSTATE+KSTATE)=EFDIN                                       INUAL     341
      ENDIF                                                             INUAL     342
      VSUM=VSUM-EFDIN                                                   INUAL     343
      VSUM=VSUM*DDAT(JU+4)                                              INUAL     344
      IF (IDDAT(JU+12).NE.0)THEN                                        INUAL     345
      KSTATE=KSTATE+1                                                   INUAL     346
      XSTATE(JSTATE+KSTATE)=VSUM                                        INUAL     347
      ENDIF                                                             INUAL     348
      VSUM=VSUM/(1.0-DDAT(JU+5))                                        INUAL     349
      IF (IDDAT(JU+13).NE.0)THEN                                        INUAL     350
      KSTATE=KSTATE+1                                                   INUAL     351
      XSTATE(JSTATE+KSTATE)=VSUM                                        INUAL     352
      ENDIF                                                             INUAL     353
      VUALN=VSUM                                                        INUAL     354
C                                                                       INUAL     355
C   ENDIF KUALN.EQ.2                                                    INUAL     356
C                                                                       INUAL     357
      ENDIF                                                             INUAL     358
 620  IF (VUALN.GT.0.0)THEN                                             INUAL     359
      WRITE(MSG(1),970) NLF,INAME(KN-2),INAME(KN-1),INAME(KN),NDGC(N)   INUAL     360
      WRITE(MSG(2),980) IUALN,VUALN                                     INUAL     361
      CALL PRTMSG(2)                                                    INUAL     362
      ELSE                                                              INUAL     363
      VUAL(JYU+1)=0.0                                                   INUAL     364
      ENDIF                                                             INUAL     365
C                                                                       INUAL     366
      JSTATE=JSTATE+KSTATE                                              INUAL     367
      JY=JY+1                                                           INUAL     368
C                                                                       INUAL     369
      RETURN                                                            INUAL     370
C                                                                       INUAL     371
  970 FORMAT(' *** ERROR GENERATOR AT BUS ',I5,' NAME ',3A4             INUAL     372
     *,' GID ',A4)                                                      INUAL     373
  980 FORMAT(5X,'IUAL=',I3,'VUAL=',G10.5,' CHECK UAL DATA')             INUAL     374
 9000 FORMAT(' *** WARNING GENERATOR AT BUS:',I6,' NAME ',3A4           INUAL     375
     *,' GID ',A4)                                                      INUAL     376
 9020 FORMAT(5X,'TYPE ',I2,' UAL ',A,'=',F8.6                           INUAL     377
     *,' IS BELOW THE LIMIT VALUE OF ',F4.2)                            INUAL     378
 9030 FORMAT(5X,A,' HAS BEEN SET TO ',F4.2)                             INUAL     379
 9060 FORMAT(5X,'TYPE ',I2,' UAL ',A,'=0.0',A,'=',F8.6                  INUAL     380
     *,' IS BELOW THE LIMIT VALUE OF ',F4.2)                            INUAL     381
C                                                                       INUAL     382
      END                                                               INUAL     383
