CFPRIME ULTCIN                                                          ULTCIN      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 ULTCIN                                                 ULTCIN      3
CD                                                                      ULTCIN      4
CD    THE FUNCTION OF THIS ROUTINE IS TO SET UP THE INITIAL POSITIONS   ULTCIN      5
CD    OF ULTC TRANSFORMERS.                                             ULTCIN      6
CD                                                                      ULTCIN      7
      INCLUDE 'PARX.INS'                                                ULTCIN      8
      INCLUDE 'CNFLAG.INS'                                              ULTCIN      9
      INCLUDE 'CNPT.INS'                                                ULTCIN     10
      INCLUDE 'CNB4.INS'                                                ULTCIN     11
      INCLUDE 'CNPARX.INS'                                              ULTCIN     12
      INCLUDE 'CNNNEW.INS'                                              ULTCIN     13
      INCLUDE 'CNLFDA.INS'                                              ULTCIN     14
      INCLUDE 'CNULTC.INS'                                              ULTCIN     15
      INCLUDE 'CNVOLT.INS'                                              ULTCIN     16
      INCLUDE 'CNMDAT.INS'                                              ULTCIN     17
C      INCLUDE 'CNISOC.INS/LIST'                                        ULTCIN     18
      INCLUDE 'CNUNIT.INS'                                              ULTCIN     19
      INCLUDE 'CNSTN.INS'                                               ULTCIN     20
      INCLUDE 'CNMSG.INS'                                               ULTCIN     21
C                                                                       ULTCIN     22
      CHARACTER*4 ICKT                                                  ULTCIN     23
      INTEGER*4 JCKID                                                   ULTCIN     24
      EQUIVALENCE (JCKID,ICKT)                                          ULTCIN     25
C                                                                       ULTCIN     26
C      CHARACTER*2 ICOM2,JCOM2                                          ULTCIN     27
C      INTEGER*2 IFRTO(2)                                               ULTCIN     28
C      INTEGER*4 ITFK                                                   ULTCIN     29
C      CHARACTER*80 ISWUTC                                              ULTCIN     30
C      CHARACTER*3 IEND                                                 ULTCIN     31
C      DATA IEND/'ESC'/                                                 ULTCIN     32
C                                                                       ULTCIN     33
      LDEB=.FALSE.                                                      ULTCIN     34
C                                                                       ULTCIN     35
      IF (NULTC .LE. 0) RETURN                                          ULTCIN     36
C                                                                       ULTCIN     37
C      CALL PHEAD(0)                                                    ULTCIN     38
C      WRITE(IU6,1000)                                                  ULTCIN     39
C                                                                       ULTCIN     40
      IF(NBFT.EQ.0)THEN                                                 ULTCIN     41
        IBOUND = IPNODX                                                 ULTCIN     42
      ELSE                                                              ULTCIN     43
        IBOUND = ICNODX                                                 ULTCIN     44
      ENDIF                                                             ULTCIN     45
C                                                                       ULTCIN     46
      NULTC9=NULTC*9                                                    ULTCIN     47
      CALL MOVE(0,NULTCO,NULTCO,NULTC9)                                 ULTCIN     48
C                                                                       ULTCIN     49
      DO 100 ITC = 1,NULTC                                              ULTCIN     50
C                                                                       ULTCIN     51
        IF(MOULTC(ITC).NE.1)GOTO 100                                    ULTCIN     52
C                                                                       ULTCIN     53
        ITC4 = ITC*4                                                    ULTCIN     54
        JTC = JULTCD(ITC)                                               ULTCIN     55
        NLFP = IDDAT(JTC+1)                                             ULTCIN     56
        NLFS = IDDAT(JTC+2)                                             ULTCIN     57
C                                                                       ULTCIN     58
        NLFPN = NNEW(NLFP)                                              ULTCIN     59
        NLFSN = NNEW(NLFS)                                              ULTCIN     60
C                                                                       ULTCIN     61
        JCKID = IDDAT(JTC+3)                                            ULTCIN     62
        NLFR = IDDAT(JTC+4)                                             ULTCIN     63
        ITYPE = IDDAT(JTC+5)                                            ULTCIN     64
        ICHOI = IDDAT(JTC+6)                                            ULTCIN     65
        NLFR = IABS(NLFR)                                               ULTCIN     66
        NLFRN = NNEW(NLFR)                                              ULTCIN     67
CD                                                                      ULTCIN     68
CD    STEP 1. ULTC IN OR OUT SERVICE STATUS INITIALIZATION              ULTCIN     69
CD                                                                      ULTCIN     70
        IF (NLFRN .LT. IBOUND) THEN                                     ULTCIN     71
          MOULTC(ITC) = 0                                               ULTCIN     72
          IIP3 = NLFPN*3                                                ULTCIN     73
          IIS3 = NLFSN*3                                                ULTCIN     74
          IIR3 = NLFRN*3                                                ULTCIN     75
          WRITE(MSG(1),1320) NLFR,INAME(IIR3-2),INAME(IIR3-1),          ULTCIN     76
     1                       INAME(IIR3)                                ULTCIN     77
          WRITE(MSG(2),1330) ITC,NLFP,INAME(IIP3-2),INAME(IIP3-1),      ULTCIN     78
     1                       INAME(IIP3)                                ULTCIN     79
          WRITE(MSG(3),1340) NLFS,INAME(IIS3-2),                        ULTCIN     80
     2                       INAME(IIS3-1),INAME(IIS3),ICKT             ULTCIN     81
          CALL PRTMSG(3)                                                ULTCIN     82
          GOTO 100                                                      ULTCIN     83
        END IF                                                          ULTCIN     84
C                                                                       ULTCIN     85
        RC = DDAT(JTC+7)                                                ULTCIN     86
        XC = DDAT(JTC+8)                                                ULTCIN     87
        DB = DDAT(JTC+9)                                                ULTCIN     88
C                                                                       ULTCIN     89
C       FOR BPA LOAD FLOW CASE, DB IN THE LOAD FLOW DATA IS NOT READ IN.ULTCIN     90
C       IF DB IS ZERO, SET DB = 1.67%/2 (2 VOLTS ON 120 VOLT BASE)      ULTCIN     91
C                                                                       ULTCIN     92
        IF (ABS(DB).LE.0.) DDAT(JTC+9) = 0.00835                        ULTCIN     93
C                                                                       ULTCIN     94
        EPSLO = DDAT(JTC+10)                                            ULTCIN     95
        AKP = DDAT(JTC+11)                                              ULTCIN     96
        AKC = DDAT(JTC+12)                                              ULTCIN     97
        TDO = DDAT(JTC+13)                                              ULTCIN     98
        TD1 = DDAT(JTC+24)                                              ULTCIN     99
        TDM = DDAT(JTC+14)                                              ULTCIN    100
        DSTEP = DDAT(JTC+15)                                            ULTCIN    101
        AMAT = DDAT(JTC+16)                                             ULTCIN    102
        AMIT = DDAT(JTC+17)                                             ULTCIN    103
        VREF = DDAT(JTC+23)                                             ULTCIN    104
        IF (ABS(VREF) .LT. 0.00001) THEN                                ULTCIN    105
          VRM = CABS(VOLT(NLFRN))                                       ULTCIN    106
        ELSE                                                            ULTCIN    107
          VRM = VREF                                                    ULTCIN    108
        END IF                                                          ULTCIN    109
CD                                                                      ULTCIN    110
CD    STEP 2. INITIALIZE REFERENCE VOLTAGE                              ULTCIN    111
CD                                                                      ULTCIN    112
        DDAT(JTC+23) = VRM                                              ULTCIN    113
CD                                                                      ULTCIN    114
CD    STEP 3. SET UP TIME DELAY FOR THE FIRST TAP CHANGE OPERATION      ULTCIN    115
CD                                                                      ULTCIN    116
        RELATC(ITC) = TDO                                               ULTCIN    117
CD                                                                      ULTCIN    118
CD    STEP 4. INITIALIZE ULTC STATES                                    ULTCIN    119
CD                                                                      ULTCIN    120
        ONRSTA(ITC4-3) = DDAT(JTC+22)                                   ULTCIN    121
        DVRTAP(ITC4-2) = 0.                                             ULTCIN    122
        COUNTD(ITC4-1) = 0.                                             ULTCIN    123
        COUNTM(ITC4) = 0.                                               ULTCIN    124
C                                                                       ULTCIN    125
        IDDAT(JTC+1)=NLFPN                                              ULTCIN    126
        IDDAT(JTC+2)=NLFSN                                              ULTCIN    127
        IF(NLFR.GT.0) THEN                                              ULTCIN    128
          IDDAT(JTC+4)=NLFRN                                            ULTCIN    129
        ELSE                                                            ULTCIN    130
          IDDAT(JTC+4)=-NLFRN                                           ULTCIN    131
        ENDIF                                                           ULTCIN    132
CD                                                                      ULTCIN    133
CD    STEP 5. INITIALIZE ULTC OPERATION RECORD ARRAYS                   ULTCIN    134
CD                                                                      ULTCIN    135
        ITC9=(ITC-1)*9                                                  ULTCIN    136
        ULTCOP(ITC9+1)=DDAT(JTC+22)                                     ULTCIN    137
        ULTCOP(ITC9+2)=CABS(VOLT(NLFRN))                                ULTCIN    138
 100  CONTINUE                                                          ULTCIN    139
C                                                                       ULTCIN    140
      RETURN                                                            ULTCIN    141
C                                                                       ULTCIN    142
 1000 FORMAT (///49X,'ULTC DATA AND INITIAL CONDITIONS'                 ULTCIN    143
     +/49X,32('='))                                                     ULTCIN    144
 1100 FORMAT (//1X,'ULTC # ',I4,' ,  FROM BUS ',I5,2X,'TO BUS ',        ULTCIN    145
     1I5,2X,'ID ',A2/1X,49('-'))                                        ULTCIN    146
 1150 FORMAT (//1X,'ULTC # ',I4,' ,  FROM BUS # ',I5,2X,3A4,2X,         ULTCIN    147
     1'TO BUS # ',I5,2X,3A4,2X,'ID ',A2/1X,49('-'))                     ULTCIN    148
 1250 FORMAT (1X,'NLFR =  # ',I5,2X,3A4,2X,'ITYPE =     ',I3,2X,        ULTCIN    149
     &'ICHOI =',5X,I3/1X,'RC   =',F8.3,2X,'XC    =',F8.3,2X,'DB    =',  ULTCIN    150
     &F8.3,2X,'EPSLO =',F8.3,2X,'KP    =',F8.3                          ULTCIN    151
     &/1X,'KC   =',F8.3,2X,'TD0   =',F8.3,2X,'TD1   =',F8.3,2X,         ULTCIN    152
     &'TDM   =',F8.3,2X,                                                ULTCIN    153
     &'DSTEP =',F8.3,2X,'AMAX =',F8.3                                   ULTCIN    154
     &/1X,'AMIN =',F8.3,2X,'VREF  =',F8.3)                              ULTCIN    155
 1300 FORMAT (/1X,'INITIAL ULTC CONDITIONS:',/1X,24('-')                ULTCIN    156
     &/1X,'ONR  =',F8.3,2X,'VOLT  =',F8.3)                              ULTCIN    157
 1310 FORMAT(5X,'BUS # ',I5,' IS A GENERATOR BUS',' ULTC # ',I4,' IS    ULTCIN    158
     1SET INTO INACTIVE MODE')                                          ULTCIN    159
 1320 FORMAT(' *** WARNING BUS:',I5,' STATION:',3A4                     ULTCIN    160
     *,' IS A GENERATOR BUS')                                           ULTCIN    161
 1330 FORMAT(5X,'ULTC#',I5,', FROM BUS#',I5,2X,3A4)                     ULTCIN    162
 1340 FORMAT(5X,'TO BUS#',I5,2X,3A4,2X,'ID ',A2,' IS DISABLED')         ULTCIN    163
       END                                                              ULTCIN    164
