CFPRIME IUDB44                                                          IUDB44      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 IUDB44(IORD,NEXTB1,CID)                                IUDB44      3
CD                                                                      IUDB44      4
CD    TO PERFORM INITIALIZATION FOR USER DEFINED BLOCK TYPE 44 (TYPE    IUDB44      5
CD    T1 GOVERNOR END BLOCK) IN A USER DEFINED GOVERNOR MODEL.          IUDB44      6
CD                                                                      IUDB44      7
CD    EACH ENTRY POINT IN THIS SUBROUTINE HAS SIMILAR FUNCTION AND IS   IUDB44      8
CD    FOR A DIFFERENT TYPE OF GOVERNOR END BLOCK APPLICABLE TO A USER   IUDB44      9
CD    DEFINED GOVERNOR MODEL.                                           IUDB44     10
CD                                                                      IUDB44     11
      INCLUDE 'PARX.INS'                                                IUDB44     12
      INCLUDE 'CNG3.INS'                                                IUDB44     13
      INCLUDE 'CNB8.INS'                                                IUDB44     14
      INCLUDE 'CNB19.INS'                                               IUDB44     15
      INCLUDE 'CNEXC.INS'                                               IUDB44     16
      INCLUDE 'CNMDAT.INS'                                              IUDB44     17
      INCLUDE 'CNMSTA.INS'                                              IUDB44     18
      INCLUDE 'CNXSTA.INS'                                              IUDB44     19
      INCLUDE 'CNSTN.INS'                                               IUDB44     20
      INCLUDE 'CNYVAR.INS'                                              IUDB44     21
      INCLUDE 'CNUNIT.INS'                                              IUDB44     22
      INCLUDE 'CNFLAG.INS'                                              IUDB44     23
      INCLUDE 'CNUDM.INS'                                               IUDB44     24
      INCLUDE 'CNMSG.INS'                                               IUDB44     25
C                                                                       IUDB44     26
      CHARACTER*2 CID                                                   IUDB44     27
C                                                                       IUDB44     28
      LDEB=(JDEB(262).NE.0)                                             IUDB44     29
C                                                                       IUDB44     30
      NINP=0                                                            IUDB44     31
      NEXTB1=0                                                          IUDB44     32
      JORD=JUDE(IORD)                                                   IUDB44     33
      KORD=JSTATE+KUDE(IORD)+1                                          IUDB44     34
      JEI=JEB+2                                                         IUDB44     35
      JLS=IDDAT(JEI+12)                                                 IUDB44     36
C                                                                       IUDB44     37
      IF(IDDAT(JEI+1).EQ.0.OR.IDDAT(JEI+2).EQ.0.OR.IDDAT(JEI+4)         IUDB44     38
     &  .EQ.0.0) THEN                                                   IUDB44     39
         WRITE(MSG(1),1000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN),CID   IUDB44     40
         WRITE(MSG(2),1100) IORD,BLNAM1,BLNAM2                          IUDB44     41
         CALL PRTMSG(2)                                                 IUDB44     42
          MSG(1)='IUDB44: UDM ERROR'                                    IUDB44     43
          CALL ASTOP(MSG(1),17)                                         IUDB44     44
      ENDIF                                                             IUDB44     45
C                                                                       IUDB44     46
      J2=JE5-2                                                          IUDB44     47
      DO 110 J=1,INTUD                                                  IUDB44     48
      J2=J2+2                                                           IUDB44     49
      IDD=IDDAT(J2+2)                                                   IUDB44     50
      IDD=ABS(IDD)                                                      IUDB44     51
      IF(IDD.EQ.IORD) THEN                                              IUDB44     52
         XDAT=1.0                                                       IUDB44     53
         IF(IDDAT(J2+2).LT.0) XDAT=-1.0                                 IUDB44     54
         IOUT=IDDAT(J2+1)                                               IUDB44     55
         IF(NINP.EQ.0) THEN                                             IUDB44     56
            IF(JUDE(IOUT).EQ.0) THEN                                    IUDB44     57
               NEXTB1=IOUT                                              IUDB44     58
               XDATN=XDAT                                               IUDB44     59
               NINP=NINP+1                                              IUDB44     60
            ELSE                                                        IUDB44     61
         WRITE(MSG(1),1000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN),CID   IUDB44     62
         WRITE(MSG(2),1030) IORD,BLNAM1,BLNAM2                          IUDB44     63
         CALL PRTMSG(2)                                                 IUDB44     64
         MSG(1)='IUDB44: UDM ERROR'                                     IUDB44     65
         CALL ASTOP(MSG(1),17)                                          IUDB44     66
            ENDIF                                                       IUDB44     67
         ELSE                                                           IUDB44     68
            NINP=NINP+1                                                 IUDB44     69
         ENDIF                                                          IUDB44     70
      ENDIF                                                             IUDB44     71
  110 CONTINUE                                                          IUDB44     72
      J3=JE6-3                                                          IUDB44     73
      DO 120 J=1,INPUD                                                  IUDB44     74
      J3=J3+3                                                           IUDB44     75
      IF(IDDAT(J3+1).EQ.IORD) THEN                                      IUDB44     76
         IIN=IDDAT(J3+2)                                                IUDB44     77
         IF(NINP.EQ.0) THEN                                             IUDB44     78
            IF(IIN.EQ.20) THEN                                          IUDB44     79
               XDATN=DDAT(J3+3)                                         IUDB44     80
               NINP=NINP+1                                              IUDB44     81
            ELSE                                                        IUDB44     82
         WRITE(MSG(1),1000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN),CID   IUDB44     83
         WRITE(MSG(2),1001) IORD,BLNAM1,BLNAM2                          IUDB44     84
         WRITE(MSG(3),1002)                                             IUDB44     85
         CALL PRTMSG(3)                                                 IUDB44     86
         MSG(1)='IUDB44: UDM ERROR'                                     IUDB44     87
         CALL ASTOP(MSG(1),17)                                          IUDB44     88
            ENDIF                                                       IUDB44     89
         ELSE                                                           IUDB44     90
            IF(IIN.EQ.20)THEN                                           IUDB44     91
      WRITE(MSG(1),1000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN),CID      IUDB44     92
      WRITE(MSG(2),1090) IORD,BLNAM1,BLNAM2                             IUDB44     93
      WRITE(MSG(3),1091)                                                IUDB44     94
      CALL PRTMSG(3)                                                    IUDB44     95
         MSG(1)='IUDB44: UDM ERROR'                                     IUDB44     96
         CALL ASTOP(MSG(1),17)                                          IUDB44     97
            ELSE                                                        IUDB44     98
               NINP=NINP+1                                              IUDB44     99
            ENDIF                                                       IUDB44    100
         ENDIF                                                          IUDB44    101
      ENDIF                                                             IUDB44    102
  120 CONTINUE                                                          IUDB44    103
      IF(NINP.EQ.0) THEN                                                IUDB44    104
         WRITE(MSG(1),1000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN),CID   IUDB44    105
         WRITE(MSG(2),1010) IORD,BLNAM1,BLNAM2                          IUDB44    106
         CALL PRTMSG(2)                                                 IUDB44    107
         MSG(1)='IUDB44: UDM ERROR'                                     IUDB44    108
         CALL ASTOP(MSG(1),17)                                          IUDB44    109
      ENDIF                                                             IUDB44    110
      IF(NINP.GT.2) THEN                                                IUDB44    111
         WRITE(MSG(1),1000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN),CID   IUDB44    112
         WRITE(MSG(2),1050) IORD,BLNAM1,BLNAM2                          IUDB44    113
         CALL PRTMSG(2)                                                 IUDB44    114
         MSG(1)='IUDB44: UDM ERROR'                                     IUDB44    115
         CALL ASTOP(MSG(1),17)                                          IUDB44    116
      ENDIF                                                             IUDB44    117
C                                                                       IUDB44    118
C     DATA PREPARATIONS AND INPUT DATA PRINTOUT                         IUDB44    119
C                                                                       IUDB44    120
      IF (IDDAT(JEI+3).EQ.0) DDAT(JEI+6)=0.0                            IUDB44    121
      XINIT=VALOUT(IORD)/DDAT(JEI+7)                                    IUDB44    122
      XSTATE(KORD)=XINIT                                                IUDB44    123
      XSTATE(KORD+1)=XINIT                                              IUDB44    124
      XSTATE(KORD+2)=XINIT                                              IUDB44    125
      XSTATE(KORD+3)=XINIT                                              IUDB44    126
C                                                                       IUDB44    127
C     BOILER/REACTOR PRESSURE                                           IUDB44    128
C                                                                       IUDB44    129
      IF(VALIN(10).LE.0.0.AND.VALIN(10).GE.0.0) THEN                    IUDB44    130
         BLRPR0=DDAT(JEI+9)                                             IUDB44    131
      ELSE                                                              IUDB44    132
         BLRPR0=DDAT(JEI+9)*VALOUT(IORD)/VALIN(10)                      IUDB44    133
      ENDIF                                                             IUDB44    134
      SSMAT(JLS+11)=BLRPR0                                              IUDB44    135
C                                                                       IUDB44    136
C     CV FLOW                                                           IUDB44    137
C                                                                       IUDB44    138
      XPN1=SSMAT(JLS+4)                                                 IUDB44    139
      YFA1=SSMAT(JLS+3)                                                 IUDB44    140
      XPN2=SSMAT(JLS+6)                                                 IUDB44    141
      YFA2=SSMAT(JLS+5)                                                 IUDB44    142
      XPIN=XINIT/BLRPR0                                                 IUDB44    143
      CALL NLCHAR                                                       IUDB44    144
      VALIN(1)=YOUT                                                     IUDB44    145
C                                                                       IUDB44    146
      VALIN(2)=1.0                                                      IUDB44    147
C                                                                       IUDB44    148
C    A=1 - FACTOR OF IV FLOW                                            IUDB44    149
C                                                                       IUDB44    150
      XEK1=2.0/DDAT(JEI+10)                                             IUDB44    151
      XEK2=(DDAT(JEI+10)+1.0)/DDAT(JEI+10)                              IUDB44    152
      XPR=1.0-(DDAT(JEI+11)/100.)                                       IUDB44    153
      XEKK=(XPR**XEK1)-(XPR**XEK2)                                      IUDB44    154
      XEKK=SQRT(XEKK)                                                   IUDB44    155
      SSMAT(JLS+2)=1.0/XEKK                                             IUDB44    156
C                                                                       IUDB44    157
      FLP=1.0-DDAT(JEI+5)-DDAT(JEI+6)                                   IUDB44    158
C                                                                       IUDB44    159
      IF(NEXTB1.NE.0) THEN                                              IUDB44    160
         VALOUT(NEXTB1)=YOUT                                            IUDB44    161
      ELSE                                                              IUDB44    162
         VALIN(20)=YOUT                                                 IUDB44    163
      ENDIF                                                             IUDB44    164
      IF(LDEB)WRITE(IUD6,1040) JORD                                     IUDB44    165
C                                                                       IUDB44    166
      RETURN                                                            IUDB44    167
C                                                                       IUDB44    168
C-----------------------------------------------------------------------IUDB44    169
C                                                                       IUDB44    170
      ENTRY IUDB45(IORD,TINX,CID)                                       IUDB44    171
CD                                                                      IUDB44    172
CD    FOR BLOCK TYPE 45 (TYPE T4 GOVERNOR END BLOCK).                   IUDB44    173
CD                                                                      IUDB44    174
      LDEB=(JDEB(262).NE.0)                                             IUDB44    175
C                                                                       IUDB44    176
      NINP=0                                                            IUDB44    177
      NEXTB=0                                                           IUDB44    178
      JORD=JUDE(IORD)                                                   IUDB44    179
      KORD=JSTATE+KUDE(IORD)+1                                          IUDB44    180
      JEI=JEB+2                                                         IUDB44    181
C                                                                       IUDB44    182
      J2=JE5-2                                                          IUDB44    183
      DO 130 J=1,INTUD                                                  IUDB44    184
      J2=J2+2                                                           IUDB44    185
      IDD=IDDAT(J2+2)                                                   IUDB44    186
      IDD=ABS(IDD)                                                      IUDB44    187
      IF(IDD.EQ.IORD) THEN                                              IUDB44    188
         XDAT=1.0                                                       IUDB44    189
         IF(IDDAT(J2+2).LT.0) XDAT=-1.0                                 IUDB44    190
         IOUT=IDDAT(J2+1)                                               IUDB44    191
         IF(JUDE(IOUT).EQ.0) THEN                                       IUDB44    192
            NEXTB=IOUT                                                  IUDB44    193
            XDATN=XDAT                                                  IUDB44    194
            NINP=NINP+1                                                 IUDB44    195
         ELSE                                                           IUDB44    196
         WRITE(MSG(1),1000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN),CID   IUDB44    197
         WRITE(MSG(2),1030) IORD,BLNAM1,BLNAM2                          IUDB44    198
         CALL PRTMSG(2)                                                 IUDB44    199
          MSG(1)='IUDB45: UDM ERROR'                                    IUDB44    200
          CALL ASTOP(MSG(1),17)                                         IUDB44    201
         ENDIF                                                          IUDB44    202
      ENDIF                                                             IUDB44    203
  130 CONTINUE                                                          IUDB44    204
      J3=JE6-3                                                          IUDB44    205
      DO 140 J=1,INPUD                                                  IUDB44    206
      J3=J3+3                                                           IUDB44    207
      IF(IDDAT(J3+1).EQ.IORD) THEN                                      IUDB44    208
         IIN=IDDAT(J3+2)                                                IUDB44    209
         IF(IIN.EQ.20) THEN                                             IUDB44    210
            XDATN=DDAT(J3+3)                                            IUDB44    211
            NINP=NINP+1                                                 IUDB44    212
         ELSE                                                           IUDB44    213
          WRITE(MSG(1),1000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN),CID  IUDB44    214
          WRITE(MSG(2),1001) IORD,BLNAM1,BLNAM2                         IUDB44    215
          WRITE(MSG(3),1002)                                            IUDB44    216
          CALL PRTMSG(3)                                                IUDB44    217
          MSG(1)='IUDB45: UDM ERROR'                                    IUDB44    218
          CALL ASTOP(MSG(1),17)                                         IUDB44    219
         ENDIF                                                          IUDB44    220
      ENDIF                                                             IUDB44    221
  140 CONTINUE                                                          IUDB44    222
      IF(NINP.EQ.0) THEN                                                IUDB44    223
         WRITE(MSG(1),1000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN),CID   IUDB44    224
         WRITE(MSG(2),1010) IORD,BLNAM1,BLNAM2                          IUDB44    225
         CALL PRTMSG(2)                                                 IUDB44    226
      MSG(1)='IUDB45: UDM ERROR'                                        IUDB44    227
      CALL ASTOP(MSG(1),17)                                             IUDB44    228
      ENDIF                                                             IUDB44    229
      IF(NINP.GT.1) THEN                                                IUDB44    230
         WRITE(MSG(1),1000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN),CID   IUDB44    231
         WRITE(MSG(2),1250) IORD,BLNAM1,BLNAM2                          IUDB44    232
         CALL PRTMSG(2)                                                 IUDB44    233
         MSG(1)='IUDB45: UDM ERROR'                                     IUDB44    234
         CALL ASTOP(MSG(1),17)                                          IUDB44    235
      ENDIF                                                             IUDB44    236
C                                                                       IUDB44    237
C     DATA PREPARATIONS AND INPUT DATA PRINTOUT                         IUDB44    238
C                                                                       IUDB44    239
      NP1=N+1                                                           IUDB44    240
      IGVNP1=ICONTA(2,NP1)                                              IUDB44    241
C                                                                       IUDB44    242
      IF(IGVNP1.NE.5) THEN                                              IUDB44    243
         XINIT=VALOUT(IORD)/DDAT(JEI+7)                                 IUDB44    244
         DDAT(JEI+11)=1.0-(DDAT(JEI+8)+DDAT(JEI+9)+DDAT(JEI+10))        IUDB44    245
      ELSE                                                              IUDB44    246
         JGV5=JCONTA(2,NP1)                                             IUDB44    247
         JG5=JCONTA(1,NP1)                                              IUDB44    248
         RATIO2=DDAT(JGV5+1)+DDAT(JGV5+2)+DDAT(JGV5+3)                  IUDB44    249
         RATIO1=1.0-RATIO2                                              IUDB44    250
         DDAT(JEI+11)=RATIO1-(DDAT(JEI+8)+DDAT(JEI+9)+DDAT(JEI+10))     IUDB44    251
         XINIT=VALOUT(IORD)/DDAT(JEI+7)/RATIO1                          IUDB44    252
         DDAT(JGV5+4)=TINX/XINIT/RATIO2                                 IUDB44    253
      ENDIF                                                             IUDB44    254
C                                                                       IUDB44    255
      DO 150 I=KORD,KORD+3                                              IUDB44    256
  150 XSTATE(I)=XINIT                                                   IUDB44    257
C                                                                       IUDB44    258
      VALIN(1)=XINIT                                                    IUDB44    259
      IF(NEXTB.NE.0) THEN                                               IUDB44    260
         VALOUT(NEXTB)=XINIT                                            IUDB44    261
      ELSE                                                              IUDB44    262
         VALIN(20)=XINIT                                                IUDB44    263
      ENDIF                                                             IUDB44    264
C                                                                       IUDB44    265
      IF (LDEB) WRITE(IUD6,1040) JORD                                   IUDB44    266
      IF (DDAT(JEI+11).LT.-0.0001) THEN                                 IUDB44    267
         WRITE(MSG(1),1000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN),CID   IUDB44    268
         WRITE(MSG(2),1260)                                             IUDB44    269
         CALL PRTMSG(2)                                                 IUDB44    270
          MSG(1)='IUDB45: UDM ERROR'                                    IUDB44    271
          CALL ASTOP(MSG(1),17)                                         IUDB44    272
      END IF                                                            IUDB44    273
      IF (IDDAT(JEI+1).EQ.0) THEN                                       IUDB44    274
         WRITE(MSG(1),1000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN),CID   IUDB44    275
         WRITE(MSG(2),1270)                                             IUDB44    276
         CALL PRTMSG(2)                                                 IUDB44    277
          MSG(1)='IUDB45: UDM ERROR'                                    IUDB44    278
          CALL ASTOP(MSG(1),17)                                         IUDB44    279
      END IF                                                            IUDB44    280
C                                                                       IUDB44    281
      RETURN                                                            IUDB44    282
C                                                                       IUDB44    283
C-----------------------------------------------------------------------IUDB44    284
C                                                                       IUDB44    285
      ENTRY IUDB46(IORD,CID)                                            IUDB44    286
CD                                                                      IUDB44    287
CD    FOR BLOCK TYPE 46 (TYPE T20 GOVERNOR END BLOCK).                  IUDB44    288
CD                                                                      IUDB44    289
      LDEB=(JDEB(262).NE.0)                                             IUDB44    290
C                                                                       IUDB44    291
      NINP=0                                                            IUDB44    292
      NEXTB=0                                                           IUDB44    293
      JORD=JUDE(IORD)                                                   IUDB44    294
      KORD=JSTATE+KUDE(IORD)+1                                          IUDB44    295
      JEI=JEB+2                                                         IUDB44    296
      TW=DDAT(JEI+1)                                                    IUDB44    297
      IF(TW.LE.0.0) THEN                                                IUDB44    298
         WRITE(MSG(1),1000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN),CID   IUDB44    299
         WRITE(MSG(2),1360) IORD,BLNAM1,BLNAM2                          IUDB44    300
         CALL PRTMSG(2)                                                 IUDB44    301
          MSG(1)='IUDB46: UDM ERROR'                                    IUDB44    302
          CALL ASTOP(MSG(1),17)                                         IUDB44    303
      ENDIF                                                             IUDB44    304
C                                                                       IUDB44    305
      J2=JE5-2                                                          IUDB44    306
      DO 160 J=1,INTUD                                                  IUDB44    307
      J2=J2+2                                                           IUDB44    308
      IDD=IDDAT(J2+2)                                                   IUDB44    309
      IDD=ABS(IDD)                                                      IUDB44    310
      IF(IDD.EQ.IORD) THEN                                              IUDB44    311
         XDAT=1.0                                                       IUDB44    312
         IF(IDDAT(J2+2).LT.0) XDAT=-1.0                                 IUDB44    313
         IOUT=IDDAT(J2+1)                                               IUDB44    314
         IF(JUDE(IOUT).EQ.0) THEN                                       IUDB44    315
            NEXTB=IOUT                                                  IUDB44    316
            XDATN=XDAT                                                  IUDB44    317
            NINP=NINP+1                                                 IUDB44    318
         ELSE                                                           IUDB44    319
         WRITE(MSG(1),1000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN),CID   IUDB44    320
         WRITE(MSG(2),1030) IORD,BLNAM1,BLNAM2                          IUDB44    321
         CALL PRTMSG(2)                                                 IUDB44    322
          MSG(1)='IUDB46: UDM ERROR'                                    IUDB44    323
          CALL ASTOP(MSG(1),17)                                         IUDB44    324
         ENDIF                                                          IUDB44    325
      ENDIF                                                             IUDB44    326
  160 CONTINUE                                                          IUDB44    327
      J3=JE6-3                                                          IUDB44    328
      DO 170 J=1,INPUD                                                  IUDB44    329
      J3=J3+3                                                           IUDB44    330
      IF(IDDAT(J3+1).EQ.IORD) THEN                                      IUDB44    331
         IIN=IDDAT(J3+2)                                                IUDB44    332
         IF(IIN.EQ.20) THEN                                             IUDB44    333
            XDATN=DDAT(J3+3)                                            IUDB44    334
            NINP=NINP+1                                                 IUDB44    335
         ELSE                                                           IUDB44    336
          WRITE(MSG(1),1000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN),CID  IUDB44    337
          WRITE(MSG(2),1001) IORD,BLNAM1,BLNAM2                         IUDB44    338
          WRITE(MSG(3),1002)                                            IUDB44    339
          CALL PRTMSG(3)                                                IUDB44    340
          MSG(1)='IUDB46: UDM ERROR'                                    IUDB44    341
          CALL ASTOP(MSG(1),17)                                         IUDB44    342
         ENDIF                                                          IUDB44    343
      ENDIF                                                             IUDB44    344
  170 CONTINUE                                                          IUDB44    345
      IF(NINP.EQ.0) THEN                                                IUDB44    346
         WRITE(MSG(1),1000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN),CID   IUDB44    347
         WRITE(MSG(2),1010) IORD,BLNAM1,BLNAM2                          IUDB44    348
         CALL PRTMSG(2)                                                 IUDB44    349
          MSG(1)='IUDB46: UDM ERROR'                                    IUDB44    350
          CALL ASTOP(MSG(1),17)                                         IUDB44    351
      ENDIF                                                             IUDB44    352
      IF(NINP.GT.1) THEN                                                IUDB44    353
         WRITE(MSG(1),1000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN),CID   IUDB44    354
         WRITE(MSG(2),1250) IORD,BLNAM1,BLNAM2                          IUDB44    355
         CALL PRTMSG(2)                                                 IUDB44    356
          MSG(1)='IUDB46: UDM ERROR'                                    IUDB44    357
          CALL ASTOP(MSG(1),17)                                         IUDB44    358
      ENDIF                                                             IUDB44    359
C                                                                       IUDB44    360
C     DATA PREPARATIONS AND INPUT DATA PRINTOUT                         IUDB44    361
C                                                                       IUDB44    362
      IF(IDDAT(JEI+3).EQ.0) DDAT(JEI+3)=1.0                             IUDB44    363
      DDAT(JEI+7)=1.0/(DDAT(JEI+4)-DDAT(JEI+5))                         IUDB44    364
      DDAT(JEI+8)=DDAT(JEI+7)*DDAT(JEI+5)*SQRT(DDAT(JEI+3))             IUDB44    365
      PZERO=VALOUT(IORD)/DDAT(JEI+6)                                    IUDB44    366
C                                                                       IUDB44    367
      XSTATE(KORD+1)=PZERO/DDAT(JEI+3)+DDAT(JEI+8)                      IUDB44    368
      XSTATE(KORD)=XSTATE(KORD+1)/SQRT(DDAT(JEI+3))                     IUDB44    369
      VG=XSTATE(KORD)/DDAT(JEI+7)                                       IUDB44    370
C                                                                       IUDB44    371
      VALIN(1)=VG                                                       IUDB44    372
      IF(NEXTB.NE.0) THEN                                               IUDB44    373
         VALOUT(NEXTB)=VG                                               IUDB44    374
      ELSE                                                              IUDB44    375
         VALIN(20)=VG                                                   IUDB44    376
      ENDIF                                                             IUDB44    377
C                                                                       IUDB44    378
      IF(LDEB)WRITE(IUD6,1040) JORD                                     IUDB44    379
C                                                                       IUDB44    380
      RETURN                                                            IUDB44    381
C                                                                       IUDB44    382
C-----------------------------------------------------------------------IUDB44    383
C                                                                       IUDB44    384
      ENTRY IUDB47(IORD,CID)                                            IUDB44    385
CD                                                                      IUDB44    386
CD    FOR BLOCK TYPE 47 (TYPE T22 GOVERNOR END BLOCK).                  IUDB44    387
CD                                                                      IUDB44    388
      LDEB=(JDEB(262).NE.0)                                             IUDB44    389
C                                                                       IUDB44    390
      LL=0                                                              IUDB44    391
      NINP=0                                                            IUDB44    392
      NEXTB=0                                                           IUDB44    393
      JORD=JUDE(IORD)                                                   IUDB44    394
      KORD=JSTATE+KUDE(IORD)+1                                          IUDB44    395
      JEI=JEB+2                                                         IUDB44    396
      XKT=DDAT(JEI+2)                                                   IUDB44    397
      XK1=DDAT(JEI+3)                                                   IUDB44    398
      DTX=DDAT(JEI+4)                                                   IUDB44    399
      GMAX=DDAT(JEI+5)                                                  IUDB44    400
      GMIN=DDAT(JEI+6)                                                  IUDB44    401
      PMAX=DDAT(JEI+7)                                                  IUDB44    402
C                                                                       IUDB44    403
      IF(IDDAT(JEI+5).EQ.0.AND.IDDAT(JEI+6).EQ.0) LL=1                  IUDB44    404
      IF(GMAX.LE.GMIN.AND.LL.EQ.0) THEN                                 IUDB44    405
         WRITE(MSG(1),1000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN),CID   IUDB44    406
         WRITE(MSG(2),1470) IORD,BLNAM1,BLNAM2                          IUDB44    407
         WRITE(MSG(3),1480) GMAX,GMIN                                   IUDB44    408
         CALL PRTMSG(3)                                                 IUDB44    409
          MSG(1)='IUDB47: UDM ERROR'                                    IUDB44    410
          CALL ASTOP(MSG(1),17)                                         IUDB44    411
      ENDIF                                                             IUDB44    412
C                                                                       IUDB44    413
      J2=JE5-2                                                          IUDB44    414
      DO 180 J=1,INTUD                                                  IUDB44    415
      J2=J2+2                                                           IUDB44    416
      IDD=IDDAT(J2+2)                                                   IUDB44    417
      IDD=ABS(IDD)                                                      IUDB44    418
      IF(IDD.EQ.IORD) THEN                                              IUDB44    419
         XDAT=1.0                                                       IUDB44    420
         IF(IDDAT(J2+2).LT.0) XDAT=-1.0                                 IUDB44    421
         IOUT=IDDAT(J2+1)                                               IUDB44    422
         IF(JUDE(IOUT).EQ.0) THEN                                       IUDB44    423
            NEXTB=IOUT                                                  IUDB44    424
            XDATN=XDAT                                                  IUDB44    425
            NINP=NINP+1                                                 IUDB44    426
         ELSE                                                           IUDB44    427
         WRITE(MSG(1),1000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN),CID   IUDB44    428
         WRITE(MSG(2),1030) IORD,BLNAM1,BLNAM2                          IUDB44    429
         CALL PRTMSG(2)                                                 IUDB44    430
          MSG(1)='IUDB47: UDM ERROR'                                    IUDB44    431
          CALL ASTOP(MSG(1),17)                                         IUDB44    432
         ENDIF                                                          IUDB44    433
      ENDIF                                                             IUDB44    434
  180 CONTINUE                                                          IUDB44    435
      J3=JE6-3                                                          IUDB44    436
      DO 190 J=1,INPUD                                                  IUDB44    437
      J3=J3+3                                                           IUDB44    438
      IF(IDDAT(J3+1).EQ.IORD) THEN                                      IUDB44    439
         IIN=IDDAT(J3+2)                                                IUDB44    440
         IF(IIN.EQ.20) THEN                                             IUDB44    441
            XDATN=DDAT(J3+3)                                            IUDB44    442
            NINP=NINP+1                                                 IUDB44    443
         ELSE                                                           IUDB44    444
          WRITE(MSG(1),1000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN),CID  IUDB44    445
          WRITE(MSG(2),1001) IORD,BLNAM1,BLNAM2                         IUDB44    446
          WRITE(MSG(3),1002)                                            IUDB44    447
          CALL PRTMSG(3)                                                IUDB44    448
          MSG(1)='IUDB47: UDM ERROR'                                    IUDB44    449
          CALL ASTOP(MSG(1),17)                                         IUDB44    450
         ENDIF                                                          IUDB44    451
      ENDIF                                                             IUDB44    452
  190 CONTINUE                                                          IUDB44    453
      IF(NINP.EQ.0) THEN                                                IUDB44    454
         WRITE(MSG(1),1000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN),CID   IUDB44    455
         WRITE(MSG(2),1010) IORD,BLNAM1,BLNAM2                          IUDB44    456
         CALL PRTMSG(2)                                                 IUDB44    457
          MSG(1)='IUDB47: UDM ERROR'                                    IUDB44    458
          CALL ASTOP(MSG(1),17)                                         IUDB44    459
      ENDIF                                                             IUDB44    460
      IF(NINP.GT.1) THEN                                                IUDB44    461
         WRITE(MSG(1),1000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN),CID   IUDB44    462
         WRITE(MSG(2),1250) IORD,BLNAM1,BLNAM2                          IUDB44    463
         CALL PRTMSG(2)                                                 IUDB44    464
          MSG(1)='IUDB47: UDM ERROR'                                    IUDB44    465
          CALL ASTOP(MSG(1),17)                                         IUDB44    466
      ENDIF                                                             IUDB44    467
C                                                                       IUDB44    468
C     DATA PREPARATIONS AND INPUT DATA PRINTOUT                         IUDB44    469
C                                                                       IUDB44    470
      PMX=VALOUT(IORD)/PMAX                                             IUDB44    471
      PMX=PMX/(XKT+XK1)                                                 IUDB44    472
      IF(LL.EQ.0) THEN                                                  IUDB44    473
         IF(PMX.LT.GMIN.OR.PMX.GT.GMAX) THEN                            IUDB44    474
         WRITE(MSG(1),1000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN),CID   IUDB44    475
         WRITE(MSG(2),1460) IORD,BLNAM1,BLNAM2                          IUDB44    476
         WRITE(MSG(3),1461)                                             IUDB44    477
         CALL PRTMSG(3)                                                 IUDB44    478
         ENDIF                                                          IUDB44    479
      ENDIF                                                             IUDB44    480
      VALIN(1)=PMX                                                      IUDB44    481
      XSTATE(KORD)=PMX*XKT                                              IUDB44    482
      IF(NEXTB.NE.0) THEN                                               IUDB44    483
         VALOUT(NEXTB)=PMX                                              IUDB44    484
      ELSE                                                              IUDB44    485
         VALIN(20)=PMX                                                  IUDB44    486
      ENDIF                                                             IUDB44    487
C                                                                       IUDB44    488
      IDDAT(JEI+8)=LL                                                   IUDB44    489
      IF(LDEB)WRITE(IUD6,1040) JORD                                     IUDB44    490
C                                                                       IUDB44    491
      RETURN                                                            IUDB44    492
 1000 FORMAT(' *** ERROR USER DEFINED MODEL AT BUS:',I5,' STATION: '    IUDB44    493
     *,3A4,' ID:',A4)                                                   IUDB44    494
 1001 FORMAT(11X,'BLOCK#',I3,'(',2A4,') HAS WRONG INPUT SIGNAL.')       IUDB44    495
 1002 FORMAT(11X,'THE ONLY POSSIBLE INPUT IS "VREF".')                  IUDB44    496
 1010 FORMAT(11X,'BLOCK#',I3,'(',2A4,') HAS NO INPUT CONNECTION')       IUDB44    497
 1030 FORMAT(11X,'BLOCK#',I3,'(',2A4                                    IUDB44    498
     *,') VREF IS NOT CONNECTED TO REG. PATH')                          IUDB44    499
 1040 FORMAT(1X,'JORD: ',I5)                                            IUDB44    500
 1050 FORMAT(11X,'BLOCK#',I3,'(',2A4                                    IUDB44    501
     *,') HAS MORE THAN TWO INPUT CONNECTIONS')                         IUDB44    502
 1090 FORMAT(11X,'BLOCK#',I3,'(',2A4,') HAS WRONG INPUT SIGNAL.')       IUDB44    503
 1091 FORMAT(11X                                                        IUDB44    504
     *,'"VREF" CANNOT BE CONNECTED TO THE SECOND INPUT OF T1.')         IUDB44    505
 1100 FORMAT(11X,'T1 BLOCK#',I3,'(',2A4                                 IUDB44    506
     *,') THP TRH AND TLP MUST BE GREATER THAN 0.')                     IUDB44    507
 1250 FORMAT(11X,'BLOCK#',I3,'(',2A4                                    IUDB44    508
     *,') HAS MORE THAN ONE INPUT CONNECTIONS')                         IUDB44    509
 1260 FORMAT(11X                                                        IUDB44    510
     *,'UD GOVERNOR K5 TURNED OUT NEGATIVE. REENTER OTHER K VALUES.')   IUDB44    511
 1270 FORMAT(11X,'UD GOVERNOR  T4 CAN NOT BE EQUAL TO ZERO.')           IUDB44    512
 1360 FORMAT(11X,'BLOCK#',I3,'(',2A4                                    IUDB44    513
     *,') TW MUST BE LARGER THAN ZERO.')                                IUDB44    514
 1460 FORMAT(11X,'T22 BLOCK#',I3,'(',2A4,') VG=',F10.5)                 IUDB44    515
 1461 FORMAT(11X,'IS INITIALLY OUTSIDE GMIN AND GMAX LIMITS.')          IUDB44    516
 1470 FORMAT(11X,'END BLOCK#',I3,'(',2A4,') HAS XCROSSING LIMITS.')     IUDB44    517
 1480 FORMAT(11X,'GMAX=',F10.5,' GMIN=',F10.5)                          IUDB44    518
      END                                                               IUDB44    519
