CFPRIME RANINT                                                          RANINT      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 RANINT(*)                                              RANINT      3
CD                                                                      RANINT      4
CD    THIS ROUTINE INITIALZES ALL RANI DEVICES.                         RANINT      5
CD                                                                      RANINT      6
      INCLUDE 'PARX.INS'                                                RANINT      7
      INCLUDE 'CNPT.INS'                                                RANINT      8
      INCLUDE 'CNIPTR.INS'                                              RANINT      9
      INCLUDE 'CNSTN.INS'                                               RANINT     10
      INCLUDE 'CNB1.INS'                                                RANINT     11
      INCLUDE 'CNB4.INS'                                                RANINT     12
      INCLUDE 'CNB19.INS'                                               RANINT     13
      INCLUDE 'CNRAN.INS'                                               RANINT     14
      INCLUDE 'CNUDM.INS'                                               RANINT     15
C                                                                       RANINT     16
      INCLUDE 'CNXSTA.INS'                                              RANINT     17
      INCLUDE 'CNMDAT.INS'                                              RANINT     18
      INCLUDE 'CNVOLT.INS'                                              RANINT     19
      INCLUDE 'CNNNEW.INS'                                              RANINT     20
      INCLUDE 'CNMYVA.INS'                                              RANINT     21
      INCLUDE 'CNYVAR.INS'                                              RANINT     22
C                                                                       RANINT     23
      INCLUDE 'CNQSTA.INS'                                              RANINT     24
      INCLUDE 'EQQSTA.INS'                                              RANINT     25
      INCLUDE 'CNFLAG.INS'                                              RANINT     26
      INCLUDE 'CNUNIT.INS'                                              RANINT     27
C                                                                       RANINT     28
      CHARACTER*2 LCKT                                                  RANINT     29
      INTEGER*4 JCKID                                                   RANINT     30
      CHARACTER*4 CKID                                                  RANINT     31
      EQUIVALENCE (JCKID,CKID)                                          RANINT     32
C                                                                       RANINT     33
      LDEB=.FALSE.                                                      RANINT     34
C                                                                       RANINT     35
      DO 110 N=1,NRANI                                                  RANINT     36
      IF(JY+10+NXUDB.GT.NSI) RETURN 1                                   RANINT     37
      JR=JRDAT(N)                                                       RANINT     38
      JXRAN(N)=JSTATE                                                   RANINT     39
      JVRAN(N)=JY                                                       RANINT     40
      K1=IDDAT(JR+1)                                                    RANINT     41
      K2=IDDAT(JR+2)                                                    RANINT     42
      K13=K1*3                                                          RANINT     43
      K23=K2*3                                                          RANINT     44
      NLF1=NOLD(K1)                                                     RANINT     45
      NLF2=NOLD(K2)                                                     RANINT     46
      VR1=REAL(VOLT(K1))                                                RANINT     47
      VI1=AIMAG(VOLT(K1))                                               RANINT     48
      VM1=SQRT(VR1**2+VI1**2)                                           RANINT     49
      VR2=REAL(VOLT(K2))                                                RANINT     50
      VI2=AIMAG(VOLT(K2))                                               RANINT     51
      VM2=SQRT(VR2**2+VI2**2)                                           RANINT     52
      JCKID=IDDAT(JR+3)                                                 RANINT     53
      CALL UNPACK(LCKT,JJJ,JCKID)                                       RANINT     54
      NRTYPN=IDDAT(JR+4)                                                RANINT     55
      IBFARX=IDDAT(JR+5)                                                RANINT     56
      IRANF=IDDAT(JR+6)                                                 RANINT     57
      IDIVX=IDDAT(JR+7)                                                 RANINT     58
      IF(IRANF.EQ.2) THEN                                               RANINT     59
         XRAN=BRANT(N)/(GRANT(N)**2+BRANT(N)**2)                        RANINT     60
         BRANI(JY+2)=XRAN*IBFARX/100.0                                  RANINT     61
         BRANI(JY+8)=GRANT(N)                                           RANINT     62
         BRANO(JY+9)=GRANT(N)                                           RANINT     63
      ELSE                                                              RANINT     64
         BRANI(JY+2)=BRANT(N)                                           RANINT     65
         BRANO(JY+10)=0.0                                               RANINT     66
      ENDIF                                                             RANINT     67
      BRANO(JY+3)=BRANT(N)                                              RANINT     68
C                                                                       RANINT     69
      IF(NRTYPN.EQ.50) THEN                                             RANINT     70
         CALL FMOVE(0,VALIN,VALIN,80)                                   RANINT     71
         VALIN(7)=VM1                                                   RANINT     72
         VALIN(8)=VM2                                                   RANINT     73
         IF(VM1.GT.0.05)VALIN(9)=ATAN2(VI1,VR1)                         RANINT     74
         IF(VM2.GT.0.05)VALIN(10)=ATAN2(VI2,VR2)                        RANINT     75
C                                                                       RANINT     76
         VRE=VR1-VR2                                                    RANINT     77
         VIM=VI1-VI2                                                    RANINT     78
         VMG=SQRT(VRE**2+VIM**2)                                        RANINT     79
         JE0=JR+7                                                       RANINT     80
         IDDAT(JE0+1)=0                                                 RANINT     81
         DDAT(JE0+2)=VALIN(9)                                           RANINT     82
         IDDAT(JE0+3)=0                                                 RANINT     83
         DDAT(JE0+4)=VALIN(10)                                          RANINT     84
         JE1=JE0+5                                                      RANINT     85
         NUF=6                                                          RANINT     86
         CALL UDMINT(NUF,VMG,NLF1,K13,LCKT)                             RANINT     87
C                                                                       RANINT     88
C         IF(LDEB) WRITE(IUD6,1030) (I,VALIN(I),I=1,80)                 RANINT     89
C                                                                       RANINT     90
C     STORE THE REQUIRED INPUTS AND OUTPUTS                             RANINT     91
C                                                                       RANINT     92
         IOUT=IDDAT(JE7+1)                                              RANINT     93
         RVREF(JY+1)=VALIN(20)                                          RANINT     94
         BDEV(JY+5)=VALOUT(IOUT)                                        RANINT     95
         IF(IRANF.EQ.0) THEN                                            RANINT     96
            BTCR(JY+6)=VALIN(6)                                         RANINT     97
            STCR(JY+7)=VALIN(11)                                        RANINT     98
         ELSE                                                           RANINT     99
            SRAN(JY+7)=VALIN(12)                                        RANINT    100
         ENDIF                                                          RANINT    101
         JY=JY+10                                                       RANINT    102
         DO 100 J=1,NXUDB                                               RANINT    103
         YVAR(JY+J)=VALOUT(J)                                           RANINT    104
  100    CONTINUE                                                       RANINT    105
         JY=JY+NXUDB                                                    RANINT    106
         GO TO 110                                                      RANINT    107
      ENDIF                                                             RANINT    108
  110 CONTINUE                                                          RANINT    109
      JXRAN(NRANI+1)=JSTATE                                             RANINT    110
      RETURN                                                            RANINT    111
C                                                                       RANINT    112
 1030 FORMAT(1X,'INPUT VALUES: ',/,I5,F10.3)                            RANINT    113
      END                                                               RANINT    114
