CFPRIME RINUDM                                                          RINUDM      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 RINUDM                                                 RINUDM      3
CD                                                                      RINUDM      4
CD    TO PROCESS THE REMOTE AND SOURCE INPUTS OF USER DEFINED AC MODELS.RINUDM      5
CD                                                                      RINUDM      6
      INCLUDE 'PARX.INS'                                                RINUDM      7
      INCLUDE 'CNPT.INS'                                                RINUDM      8
      INCLUDE 'CNVOLT.INS'                                              RINUDM      9
      INCLUDE 'CNIPTR.INS'                                              RINUDM     10
      INCLUDE 'CNNNEW.INS'                                              RINUDM     11
      INCLUDE 'CNMDAT.INS'                                              RINUDM     12
      INCLUDE 'CNB3.INS'                                                RINUDM     13
      INCLUDE 'CNB4.INS'                                                RINUDM     14
      INCLUDE 'CNB5.INS'                                                RINUDM     15
      INCLUDE 'CNB8.INS'                                                RINUDM     16
      INCLUDE 'CNB9.INS'                                                RINUDM     17
      INCLUDE 'CNB10.INS'                                               RINUDM     18
      INCLUDE 'CNB19.INS'                                               RINUDM     19
      INCLUDE 'CNEXC.INS'                                               RINUDM     20
      INCLUDE 'CNXSTA.INS'                                              RINUDM     21
      INCLUDE 'CNYVAR.INS'                                              RINUDM     22
      INCLUDE 'CNUDM.INS'                                               RINUDM     23
      INCLUDE 'CNFLAG.INS'                                              RINUDM     24
      INCLUDE 'CNUNIT.INS'                                              RINUDM     25
C                                                                       RINUDM     26
      LDEB=(JDEB(263).NE.0)                                             RINUDM     27
C                                                                       RINUDM     28
C     SET THE POINTERS                                                  RINUDM     29
C                                                                       RINUDM     30
      NRBUS=IDDAT(JE1)                                                  RINUDM     31
      JE2=JE1+3*NRBUS+1                                                 RINUDM     32
      NRLIN=IDDAT(JE2)                                                  RINUDM     33
      JE3=JE2+4*NRLIN+1                                                 RINUDM     34
      NUDB=IDDAT(JE3)                                                   RINUDM     35
      JE4=JE3+17*NUDB+1                                                 RINUDM     36
      JE5=JE4+3*NUDB+1                                                  RINUDM     37
      INTUD=IDDAT(JE5)                                                  RINUDM     38
      JE6=JE5+2*INTUD+1                                                 RINUDM     39
      INPUD=IDDAT(JE6)                                                  RINUDM     40
      JE7=JE6+3*INPUD                                                   RINUDM     41
C                                                                       RINUDM     42
C     GET THE INPUT VALUES                                              RINUDM     43
C                                                                       RINUDM     44
      VALIN(13)=1.0                                                     RINUDM     45
      VALIN(14)=TS                                                      RINUDM     46
      IF(NRBUS.NE.0) THEN                                               RINUDM     47
         DO 100 I=1,NRBUS                                               RINUDM     48
         NI=3*I                                                         RINUDM     49
         IBUS=IDDAT(JE1+NI-2)                                           RINUDM     50
         VRE=REAL(VOLT(IBUS))                                           RINUDM     51
         VIM=AIMAG(VOLT(IBUS))                                          RINUDM     52
         VMG=SQRT(VRE*VRE+VIM*VIM)                                      RINUDM     53
         VALIN(20+I)=VMG                                                RINUDM     54
         IF(VMG.GT.0.05) THEN                                           RINUDM     55
            VAG=ATAN2(VIM,VRE)                                          RINUDM     56
            VAGD=DDAT(JE1+NI)-VAG                                       RINUDM     57
            DDAT(JE1+NI)=VAG                                            RINUDM     58
            IF(VAGD.GT.3.15) THEN                                       RINUDM     59
               IDDAT(JE1+NI-1)=IDDAT(JE1+NI-1)+1                        RINUDM     60
            ELSEIF(VAGD.LT.-3.15) THEN                                  RINUDM     61
               IDDAT(JE1+NI-1)=IDDAT(JE1+NI-1)-1                        RINUDM     62
            ENDIF                                                       RINUDM     63
            VALIN(30+I)=VAG+6.2831853*IDDAT(JE1+NI-1)                   RINUDM     64
         ELSE                                                           RINUDM     65
            VALIN(30+I)=DDAT(JE1+NI)+6.2831853*IDDAT(JE1+NI-1)          RINUDM     66
         ENDIF                                                          RINUDM     67
  100    CONTINUE                                                       RINUDM     68
      ENDIF                                                             RINUDM     69
      IF(NRLIN.NE.0) THEN                                               RINUDM     70
         NR4=JE2-4                                                      RINUDM     71
         DO 110 I=1,NRLIN                                               RINUDM     72
         NR4=NR4+4                                                      RINUDM     73
         IBUS1=IDDAT(NR4+1)                                             RINUDM     74
         LOC=IDDAT(NR4+4)                                               RINUDM     75
         CALL GETCUR(CURR,CURI,LOC)                                     RINUDM     76
         VALIN(40+I)=SQRT(CURR*CURR+CURI*CURI)                          RINUDM     77
         VRE=REAL(VOLT(IBUS1))                                          RINUDM     78
         VIM=AIMAG(VOLT(IBUS1))                                         RINUDM     79
         VALIN(50+I)=VRE*CURR+VIM*CURI                                  RINUDM     80
         VALIN(60+I)=VIM*CURR-VRE*CURI                                  RINUDM     81
         S1=SQRT(VALIN(50+I)**2+VALIN(60+I)**2)                         RINUDM     82
         IF(S1.GT.0.0) THEN                                             RINUDM     83
            VALIN(70+I)=VALIN(50+I)/S1                                  RINUDM     84
         ELSE                                                           RINUDM     85
            VALIN(70+I)=1.0                                             RINUDM     86
         ENDIF                                                          RINUDM     87
  110    CONTINUE                                                       RINUDM     88
      ENDIF                                                             RINUDM     89
      RETURN                                                            RINUDM     90
      END                                                               RINUDM     91
