CFPRIME RRANDA                                                          RRANDA      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 RRANDA(IUX,IUY,IEBK)                                   RRANDA      3
CD                                                                      RRANDA      4
CD    TO READ RANI DATA.                                                RRANDA      5
CD                                                                      RRANDA      6
CD    ROUT INPUT:                                                       RRANDA      7
CD                                                                      RRANDA      8
CD    IUX IS THE UNIT OF WHICH RANI DATA IS READ                        RRANDA      9
CD    IUY IS THE UNIT OF WHICH ERROR AND WARNING MESSAGE WILL BE WRITTENRRANDA     10
CD    IEBK IS ERROR INDICATOR                                           RRANDA     11
CD    IEBK = 1 WHEN RANI BUSES EXCEED THE PROGRAM LIMIT                 RRANDA     12
CD                                                                      RRANDA     13
C                                                                       RRANDA     14
      INCLUDE 'PARX.INS'                                                RRANDA     15
      INCLUDE 'CNFLAG.INS'                                              RRANDA     16
      INCLUDE 'CNB19.INS'                                               RRANDA     17
      INCLUDE 'CNMNEW.INS'                                              RRANDA     18
      INCLUDE 'CNJPT.INS'                                               RRANDA     19
      INCLUDE 'CNJDAT.INS'                                              RRANDA     20
      INCLUDE 'CNTMDA.INS'                                              RRANDA     21
      INCLUDE 'CNUNIT.INS'                                              RRANDA     22
      INCLUDE 'CNMSG.INS'                                               RRANDA     23
      INCLUDE 'CNPARX.INS'                                              RRANDA     24
*IF FACTS                                                               RRANDA     25
C                                                                       RRANDA     26
      CHARACTER*40 LCARD(2)                                             RRANDA     27
C                                                                       RRANDA     28
      CHARACTER*80 SIMBUF                                               RRANDA     29
      CHARACTER*12 RANIA1,RANIA2                                        RRANDA     30
      INTEGER IBUSN(3),JBUSN(3)                                         RRANDA     31
C                                                                       RRANDA     32
      CHARACTER*2 KCKT1                                                 RRANDA     33
      EQUIVALENCE (IBUSN(1),RANIA1),(JBUSN(1),RANIA2)                   RRANDA     34
C                                                                       RRANDA     35
      DATA LCARD(1)/'     START OF THE RANI DATA             '/         RRANDA     36
      DATA LCARD(2)/'                                        '/         RRANDA     37
C                                                                       RRANDA     38
C     READING RANI DATA                                                 RRANDA     39
C                                                                       RRANDA     40
      LDEB=(JDEB(8).NE.0)                                               RRANDA     41
C                                                                       RRANDA     42
  100 CONTINUE                                                          RRANDA     43
      CALL GETLIN (IUX,SIMBUF)                                          RRANDA     44
      IF (SIMBUF(1:5).EQ.'EDATA')GOTO 130                               RRANDA     45
C                                                                       RRANDA     46
      LDSTAT=1                                                          RRANDA     47
C                                                                       RRANDA     48
      IF(KLFO.EQ.0)THEN                                                 RRANDA     49
         READ (SIMBUF,1000,IOSTAT=IOS)                                  RRANDA     50
     *         NLF1,NLF2,KCKT1,NRTYPX,IBFARX,IDIVX                      RRANDA     51
         IF(IOS.NE.0) GOTO 900                                          RRANDA     52
      IF(NLF1.GT.N99999.OR.NLF2.GT.N99999)THEN                          RRANDA     53
      WRITE(MSG(2),1070) N99999                                         RRANDA     54
      MSG(1)=SIMBUF                                                     RRANDA     55
      CALL PRTMSG(2)                                                    RRANDA     56
      LDSTAT=5                                                          RRANDA     57
      ENDIF                                                             RRANDA     58
      ELSE                                                              RRANDA     59
         READ (SIMBUF,1030,IOSTAT=IOS)                                  RRANDA     60
     *         RANIA1,RANIA2,KCKT1,NRTYPX,IBFARX,IDIVX                  RRANDA     61
         IF(IOS.NE.0) GOTO 900                                          RRANDA     62
         CALL CHKBUS(RANIA1,NLF1)                                       RRANDA     63
         CALL CHKBUS(RANIA2,NLF2)                                       RRANDA     64
      ENDIF                                                             RRANDA     65
 105  CONTINUE                                                          RRANDA     66
      LCARD(1)=SIMBUF(1:40)                                             RRANDA     67
      LCARD(2)=SIMBUF(41:80)                                            RRANDA     68
C                                                                       RRANDA     69
      JRANI=JRANI+1                                                     RRANDA     70
      IF(JRANI.GT.NXRAN)GOTO 120                                        RRANDA     71
      JJRDAT(JRANI)=JTLN                                                RRANDA     72
C                                                                       RRANDA     73
      IF(KLFO.EQ.0)THEN                                                 RRANDA     74
         IF(MNEW(NLF1).EQ.0)THEN                                        RRANDA     75
            WRITE(MSG(1),1020)                                          RRANDA     76
            MSG(2)=SIMBUF                                               RRANDA     77
            CALL PRTMSG(2)                                              RRANDA     78
            LDSTAT=5                                                    RRANDA     79
         ENDIF                                                          RRANDA     80
         IF(MNEW(NLF2).EQ.0)THEN                                        RRANDA     81
            WRITE(MSG(1),1020)                                          RRANDA     82
            MSG(2)=SIMBUF                                               RRANDA     83
            CALL PRTMSG(2)                                              RRANDA     84
            LDSTAT=5                                                    RRANDA     85
         ENDIF                                                          RRANDA     86
      ITDDAT(JTLN+1)=NLF1                                               RRANDA     87
      ITDDAT(JTLN+2)=NLF2                                               RRANDA     88
      CALL PACK(KCKT1,0,JCKID)                                          RRANDA     89
      ITDDAT(JTLN+3)=JCKID                                              RRANDA     90
      ITDDAT(JTLN+4)=NRTYPX                                             RRANDA     91
      ITDDAT(JTLN+5)=IBFARX                                             RRANDA     92
      IF(IDIVX.LT.1)IDIVX=1                                             RRANDA     93
      ITDDAT(JTLN+7)=IDIVX                                              RRANDA     94
      JTLN=JTLN+7                                                       RRANDA     95
      ELSE                                                              RRANDA     96
         IF (NLF1.LE.0) THEN                                            RRANDA     97
            WRITE(MSG(1),1020)                                          RRANDA     98
            MSG(2)=SIMBUF                                               RRANDA     99
            CALL PRTMSG(2)                                              RRANDA    100
            LDSTAT=5                                                    RRANDA    101
         ENDIF                                                          RRANDA    102
         IF (NLF2.LE.0) THEN                                            RRANDA    103
            WRITE(MSG(1),1020)                                          RRANDA    104
            MSG(2)=SIMBUF                                               RRANDA    105
            CALL PRTMSG(2)                                              RRANDA    106
            LDSTAT=5                                                    RRANDA    107
         ENDIF                                                          RRANDA    108
      ITDDAT(JTLN+1)=IBUSN(1)                                           RRANDA    109
      ITDDAT(JTLN+2)=IBUSN(2)                                           RRANDA    110
      ITDDAT(JTLN+3)=IBUSN(3)                                           RRANDA    111
      ITDDAT(JTLN+4)=JBUSN(1)                                           RRANDA    112
      ITDDAT(JTLN+5)=JBUSN(2)                                           RRANDA    113
      ITDDAT(JTLN+6)=JBUSN(3)                                           RRANDA    114
      CALL PACK(KCKT1,0,JCKID)                                          RRANDA    115
      ITDDAT(JTLN+7)=JCKID                                              RRANDA    116
      ITDDAT(JTLN+8)=NRTYPX                                             RRANDA    117
      ITDDAT(JTLN+9)=IBFARX                                             RRANDA    118
      IF(IDIVX.LT.1)IDIVX=1                                             RRANDA    119
      ITDDAT(JTLN+11)=IDIVX                                             RRANDA    120
      JTLN=JTLN+11                                                      RRANDA    121
      ENDIF                                                             RRANDA    122
C                                                                       RRANDA    123
      IF(LDSTAT.EQ.1)THEN                                               RRANDA    124
      NPROG=MNEW(NLF1)                                                  RRANDA    125
      LDSTAT=JBSTAT(NPROG)                                              RRANDA    126
      ENDIF                                                             RRANDA    127
      IF(LDSTAT.LT.3)THEN                                               RRANDA    128
      NPROG=MNEW(NLF2)                                                  RRANDA    129
      LDSTAT=JBSTAT(NPROG)                                              RRANDA    130
      ENDIF                                                             RRANDA    131
      JSTRAN(JRANI)=LDSTAT                                              RRANDA    132
C                                                                       RRANDA    133
      IF (NRTYPX.NE.50) GO TO 110                                       RRANDA    134
C                                                                       RRANDA    135
C     USER DEFINED RANI DATA                                            RRANDA    136
C                                                                       RRANDA    137
      JTLN1=JTLN-1                                                      RRANDA    138
      NUF=6                                                             RRANDA    139
      CALL RUDMDA(NUF,IUX,IUY,JTLN1,SIMBUF)                             RRANDA    140
      IF(NUF.EQ.900) GO TO 900                                          RRANDA    141
      CALL MCHECK (NLF1,14,JTLN,'RRANDA')                               RRANDA    142
      GO TO 100                                                         RRANDA    143
C                                                                       RRANDA    144
  110 CONTINUE                                                          RRANDA    145
      WRITE (MSG(1),1050) NRTYPX                                        RRANDA    146
      MSG(2)=LCARD(1)//LCARD(2)                                         RRANDA    147
      CALL PRTMSG(2)                                                    RRANDA    148
      SIMBUF='RRANDA: RANI TYPE ERROR'                                  RRANDA    149
      CALL ASTOP(SIMBUF,23)                                             RRANDA    150
C                                                                       RRANDA    151
  120 CONTINUE                                                          RRANDA    152
      WRITE (MSG(1),1010) NXRAN                                         RRANDA    153
      MSG(2)=LCARD(1)//LCARD(2)                                         RRANDA    154
      CALL PRTMSG(2)                                                    RRANDA    155
      IEBK=1                                                            RRANDA    156
  130 CONTINUE                                                          RRANDA    157
C                                                                       RRANDA    158
      RETURN                                                            RRANDA    159
C                                                                       RRANDA    160
  900 CONTINUE                                                          RRANDA    161
      WRITE(MSG(1),1040)                                                RRANDA    162
      MSG(2)=LCARD(1)//LCARD(2)                                         RRANDA    163
      MSG(4)=SIMBUF                                                     RRANDA    164
      WRITE(MSG(3),1041)                                                RRANDA    165
      CALL PRTMSG(4)                                                    RRANDA    166
      SIMBUF='RRANDA RANI DATA MIX UP ERROR'                            RRANDA    167
      CALL ASTOP(SIMBUF,29)                                             RRANDA    168
C                                                                       RRANDA    169
 1000 FORMAT(2I5,3X,A2,3I5)                                             RRANDA    170
 1010 FORMAT(1X,'*** ERROR RANI BUSES'                                  RRANDA    171
     &,' EXCEEDS THE LIMIT OF ',I4)                                     RRANDA    172
 1020 FORMAT(' *** RANI BUS NAME ERROR',                                RRANDA    173
     &       ' CHECK THE FOLLOWING CARD :')                             RRANDA    174
 1030 FORMAT (2A12,4X,A2,3I5)                                           RRANDA    175
 1040 FORMAT(' *** READ ERROR AT THE CARD:')                            RRANDA    176
 1041 FORMAT(11X,'THIS IS THE FIRST CARD OF THE',                       RRANDA    177
     & ' RANI DEVICE LAST READ:')                                       RRANDA    178
 1050 FORMAT(1X,'*** ERROR RANI HAS UNKOWN TYPE',I5)                    RRANDA    179
 1070 FORMAT(' *** ERROR BUS NUMBER OF THE ABOVE RANI EXCEEDED',I6)     RRANDA    180
*ENDIF                                                                  RRANDA    181
*IF -FACTS                                                              RRANDA    182
*ENDIF                                                                  RRANDA    187
      END                                                               RRANDA    188
