CFPRIME UDMSTR                                                          UDMSTR      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 UDMSTR(KSUD)                                           UDMSTR      3
CD                                                                      UDMSTR      4
CD    TO OBTAIN BLOCK INPUTS IN SOLUTION ORDER.                         UDMSTR      5
CD                                                                      UDMSTR      6
      INCLUDE 'PARX.INS'                                                UDMSTR      7
      INCLUDE 'CNMDAT.INS'                                              UDMSTR      8
C      INCLUDE 'CNMSTA.INS/LIST'                                        UDMSTR      9
      INCLUDE 'CNXSTA.INS'                                              UDMSTR     10
      INCLUDE 'CNSTN.INS'                                               UDMSTR     11
      INCLUDE 'CNYVAR.INS'                                              UDMSTR     12
      INCLUDE 'CNUNIT.INS'                                              UDMSTR     13
      INCLUDE 'CNFLAG.INS'                                              UDMSTR     14
      INCLUDE 'CNUDM.INS'                                               UDMSTR     15
C                                                                       UDMSTR     16
      LDEB=(JDEB(265).NE.0)                                             UDMSTR     17
C                                                                       UDMSTR     18
      NWL=0                                                             UDMSTR     19
      KSUD=0                                                            UDMSTR     20
      IDDAT(JE4)=KINPU                                                  UDMSTR     21
C                                                                       UDMSTR     22
C     STORE THE SOLUTION ORDER                                          UDMSTR     23
C                                                                       UDMSTR     24
      DO 100 I=1,NUDB                                                   UDMSTR     25
      IDDAT(JE4+I)=KUDE(I)                                              UDMSTR     26
  100 CONTINUE                                                          UDMSTR     27
C                                                                       UDMSTR     28
      DO 140 LORD=1,NUDB                                                UDMSTR     29
      KINT=0                                                            UDMSTR     30
      KINP=0                                                            UDMSTR     31
      JORD=IDDAT(JE4+LORD)                                              UDMSTR     32
      JEI=JE3+17*JORD-15                                                UDMSTR     33
C                                                                       UDMSTR     34
C     ORDER THE STATES                                                  UDMSTR     35
C                                                                       UDMSTR     36
      KUDE(JORD)=KSUD                                                   UDMSTR     37
      LTYP=IDDAT(JEI)                                                   UDMSTR     38
      IF(LTYP.EQ.2.OR.LTYP.EQ.3.OR.LTYP.EQ.5.OR.                        UDMSTR     39
     &   LTYP.EQ.31.OR.LTYP.EQ.32.OR.LTYP.EQ.33.OR.LTYP.EQ.34.OR.       UDMSTR     40
     &   LTYP.EQ.35.OR.LTYP.EQ.36.OR.LTYP.EQ.37.OR.LTYP.EQ.40.OR.       UDMSTR     41
     &   LTYP.EQ.48.OR.(LTYP.GT.51.AND.LTYP.LT.65)                      UDMSTR     42
     &   .OR.LTYP.EQ.71) THEN                                           UDMSTR     43
         KSUD=KSUD+1                                                    UDMSTR     44
         VMAX=999.0                                                     UDMSTR     45
         VMIN=999.0                                                     UDMSTR     46
         IF(LTYP.EQ.2) THEN                                             UDMSTR     47
            VMAX=DDAT(JEI+2)                                            UDMSTR     48
            VMIN=DDAT(JEI+3)                                            UDMSTR     49
         ENDIF                                                          UDMSTR     50
         IF(LTYP.EQ.3) THEN                                             UDMSTR     51
            VMAX=DDAT(JEI+3)                                            UDMSTR     52
            VMIN=DDAT(JEI+4)                                            UDMSTR     53
         ENDIF                                                          UDMSTR     54
         IF(LTYP.EQ.5) THEN                                             UDMSTR     55
            IF(DDAT(JEI+2).LT.DDAT(JEI+3)) THEN                         UDMSTR     56
               VMAX=DDAT(JEI+4)                                         UDMSTR     57
               VMIN=DDAT(JEI+5)                                         UDMSTR     58
            ELSE                                                        UDMSTR     59
               VMAX=0.0                                                 UDMSTR     60
               VMIN=0.0                                                 UDMSTR     61
            ENDIF                                                       UDMSTR     62
         ENDIF                                                          UDMSTR     63
         IF(LTYP.EQ.71) THEN                                            UDMSTR     64
            VMAX=DDAT(JEI+9)                                            UDMSTR     65
            VMIN=DDAT(JEI+10)                                           UDMSTR     66
         ENDIF                                                          UDMSTR     67
         IF(VMAX.LT.0.0.OR.VMAX.GT.0.0.OR.                              UDMSTR     68
     *      VMIN.LT.0.0.OR.VMIN.GT.0.0) THEN                            UDMSTR     69
            NWL=NWL+1                                                   UDMSTR     70
            IDDAT(JE4+NUDB+NWL)=JORD                                    UDMSTR     71
            IDDAT(JE4+2*NUDB+NWL)=KSUD+JSTATE                           UDMSTR     72
         ENDIF                                                          UDMSTR     73
      ENDIF                                                             UDMSTR     74
      IF(LTYP.EQ.22.OR.LTYP.EQ.24) KSUD=KSUD+IDDAT(JEI+1)               UDMSTR     75
      IF(LTYP.EQ.4.OR.LTYP.EQ.53.OR.LTYP.EQ.47.OR.LTYP.EQ.71)KSUD=KSUD+1UDMSTR     76
      IF(LTYP.EQ.12.AND.IDDAT(JEI+2).NE.0) KSUD=KSUD+1                  UDMSTR     77
      IF(LTYP.EQ.46) KSUD=KSUD+2                                        UDMSTR     78
      IF(LTYP.EQ.44.OR.LTYP.EQ.45) KSUD=KSUD+4                          UDMSTR     79
      IF(LTYP.EQ.31.OR.LTYP.EQ.32.OR.LTYP.EQ.33.OR.LTYP.EQ.34.OR.       UDMSTR     80
     &   LTYP.EQ.37.OR.LTYP.EQ.38.OR.LTYP.EQ.39.OR.LTYP.EQ.40.OR.       UDMSTR     81
     &   LTYP.EQ.41.OR.LTYP.EQ.42.OR.LTYP.EQ.51.OR.LTYP.EQ.52.OR.       UDMSTR     82
     &   LTYP.EQ.53.OR.LTYP.EQ.54.OR.LTYP.EQ.55.OR.LTYP.EQ.44.OR.       UDMSTR     83
     &   LTYP.EQ.45.OR.LTYP.EQ.46.OR.LTYP.EQ.47.OR.LTYP.EQ.56.OR.       UDMSTR     84
     &   LTYP.EQ.57.OR.LTYP.EQ.58.OR.LTYP.EQ.59) THEN                   UDMSTR     85
         J2=JE5-2                                                       UDMSTR     86
         DO 110 J=1,INTUD                                               UDMSTR     87
         J2=J2+2                                                        UDMSTR     88
         IDD=IDDAT(J2+2)                                                UDMSTR     89
         IDD=IABS(IDD)                                                  UDMSTR     90
         IF(IDD.EQ.JORD) THEN                                           UDMSTR     91
            MORD=IDDAT(J2+1)                                            UDMSTR     92
            JEK=JE3+17*MORD-15                                          UDMSTR     93
            LTYP1=IDDAT(JEK)                                            UDMSTR     94
            IF(LTYP1.EQ.2.OR.LTYP1.EQ.3.OR.LTYP1.EQ.5) THEN             UDMSTR     95
               VMAX=999.0                                               UDMSTR     96
               VMIN=999.0                                               UDMSTR     97
               IF(LTYP1.EQ.2) THEN                                      UDMSTR     98
                  VMAX=DDAT(JEK+2)                                      UDMSTR     99
                  VMIN=DDAT(JEK+3)                                      UDMSTR    100
               ENDIF                                                    UDMSTR    101
               IF(LTYP1.EQ.3) THEN                                      UDMSTR    102
                  VMAX=DDAT(JEK+3)                                      UDMSTR    103
                  VMIN=DDAT(JEK+4)                                      UDMSTR    104
               ENDIF                                                    UDMSTR    105
               IF(LTYP1.EQ.5) THEN                                      UDMSTR    106
                  IF(DDAT(JEI+2).LT.DDAT(JEI+3)) THEN                   UDMSTR    107
                     VMAX=DDAT(JEK+4)                                   UDMSTR    108
                     VMIN=DDAT(JEK+5)                                   UDMSTR    109
                  ELSE                                                  UDMSTR    110
                     VMAX=0.0                                           UDMSTR    111
                     VMIN=0.0                                           UDMSTR    112
                  ENDIF                                                 UDMSTR    113
               ENDIF                                                    UDMSTR    114
               IF(VMAX.LT.0.0.OR.VMAX.GT.0.0.OR.                        UDMSTR    115
     *            VMIN.LT.0.0.OR.VMIN.GT.0.0) THEN                      UDMSTR    116
                  IF(NWL.LT.NUDB) THEN                                  UDMSTR    117
                     NWL=NWL+1                                          UDMSTR    118
                     IDDAT(JE4+NUDB+NWL)=MORD+1000                      UDMSTR    119
                     IDDAT(JE4+2*NUDB+NWL)=KUDE(MORD)+1+JSTATE          UDMSTR    120
                  ENDIF                                                 UDMSTR    121
                  GO TO 115                                             UDMSTR    122
               ENDIF                                                    UDMSTR    123
            ENDIF                                                       UDMSTR    124
         ENDIF                                                          UDMSTR    125
  110    CONTINUE                                                       UDMSTR    126
      ENDIF                                                             UDMSTR    127
  115 CONTINUE                                                          UDMSTR    128
C                                                                       UDMSTR    129
C     STORE THE BLOCK INPUTS FROM OTHER BLOCKS                          UDMSTR    130
C                                                                       UDMSTR    131
      J2=JE5-2                                                          UDMSTR    132
      DO 120 J=1,INTUD                                                  UDMSTR    133
      J2=J2+2                                                           UDMSTR    134
      IDD=IDDAT(J2+2)                                                   UDMSTR    135
      IDD=IABS(IDD)                                                     UDMSTR    136
      IF(IDD.EQ.JORD.AND.LTYP.NE.11) THEN                               UDMSTR    137
         XDAT=1.0                                                       UDMSTR    138
         IF(IDDAT(J2+2).LT. 0)XDAT=-1.0                                 UDMSTR    139
         IOUT=IDDAT(J2+1)                                               UDMSTR    140
         KINT=KINT+1                                                    UDMSTR    141
         GAINS(KINPU+KINT)=XDAT                                         UDMSTR    142
         INPUTS(KINPU+KINT)=IOUT                                        UDMSTR    143
      ENDIF                                                             UDMSTR    144
  120 CONTINUE                                                          UDMSTR    145
      IDDAT(JEI+13)=KINT                                                UDMSTR    146
      KINPU=KINPU+KINT                                                  UDMSTR    147
C                                                                       UDMSTR    148
C     STORE THE BLOCK INPUTS FROM THE INPUT SIGNALS                     UDMSTR    149
C                                                                       UDMSTR    150
      J3=JE6-3                                                          UDMSTR    151
      DO 130 J=1,INPUD                                                  UDMSTR    152
      J3=J3+3                                                           UDMSTR    153
      IF(IDDAT(J3+1).EQ.JORD.AND.LTYP.NE.11) THEN                       UDMSTR    154
         IIN=IDDAT(J3+2)                                                UDMSTR    155
         KINP=KINP+1                                                    UDMSTR    156
         GAINS(KINPU+KINP)=DDAT(J3+3)                                   UDMSTR    157
         INPUTS(KINPU+KINP)=IIN                                         UDMSTR    158
      ENDIF                                                             UDMSTR    159
  130 CONTINUE                                                          UDMSTR    160
      IDDAT(JEI+14)=KINP                                                UDMSTR    161
      KINPU=KINPU+KINP                                                  UDMSTR    162
      IF(LDEB) WRITE(IUD6,1000)JORD,KINT,KINP,KINPU                     UDMSTR    163
  140 CONTINUE                                                          UDMSTR    164
      IF(NWL.LT.NUDB) IDDAT(JE4+NUDB+NWL+1)=0                           UDMSTR    165
C                                                                       UDMSTR    166
      RETURN                                                            UDMSTR    167
 1000 FORMAT(1X,'JORD,KINT,KINP,KINPU: ',4I5)                           UDMSTR    168
      END                                                               UDMSTR    169
