CFPRIME RULTCD                                                          RULTCD      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 RULTCD(IUX,IUY,IEBK)                                   RULTCD      3
CD                                                                      RULTCD      4
CD    TO READ ULTC DATA.                                                RULTCD      5
CD                                                   C                  RULTCD      6
CD    ROUTINE INPUTS:                                                   RULTCD      7
CD                                                                      RULTCD      8
CD     IUX IS THE UNIT OF WHICH DATA IS READ                            RULTCD      9
CD     IUY IS NOT USED IN THE CURRENT VERSION                           RULTCD     10
CD     IEBK IS AN ERROR INDICATOR                                       RULTCD     11
CD       = 0 NO ERROR                                                   RULTCD     12
CD       = 1 WHEN NUMBER OF ULTC EXCEEDS PROGRAM LIMIT                  RULTCD     13
CD       = 2 WHEN ULTC SECONDARY BUS IS NOT IN LOADFLOW                 RULTCD     14
CD       = 3 WHEN ULTC REFERENCE BUS IS NOT IN LOADFLOW                 RULTCD     15
CD       = 4 WHEN ULTC PRIMARY BUS OR SECONDARY BUS IS IN LOADFLOW      RULTCD     16
CD                                                                      RULTCD     17
      INCLUDE 'PARX.INS'                                                RULTCD     18
      INCLUDE 'CNPARX.INS'                                              RULTCD     19
      INCLUDE 'CNMNEW.INS'                                              RULTCD     20
      INCLUDE 'CNLFDA.INS'                                              RULTCD     21
      INCLUDE 'CNULTC.INS'                                              RULTCD     22
      INCLUDE 'CNTMDA.INS'                                              RULTCD     23
      INCLUDE 'CNFLAG.INS'                                              RULTCD     24
      INCLUDE 'CNMSG.INS'                                               RULTCD     25
C                                                                       RULTCD     26
C                                                                       RULTCD     27
      CHARACTER*80 SIMBUF                                               RULTCD     28
      CHARACTER*12 BSNAMP,BSNAMS,BSNAMR,BLAN12                          RULTCD     29
C                                                                       RULTCD     30
      CHARACTER*2 ICKT                                                  RULTCD     31
C                                                                       RULTCD     32
      CHARACTER*4 IBLANK,IEND                                           RULTCD     33
      CHARACTER*5 EDATA                                                 RULTCD     34
C                                                                       RULTCD     35
      DATA IBLANK/'    '/,IEND/' END'/,EDATA/'EDATA'/                   RULTCD     36
      DATA BLAN12/'            '/                                       RULTCD     37
C                                                                       RULTCD     38
C                                                                       RULTCD     39
C      NULTC = 0                                                        RULTCD     40
C                                                                       RULTCD     41
C     THIS CODE IS TEMPORARY. NREFUC WILL BE SPECIFIED IN SWITCHING FILERULTCD     42
C                                                                       RULTCD     43
C      CALL GETLIN(IUX,SIMBUF)                                          RULTCD     44
C      READ(SIMBUF,8888) NREFUC                                         RULTCD     45
C 8888 FORMAT(I5)                                                       RULTCD     46
C                                                                       RULTCD     47
C                                                                       RULTCD     48
      LDEB=.FALSE.                                                      RULTCD     49
C                                                                       RULTCD     50
 100  CONTINUE                                                          RULTCD     51
      LDSTAT=1                                                          RULTCD     52
      CALL GETLIN(IUX,SIMBUF)                                           RULTCD     53
      IF (SIMBUF(1:5) .EQ. EDATA) GOTO 110                              RULTCD     54
      IF (KLFO .EQ. 0) THEN                                             RULTCD     55
        READ(SIMBUF,1000) NLFP,NLFS,ICKT,NLFR,IREG,VREF                 RULTCD     56
C                                                                       RULTCD     57
              IF(NLFP.GT.N99999.OR.NLFS.GT.N99999.OR.NLFR.GT.N99999)THENRULTCD     58
                  WRITE(MSG(2),2100) N99999                             RULTCD     59
                  MSG(1)=SIMBUF                                         RULTCD     60
                  CALL PRTMSG(2)                                        RULTCD     61
                  SIMBUF='RULTCD: ULTC BUS NUMBER ERROR'                RULTCD     62
                  CALL ASTOP(SIMBUF,28)                                 RULTCD     63
               ENDIF                                                    RULTCD     64
        IF (NLFR .EQ. 0) NLFR = NLFS                                    RULTCD     65
        NLFP1 = MNEW(NLFP)                                              RULTCD     66
        NLFS1 = MNEW(NLFS)                                              RULTCD     67
        NLFR1 = MNEW(NLFR)                                              RULTCD     68
C                                                                       RULTCD     69
        IF (NLFP1 .EQ. 0) THEN                                          RULTCD     70
          IEBK = 1                                                      RULTCD     71
          WRITE(MSG(1),1500) NLFP                                       RULTCD     72
          CALL PRTMSG(1)                                                RULTCD     73
          LDSTAT=5                                                      RULTCD     74
        END IF                                                          RULTCD     75
        IF (NLFS1 .EQ. 0) THEN                                          RULTCD     76
          IEBK = 2                                                      RULTCD     77
          WRITE(MSG(1),1600) NLFS                                       RULTCD     78
          CALL PRTMSG(1)                                                RULTCD     79
          LDSTAT=5                                                      RULTCD     80
        END IF                                                          RULTCD     81
        IF (NLFR1 .EQ. 0) THEN                                          RULTCD     82
          IEBK = 3                                                      RULTCD     83
          WRITE(MSG(1),1700) NLFR                                       RULTCD     84
          CALL PRTMSG(1)                                                RULTCD     85
        END IF                                                          RULTCD     86
C                                                                       RULTCD     87
      ELSE                                                              RULTCD     88
        READ(SIMBUF,1100) BSNAMP,BSNAMS,ICKT,BSNAMR,IREG,VREF           RULTCD     89
        IF (BSNAMR .EQ. BLAN12) BSNAMR = BSNAMS                         RULTCD     90
C                                                                       RULTCD     91
        CALL CHKBUS(BSNAMP,NLFP)                                        RULTCD     92
        CALL CHKBUS(BSNAMS,NLFS)                                        RULTCD     93
        CALL CHKBUS(BSNAMR,NLFR)                                        RULTCD     94
        IF (NLFR .LT. 0) NLFR = -NLFR                                   RULTCD     95
C                                                                       RULTCD     96
        IF (NLFP .EQ. 0) THEN                                           RULTCD     97
          IEBK = 4                                                      RULTCD     98
          WRITE(MSG(1),1800) BSNAMP                                     RULTCD     99
          CALL PRTMSG(1)                                                RULTCD    100
          LDSTAT=5                                                      RULTCD    101
        END IF                                                          RULTCD    102
        IF (NLFS .EQ. 0) THEN                                           RULTCD    103
          IEBK = 4                                                      RULTCD    104
          WRITE(MSG(1),1900) BSNAMS                                     RULTCD    105
          CALL PRTMSG(1)                                                RULTCD    106
          LDSTAT=5                                                      RULTCD    107
        END IF                                                          RULTCD    108
        IF (NLFR .EQ. 0) THEN                                           RULTCD    109
          IEBK = 4                                                      RULTCD    110
          WRITE(MSG(1),2000) BSNAMR                                     RULTCD    111
          CALL PRTMSG(1)                                                RULTCD    112
        END IF                                                          RULTCD    113
      END IF                                                            RULTCD    114
      NULTC = NULTC+1                                                   RULTCD    115
C                                                                       RULTCD    116
      IF (NULTC .GT. NB/10) THEN                                        RULTCD    117
        WRITE(MSG(1),1400) NLFP,NLFS,NB/10                              RULTCD    118
        CALL PRTMSG(1)                                                  RULTCD    119
        IEBK = 1                                                        RULTCD    120
        RETURN                                                          RULTCD    121
      END IF                                                            RULTCD    122
C                                                                       RULTCD    123
      IF(LDSTAT.EQ.1)THEN                                               RULTCD    124
      NPROG=NLFP                                                        RULTCD    125
      LDSTAT=JBSTAT(NPROG)                                              RULTCD    126
      ENDIF                                                             RULTCD    127
      IF(LDSTAT.LT.3)THEN                                               RULTCD    128
      NPROG=NLFS                                                        RULTCD    129
      LDSTAT=JBSTAT(NPROG)                                              RULTCD    130
      ENDIF                                                             RULTCD    131
C                                                                       RULTCD    132
      JSTULT(NULTC)=LDSTAT                                              RULTCD    133
      JTULTC(NULTC) = JTLN                                              RULTCD    134
C                                                                       RULTCD    135
      ITDDAT(JTLN+1) = NLFP                                             RULTCD    136
      ITDDAT(JTLN+2) = NLFS                                             RULTCD    137
      CALL PACK(ICKT,0,JCKID)                                           RULTCD    138
      ITDDAT(JTLN+3) = JCKID                                            RULTCD    139
      IF (IREG .EQ. 0) THEN                                             RULTCD    140
        ITDDAT(JTLN+4) = NLFR                                           RULTCD    141
      ELSE                                                              RULTCD    142
        ITDDAT(JTLN+4) = -NLFR                                          RULTCD    143
      END IF                                                            RULTCD    144
      TDDAT(JTLN+23) = VREF                                             RULTCD    145
C                                                                       RULTCD    146
      CALL GETLIN(IUX,SIMBUF)                                           RULTCD    147
      READ (SIMBUF,1200) ITYPE,ICHOI                                    RULTCD    148
      ITDDAT(JTLN+5) = ITYPE                                            RULTCD    149
      ITDDAT(JTLN+6) = ICHOI                                            RULTCD    150
C                                                                       RULTCD    151
      CALL GETLIN(IUX,SIMBUF)                                           RULTCD    152
      READ (SIMBUF,1300) RC,XC,DB,EPSLO,AKP,AKC                         RULTCD    153
C                                                                       RULTCD    154
      IF (AKP .EQ. 0.) AKP = 1.                                         RULTCD    155
      IF (AKC .EQ. 0.) AKC = 1.                                         RULTCD    156
      TDDAT(JTLN+7) = RC                                                RULTCD    157
      TDDAT(JTLN+8) = XC                                                RULTCD    158
      TDDAT(JTLN+9) = DB                                                RULTCD    159
      TDDAT(JTLN+10) = EPSLO                                            RULTCD    160
      TDDAT(JTLN+11) = AKP                                              RULTCD    161
      TDDAT(JTLN+12) = AKC                                              RULTCD    162
C                                                                       RULTCD    163
      CALL GETLIN(IUX,SIMBUF)                                           RULTCD    164
      READ (SIMBUF,1300) TDO,TD1,TDM,DSTEP,AMAT,AMIT                    RULTCD    165
C                                                                       RULTCD    166
      TDDAT(JTLN+13) = TDO                                              RULTCD    167
      TDDAT(JTLN+14) = TDM                                              RULTCD    168
      TDDAT(JTLN+15) = DSTEP                                            RULTCD    169
      TDDAT(JTLN+16) = AMAT                                             RULTCD    170
      TDDAT(JTLN+17) = AMIT                                             RULTCD    171
      TDDAT(JTLN+24) = TD1                                              RULTCD    172
      JTLN = JTLN+24                                                    RULTCD    173
      GOTO 100                                                          RULTCD    174
C                                                                       RULTCD    175
 110  CONTINUE                                                          RULTCD    176
      RETURN                                                            RULTCD    177
 1000 FORMAT(2I6,3X,A2,I6,1X,I1,3X,F10.5)                               RULTCD    178
 1100 FORMAT(A12,1X,A12,3X,A2,1X,A12,1X,I1,3X,F10.5)                    RULTCD    179
 1200 FORMAT(2I5)                                                       RULTCD    180
 1300 FORMAT(6F10.5)                                                    RULTCD    181
 1400 FORMAT(' *** ERROR ULTC',I6,' TO',I6,' EXCEEDS MAXIMUM NUBER OF'  RULTCD    182
     *,I6)                                                              RULTCD    183
 1500 FORMAT(' *** ERROR ULTC PRIMARY BUS',I6,' NOT IN LOAD FLOW')      RULTCD    184
 1600 FORMAT(' *** ERROR ULTC SECONDARY BUS',I6,' NOT IN LOAD FLOW')    RULTCD    185
 1700 FORMAT(' *** ERROR ULTC REFERENCE BUS',I6,' NOT IN LOAD FLOW')    RULTCD    186
 1800 FORMAT(' *** ERROR ULTC PRIMARY BUS ',A12,' NOT IN LOAD FLOW')    RULTCD    187
 1900 FORMAT(' *** ERROR ULTC SECONDARY BUS ',A12,' NOT IN LOAD FLOW')  RULTCD    188
 2000 FORMAT(' *** ERROR ULTC REFERENCE BUS ',A12,' NOT IN LOAD FLOW')  RULTCD    189
 2100 FORMAT(' *** ERROR BUS NUMBER OF THE ABOVE ULTC EXCEEDED',I6)     RULTCD    190
      END                                                               RULTCD    191
