CFPRIME ULTCMO                                                          ULTCMO      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 ULTCMO(NDELAY,HSTEP,IDTS,TSOUTC)                       ULTCMO      3
CD                                                                      ULTCMO      4
CD    THE FUNCTION OF THIS ROUTINE IS TO DETERMINE, AT EACH TIME STEP   ULTCMO      5
CD    OR EVERY FEW TIME STEPS, WHETHER AND HOW EACH ULTC SHOULD OPERATE.ULTCMO      6
CD    THE INFORMATION REGARDING EACH ULTC OPERATION IS WRITTEN TO THE   ULTCMO      7
CD    FILE "ISWFA". THIS INFORMATION WILL BE READ BACK LATER TO MODIFY  ULTCMO      8
CD    NETWORK Y MATRIX AS A RESULT OF THE ULTC OPERATION.               ULTCMO      9
CD                                                                      ULTCMO     10
CD    THE ENTRY POINT, PRULTC, IS TO PRINT OUT AT THE END OF THE        ULTCMO     11
CD    SIMULATION THE SUMMARY OF ULTC OPERATION.                         ULTCMO     12
CD                                                                      ULTCMO     13
      INCLUDE 'PARX.INS'                                                ULTCMO     14
      INCLUDE 'CNFLAG.INS'                                              ULTCMO     15
      INCLUDE 'CNPARX.INS'                                              ULTCMO     16
      INCLUDE 'CNNNEW.INS'                                              ULTCMO     17
      INCLUDE 'CNMDAT.INS'                                              ULTCMO     18
      INCLUDE 'CNULTC.INS'                                              ULTCMO     19
      INCLUDE 'CNVOLT.INS'                                              ULTCMO     20
      INCLUDE 'CNB4.INS'                                                ULTCMO     21
      INCLUDE 'CNMASK.INS'                                              ULTCMO     22
      INCLUDE 'CNUNIT.INS'                                              ULTCMO     23
      INCLUDE 'CNAUTO.INS'                                              ULTCMO     24
      INCLUDE 'CNSTN.INS'                                               ULTCMO     25
      INCLUDE 'CNIPTR.INS'                                              ULTCMO     26
C                                                                       ULTCMO     27
      COMPLEX VREGTC,XIREG,YREGTC                                       ULTCMO     28
C                                                                       ULTCMO     29
      CHARACTER*2 IBLNK2,ICKT,ISCKT                                     ULTCMO     30
      CHARACTER*4 ITYPUC                                                ULTCMO     31
      INTEGER JCKID                                                     ULTCMO     32
C                                                                       ULTCMO     33
      DATA ITYPUC/'MTRU'/,IBLNK2/'  '/                                  ULTCMO     34
C                                                                       ULTCMO     35
      LDEB=.FALSE.                                                      ULTCMO     36
C                                                                       ULTCMO     37
      IF(ABS(TS-TL).LE.0.01) RETURN                                     ULTCMO     38
      IDTSO = IDTS                                                      ULTCMO     39
      HSTEP1 = TS-TSOUTC                                                ULTCMO     40
C                                                                       ULTCMO     41
      NAWRUC = 0                                                        ULTCMO     42
      ISCKT = IBLNK2                                                    ULTCMO     43
      VPHS = 0.                                                         ULTCMO     44
      VPHS1 = 0.                                                        ULTCMO     45
      TRCLSE = 0.                                                       ULTCMO     46
      KLHEAD = 0                                                        ULTCMO     47
C                                                                       ULTCMO     48
      DO 200 ITC = 1,NULTC                                              ULTCMO     49
C                                                                       ULTCMO     50
      IF (MOULTC(ITC) .NE. 1) GOTO 200                                  ULTCMO     51
C                                                                       ULTCMO     52
      TDMOT=-100.                                                       ULTCMO     53
CD                                                                      ULTCMO     54
CD    STEP 1. SET ULTC DATA POINTERS                                    ULTCMO     55
CD                                                                      ULTCMO     56
      ITC4 = 4*ITC                                                      ULTCMO     57
      JTC = JULTCD(ITC)                                                 ULTCMO     58
CD                                                                      ULTCMO     59
CD    STEP 2. PICK UP ULTC DYNAMIC DATA                                 ULTCMO     60
CD                                                                      ULTCMO     61
      RC = DDAT(JTC+7)                                                  ULTCMO     62
      XC = DDAT(JTC+8)                                                  ULTCMO     63
      DB = DDAT(JTC+9)                                                  ULTCMO     64
      EPSLO = DDAT(JTC+10)                                              ULTCMO     65
      AKP = DDAT(JTC+11)                                                ULTCMO     66
      AKC = DDAT(JTC+12)                                                ULTCMO     67
      TDREL = RELATC(ITC)                                               ULTCMO     68
      IF (TDREL .LE. 0.) TDREL = 0.0001                                 ULTCMO     69
      TDM = DDAT(JTC+14)                                                ULTCMO     70
      DSTEP = DDAT(JTC+15)                                              ULTCMO     71
      AMAT = DDAT(JTC+16)                                               ULTCMO     72
      AMIT = DDAT(JTC+17)                                               ULTCMO     73
CD                                                                      ULTCMO     74
CD    STEP 3. CALCULATE MAGNITUDE OF THE VOLTAGE WHICH IS TO BE REGULATEULTCMO     75
CD                                                                      ULTCMO     76
      NLFPN = IDDAT(JTC+1)                                              ULTCMO     77
      NLFSN = IDDAT(JTC+2)                                              ULTCMO     78
      JCKID = IDDAT(JTC+3)                                              ULTCMO     79
      CALL UNPACK(ICKT,III,JCKID)                                       ULTCMO     80
      NLFRN = IDDAT(JTC+4)                                              ULTCMO     81
      NLFRN1=NLFRN                                                      ULTCMO     82
      IF(NLFRN.LT.0) NLFRN1=-NLFRN                                      ULTCMO     83
C                                                                       ULTCMO     84
      MSKKP = MSK(NLFPN)                                                ULTCMO     85
      MSKKS = MSK(NLFSN)                                                ULTCMO     86
      ATCA = ONRSTA(ITC4-3)                                             ULTCMO     87
      XREAL = DDAT(JTC+20)                                              ULTCMO     88
      XIMAG = DDAT(JTC+21)                                              ULTCMO     89
      YREGTC = CMPLX(XREAL,-XIMAG)                                      ULTCMO     90
      XIREG = (VOLT(MSKKP)/ATCA-VOLT(MSKKS))*YREGTC                     ULTCMO     91
      VREGTC = VOLT(NLFRN1)+XIREG*CMPLX(RC,XC)                          ULTCMO     92
C                                                                       ULTCMO     93
      VAM = ABS(VREGTC)                                                 ULTCMO     94
      VRM = DDAT(JTC+23)                                                ULTCMO     95
C                                                                       ULTCMO     96
C     ONCE MOTOR DRIVE TIMER INITIATED, NO RESETTING. GO                ULTCMO     97
C     AHEAD AND IMPLEMENT THE TAP CHANGING OPERATION                    ULTCMO     98
C                                                                       ULTCMO     99
      IF (ABS(COUNTM(ITC4)) .GE. 50.) GOTO 135                          ULTCMO    100
C                                                                       ULTCMO    101
CD                                                                      ULTCMO    102
CD    STEP 4. CALCULATE AND CHECK VOLTAGE ERROR SIGNAL                  ULTCMO    103
CD                                                                      ULTCMO    104
      IF (NLFRN1 .EQ. NLFSN) THEN                                       ULTCMO    105
        DVR = VRM-VAM                                                   ULTCMO    106
        GOTO 110                                                        ULTCMO    107
      END IF                                                            ULTCMO    108
      IF (NLFRN1 .EQ. NLFPN) THEN                                       ULTCMO    109
        DVR = VAM-VRM                                                   ULTCMO    110
        GOTO 110                                                        ULTCMO    111
      END IF                                                            ULTCMO    112
      IF (NLFRN .GT. 0) THEN                                            ULTCMO    113
        DVR = VRM-VAM                                                   ULTCMO    114
        GOTO 110                                                        ULTCMO    115
      END IF                                                            ULTCMO    116
      IF (NLFRN .LT. 0) THEN                                            ULTCMO    117
        DVR = VAM-VRM                                                   ULTCMO    118
      END IF                                                            ULTCMO    119
C                                                                       ULTCMO    120
 110  CONTINUE                                                          ULTCMO    121
      DDVR = DVR-DVRTAP(ITC4-2)                                         ULTCMO    122
      DVRM = ABS(DVR)                                                   ULTCMO    123
      ONRS = ONRSTA(ITC4-3)                                             ULTCMO    124
CD                                                                      ULTCMO    125
CD    STEP 5. DETERMINE OUTPUT OF THE MEASURING ELEMENT (e)             ULTCMO    126
CD                                                                      ULTCMO    127
CD    NOTE:                                                             ULTCMO    128
CD                                                                      ULTCMO    129
CD     (1) DVRM <= DB, WITHIN DEAD BAND, e=0                            ULTCMO    130
CD                                                                      ULTCMO    131
      IF (DVRM.LE.DB) THEN                                              ULTCMO    132
         EOUT = 0.                                                      ULTCMO    133
         GOTO 120                                                       ULTCMO    134
      END IF                                                            ULTCMO    135
CD                                                                      ULTCMO    136
CD     (2) DB < DVR <= DB+EPSLO & DVR INCREASES , WITHIN RIGHT          ULTCMO    137
CD         HYSTERISIS BAND , e=0                                        ULTCMO    138
CD                                                                      ULTCMO    139
      IF (DVR.GT.DB .AND. DVR.LE.DB+EPSLO .AND. DDVR.GE.0.) THEN        ULTCMO    140
         EOUT = 0.                                                      ULTCMO    141
         GOTO 120                                                       ULTCMO    142
      END IF                                                            ULTCMO    143
CD                                                                      ULTCMO    144
CD     (3) -DB-EPSLO <= DVR < -DB & DVR DECREASES , WITHIN LEFT         ULTCMO    145
CD          HYSTERISIS BAND ,e=0                                        ULTCMO    146
CD                                                                      ULTCMO    147
      IF (DVR.GE.-DB-EPSLO .AND. DVR.LT.-DB .AND. DDVR.LE.0.) THEN      ULTCMO    148
         EOUT = 0.                                                      ULTCMO    149
         GOTO 120                                                       ULTCMO    150
      END IF                                                            ULTCMO    151
CD                                                                      ULTCMO    152
CD     (4) DB < DVR <= DB+EPSLO & DVR DECREASES , NOT WITHIN RIGHT      ULTCMO    153
CD         HYSTERISIS BAND , e=1                                        ULTCMO    154
CD                                                                      ULTCMO    155
      IF (DVR.GT.DB .AND. DVR.LE.DB+EPSLO .AND. DDVR.LT.0.) THEN        ULTCMO    156
         EOUT = 1.1                                                     ULTCMO    157
         GOTO 120                                                       ULTCMO    158
      END IF                                                            ULTCMO    159
CD                                                                      ULTCMO    160
CD     (5) -DB-EPSLO <= DVR < -DB & DVR INCREASES , NOT WITHIN LEFT     ULTCMO    161
CD         HYSTERISIS BAND , e=-1                                       ULTCMO    162
CD                                                                      ULTCMO    163
      IF (DVR.GE.-DB-EPSLO .AND. DVR.LT.-DB .AND. DDVR.GT.0.) THEN      ULTCMO    164
         EOUT = -1.1                                                    ULTCMO    165
         GOTO 120                                                       ULTCMO    166
      END IF                                                            ULTCMO    167
CD                                                                      ULTCMO    168
CD     (6) DVR > DB+EPSLO , OUTSIDE RIGHT HYSTERISIS BAND , e=1         ULTCMO    169
CD                                                                      ULTCMO    170
      IF (DVR.GT.DB+EPSLO) THEN                                         ULTCMO    171
         EOUT = 1.1                                                     ULTCMO    172
         GOTO 120                                                       ULTCMO    173
      END IF                                                            ULTCMO    174
CD                                                                      ULTCMO    175
CD     (7) DVR < -DB-EPSLO , OUTSIDE LEFT HYSTERISIS BAND , e=-1        ULTCMO    176
CD                                                                      ULTCMO    177
      IF (DVR.LT.-DB-EPSLO) THEN                                        ULTCMO    178
         EOUT = -1.1                                                    ULTCMO    179
         GOTO 120                                                       ULTCMO    180
      END IF                                                            ULTCMO    181
C                                                                       ULTCMO    182
 120  CONTINUE                                                          ULTCMO    183
CD                                                                      ULTCMO    184
CD    STEP 6. DETERMINE WHETHER TO RESET OR ADVANCE RELAY TIMER         ULTCMO    185
CD                                                                      ULTCMO    186
CD                                                                      ULTCMO    187
CD     (1)  WITHIN DEAD-BAND, FULL RESET                                ULTCMO    188
CD                                                                      ULTCMO    189
       IF (ABS(EOUT) .LT. 0.00001) THEN                                 ULTCMO    190
         COUNTD(ITC4-1) = 0.                                            ULTCMO    191
         GOTO 130                                                       ULTCMO    192
       END IF                                                           ULTCMO    193
CD                                                                      ULTCMO    194
CD     (2) STAY ON THE HIGHER SIDE OF THE DEAD-BAND, ADVANCE ONE        ULTCMO    195
CD         POSITIVE STEP                                                ULTCMO    196
CD                                                                      ULTCMO    197
       DVRPRV = DVRTAP(ITC4-2)*DVR                                      ULTCMO    198
                                                                        ULTCMO    199
C                                                                       ULTCMO    200
       IF (EOUT .GT. 1. .AND. DVRPRV .GT. 0.) THEN                      ULTCMO    201
         COUNTD (ITC4-1) = COUNTD(ITC4-1)+HSTEP1                        ULTCMO    202
         GOTO 130                                                       ULTCMO    203
       END IF                                                           ULTCMO    204
CD                                                                      ULTCMO    205
CD     (3) OSCILLATES BETWEEN THE TWO SIDES OF THE DEAD-BAND, RESET     ULTCMO    206
CD                                                                      ULTCMO    207
       IF (EOUT .GT. 1. .AND. DVRPRV .LT. 0.) THEN                      ULTCMO    208
          COUNTD (ITC4-1) = 0.                                          ULTCMO    209
          GOTO 130                                                      ULTCMO    210
       END IF                                                           ULTCMO    211
       IF (EOUT .LT. -1. .AND. DVRPRV .LT. 0.) THEN                     ULTCMO    212
          COUNTD (ITC4-1) = 0.                                          ULTCMO    213
          GOTO 130                                                      ULTCMO    214
       END IF                                                           ULTCMO    215
CD                                                                      ULTCMO    216
CD     (4) STAY ON THE LOWER SIDE OF THE DEAD-BAND, ADVANCE ONE         ULTCMO    217
CD         NEGATIVE STEP                                                ULTCMO    218
C                                                                       ULTCMO    219
       IF (EOUT .LT. -1. .AND. DVRPRV .GT. 0.) THEN                     ULTCMO    220
         COUNTD (ITC4-1) = COUNTD(ITC4-1)-HSTEP1                        ULTCMO    221
         GOTO 130                                                       ULTCMO    222
       END IF                                                           ULTCMO    223
C                                                                       ULTCMO    224
 130  CONTINUE                                                          ULTCMO    225
CD                                                                      ULTCMO    226
CD    STEP 7. SET COUNTING OF THE MOTOR DRIVE UNIT AND TAP CHANGER      ULTCMO    227
CD            MECHANISM                                                 ULTCMO    228
CD                                                                      ULTCMO    229
      IF (COUNTD(ITC4-1) .GE. TDREL) THEN                               ULTCMO    230
        COUNTM(ITC4) = 100.                                             ULTCMO    231
        COUNTD(ITC4-1) = 0.                                             ULTCMO    232
        GOTO 140                                                        ULTCMO    233
      END IF                                                            ULTCMO    234
C                                                                       ULTCMO    235
      IF (COUNTD(ITC4-1) .LE. -TDREL) THEN                              ULTCMO    236
        COUNTM(ITC4) = -100.                                            ULTCMO    237
        COUNTD(ITC4-1) = 0.                                             ULTCMO    238
        GOTO 140                                                        ULTCMO    239
      END IF                                                            ULTCMO    240
C                                                                       ULTCMO    241
 135  CONTINUE                                                          ULTCMO    242
C                                                                       ULTCMO    243
      IF (COUNTM(ITC4) .GE. 100.) THEN                                  ULTCMO    244
        COUNTM(ITC4) = COUNTM(ITC4) + HSTEP1                            ULTCMO    245
        COUNTD(ITC4-1) = 0.                                             ULTCMO    246
        GOTO 140                                                        ULTCMO    247
      END IF                                                            ULTCMO    248
C                                                                       ULTCMO    249
      IF (COUNTM(ITC4) .LE. -100.) THEN                                 ULTCMO    250
        COUNTM(ITC4) = COUNTM(ITC4) - HSTEP1                            ULTCMO    251
        COUNTD(ITC4-1) = 0.                                             ULTCMO    252
        GOTO 140                                                        ULTCMO    253
      END IF                                                            ULTCMO    254
 140  CONTINUE                                                          ULTCMO    255
CD                                                                      ULTCMO    256
CD    STEP 8. DETERMINE WHETHER AND HOW TO MOVE THE TAP                 ULTCMO    257
CD                                                                      ULTCMO    258
         IF (COUNTM(ITC4) .GE. 100.) THEN                               ULTCMO    259
            TDMOT = COUNTM(ITC4)-100.                                   ULTCMO    260
         END IF                                                         ULTCMO    261
         IF (COUNTM(ITC4) .LE. -100.) THEN                              ULTCMO    262
            TDMOT = -COUNTM(ITC4)-100.                                  ULTCMO    263
         END IF                                                         ULTCMO    264
C                                                                       ULTCMO    265
C         CHANGE TAP POSITION (UP)                                      ULTCMO    266
C                                                                       ULTCMO    267
         IF (TDMOT .GE. TDM) THEN                                       ULTCMO    268
           IF (COUNTM(ITC4) .GE. 100.) THEN                             ULTCMO    269
             ONROLD = ONRSTA(ITC4-3)                                    ULTCMO    270
             ONRSTA(ITC4-3) = ONRSTA(ITC4-3) - DSTEP                    ULTCMO    271
             IF(ONRSTA(ITC4-3) .GT. AMAT) ONRSTA(ITC4-3) = AMAT         ULTCMO    272
             IF(ONRSTA(ITC4-3) .LT. AMIT) ONRSTA(ITC4-3) = AMIT         ULTCMO    273
             ONRNEW = ONRSTA(ITC4-3)                                    ULTCMO    274
CD                                                                      ULTCMO    275
CD    STEP 9. UPDATE ULTC OPERATION RECORD ARRAYS                       ULTCMO    276
CD                                                                      ULTCMO    277
             ITC9=(ITC-1)*9                                             ULTCMO    278
             IF(ABS(ONRNEW-ONROLD).GT.0.00001) THEN                     ULTCMO    279
               IF(NULTCO(ITC9+9).LE.0) THEN                             ULTCMO    280
                 ULTCOP(ITC9+3)=TS                                      ULTCMO    281
                 ULTCOP(ITC9+4)=ONRNEW                                  ULTCMO    282
                 ULTCOP(ITC9+5)=CABS(VOLT(NLFRN1))                      ULTCMO    283
               END IF                                                   ULTCMO    284
               ULTCOP(ITC9+6)=TS                                        ULTCMO    285
               ULTCOP(ITC9+7)=ONRNEW                                    ULTCMO    286
               ULTCOP(ITC9+8)=CABS(VOLT(NLFRN1))                        ULTCMO    287
               NULTCO(ITC9+9)=NULTCO(ITC9+9)+1                          ULTCMO    288
             ENDIF                                                      ULTCMO    289
CD                                                                      ULTCMO    290
CD    STEP 10. WRITE INTO FILE ISWFA ULTC OPERATION INFORMATION         ULTCMO    291
CD                                                                      ULTCMO    292
             IF (ABS(ONRNEW-ONROLD).GT.0.00001 .AND. NREFUC.GT.0)       ULTCMO    293
     &           THEN                                                   ULTCMO    294
               IF(IASWX.EQ.0)THEN                                       ULTCMO    295
                 WRITE(ISWFA,2110) TS                                   ULTCMO    296
                 NAWR = NAWR+1                                          ULTCMO    297
                 NAWRUC = NAWRUC+1                                      ULTCMO    298
                 IASWX=1                                                ULTCMO    299
               ENDIF                                                    ULTCMO    300
               WRITE(ISWFA,2100) ITYPUC,NLFPN,NLFSN,ICKT,ISCKT,         ULTCMO    301
     &                           XREAL,XIMAG,ONRNEW,VPHS,ONROLD,        ULTCMO    302
     &                           VPHS1,TRCLSE                           ULTCMO    303
               NAWR = NAWR+1                                            ULTCMO    304
               NAWRUC = NAWRUC+1                                        ULTCMO    305
             END IF                                                     ULTCMO    306
C                                                                       ULTCMO    307
             ITCFLG = 1                                                 ULTCMO    308
             COUNTM(ITC4) = 0.                                          ULTCMO    309
             COUNTD(ITC4-1) = 0.                                        ULTCMO    310
             RELATC(ITC) = DDAT(JTC+24)                                 ULTCMO    311
             GOTO 150                                                   ULTCMO    312
           ELSE                                                         ULTCMO    313
             ONROLD = ONRSTA(ITC4-3)                                    ULTCMO    314
             ONRSTA(ITC4-3) = ONRSTA(ITC4-3) + DSTEP                    ULTCMO    315
             IF(ONRSTA(ITC4-3).GT.AMAT) ONRSTA(ITC4-3)=AMAT             ULTCMO    316
             IF(ONRSTA(ITC4-3).LT.AMIT) ONRSTA(ITC4-3)=AMIT             ULTCMO    317
             ONRNEW = ONRSTA(ITC4-3)                                    ULTCMO    318
CD                                                                      ULTCMO    319
CD    STEP 11. UPDATE ULTC OPERATION RECORD ARRAYS                      ULTCMO    320
CD                                                                      ULTCMO    321
             ITC9=(ITC-1)*9                                             ULTCMO    322
             IF(ABS(ONRNEW-ONROLD).GT.0.00001) THEN                     ULTCMO    323
               IF(NULTCO(ITC9+9).LE.0) THEN                             ULTCMO    324
                 ULTCOP(ITC9+3)=TS                                      ULTCMO    325
                 ULTCOP(ITC9+4)=ONRNEW                                  ULTCMO    326
                 ULTCOP(ITC9+5)=CABS(VOLT(NLFRN1))                      ULTCMO    327
               END IF                                                   ULTCMO    328
               ULTCOP(ITC9+6)=TS                                        ULTCMO    329
               ULTCOP(ITC9+7)=ONRNEW                                    ULTCMO    330
               ULTCOP(ITC9+8)=CABS(VOLT(NLFRN1))                        ULTCMO    331
               NULTCO(ITC9+9)=NULTCO(ITC9+9)+1                          ULTCMO    332
             ENDIF                                                      ULTCMO    333
C                                                                       ULTCMO    334
C            WRITE INTO FILE ISWFA ULTC OPERATION INFORMATION           ULTCMO    335
C                                                                       ULTCMO    336
             IF (ABS(ONRNEW-ONROLD).GT.0.00001 .AND. NREFUC.GT.0)       ULTCMO    337
     &           THEN                                                   ULTCMO    338
               IF(IASWX.EQ.0)THEN                                       ULTCMO    339
                 WRITE(ISWFA,2110) TS                                   ULTCMO    340
                 NAWR = NAWR+1                                          ULTCMO    341
                 NAWRUC = NAWRUC+1                                      ULTCMO    342
                 IASWX=1                                                ULTCMO    343
               ENDIF                                                    ULTCMO    344
               WRITE(ISWFA,2100) ITYPUC,NLFPN,NLFSN,ICKT,ISCKT,         ULTCMO    345
     &                           XREAL,XIMAG,ONRNEW,VPHS,ONROLD,        ULTCMO    346
     &                           VPHS1,TRCLSE                           ULTCMO    347
               NAWR = NAWR+1                                            ULTCMO    348
               NAWRUC = NAWRUC+1                                        ULTCMO    349
             END IF                                                     ULTCMO    350
C                                                                       ULTCMO    351
             ITCFLG = 1                                                 ULTCMO    352
             COUNTM(ITC4) = 0.                                          ULTCMO    353
             COUNTD(ITC4-1) = 0.                                        ULTCMO    354
             RELATC(ITC) = DDAT(JTC+24)                                 ULTCMO    355
             GOTO 150                                                   ULTCMO    356
           END IF                                                       ULTCMO    357
         END IF                                                         ULTCMO    358
 150  CONTINUE                                                          ULTCMO    359
      DVRTAP(ITC4-2) = DVR                                              ULTCMO    360
 200  CONTINUE                                                          ULTCMO    361
C                                                                       ULTCMO    362
      TSOUTC = TS                                                       ULTCMO    363
C                                                                       ULTCMO    364
      RETURN                                                            ULTCMO    365
C                                                                       ULTCMO    366
C                                                                       ULTCMO    367
      ENTRY PRULTC                                                      ULTCMO    368
CD                                                                      ULTCMO    369
CD    TO PRINT OUT THE ULTC OPERATION RECORD.                           ULTCMO    370
CD                                                                      ULTCMO    371
      ISCKT = IBLNK2                                                    ULTCMO    372
C                                                                       ULTCMO    373
      IPLINE=61                                                         ULTCMO    374
C                                                                       ULTCMO    375
      DO 250 ITC = 1,NULTC                                              ULTCMO    376
C                                                                       ULTCMO    377
      IF (MOULTC(ITC) .EQ. 0) GOTO 250                                  ULTCMO    378
C                                                                       ULTCMO    379
      ITC9=(ITC-1)*9                                                    ULTCMO    380
      IF(NULTCO(ITC9+9).LE.0) GOTO 250                                  ULTCMO    381
C                                                                       ULTCMO    382
      JTC = JULTCD(ITC)                                                 ULTCMO    383
C                                                                       ULTCMO    384
      NLFPN = IDDAT(JTC+1)                                              ULTCMO    385
      NLFSN = IDDAT(JTC+2)                                              ULTCMO    386
      JCKID = IDDAT(JTC+3)                                              ULTCMO    387
      NLFRN = IDDAT(JTC+4)                                              ULTCMO    388
      NLFRN1 = IABS(NLFRN)                                              ULTCMO    389
      AMAT = DDAT(JTC+16)                                               ULTCMO    390
      AMIT = DDAT(JTC+17)                                               ULTCMO    391
C                                                                       ULTCMO    392
      NLFP = NOLD(NLFPN)                                                ULTCMO    393
      NLFS = NOLD(NLFSN)                                                ULTCMO    394
      NLFR = NOLD(NLFRN1)                                               ULTCMO    395
C                                                                       ULTCMO    396
      IIP3 = NLFPN*3                                                    ULTCMO    397
      IIS3 = NLFSN*3                                                    ULTCMO    398
      IIR3 = NLFRN1*3                                                   ULTCMO    399
C                                                                       ULTCMO    400
      IF(IPLINE.GE.60)THEN                                              ULTCMO    401
         CALL PAGE6                                                     ULTCMO    402
         WRITE(IU6,2200)                                                ULTCMO    403
         WRITE(IU6,2250)                                                ULTCMO    404
         WRITE(IU6,2300)                                                ULTCMO    405
         IPLINE=18                                                      ULTCMO    406
      ENDIF                                                             ULTCMO    407
C                                                                       ULTCMO    408
      IF (ULTCOP(ITC9+7)+0.0001 .GT. AMAT) THEN                         ULTCMO    409
        WRITE(IU6,2400) NLFP,INAME(IIP3-2),INAME(IIP3-1),               ULTCMO    410
     1                  INAME(IIP3),NLFS,INAME(IIS3-2),                 ULTCMO    411
     2                  INAME(IIS3-1),INAME(IIS3),ICKT,                 ULTCMO    412
     3                  NLFR,INAME(IIR3-2),INAME(IIR3-1),               ULTCMO    413
     4                  INAME(IIR3),ULTCOP(ITC9+1),ULTCOP(ITC9+2),      ULTCMO    414
     5                  ULTCOP(ITC9+3),ULTCOP(ITC9+4),ULTCOP(ITC9+5),   ULTCMO    415
     6                  ULTCOP(ITC9+6),ULTCOP(ITC9+7),ULTCOP(ITC9+8),   ULTCMO    416
     7                  NULTCO(ITC9+9)                                  ULTCMO    417
        IPLINE=IPLINE+1                                                 ULTCMO    418
        GOTO 250                                                        ULTCMO    419
      END IF                                                            ULTCMO    420
C                                                                       ULTCMO    421
      IF (ULTCOP(ITC9+7)-0.0001 .LT. AMIT) THEN                         ULTCMO    422
        WRITE(IU6,2401) NLFP,INAME(IIP3-2),INAME(IIP3-1),               ULTCMO    423
     1                  INAME(IIP3),NLFS,INAME(IIS3-2),                 ULTCMO    424
     2                  INAME(IIS3-1),INAME(IIS3),ICKT,                 ULTCMO    425
     3                  NLFR,INAME(IIR3-2),INAME(IIR3-1),               ULTCMO    426
     4                  INAME(IIR3),ULTCOP(ITC9+1),ULTCOP(ITC9+2),      ULTCMO    427
     5                  ULTCOP(ITC9+3),ULTCOP(ITC9+4),ULTCOP(ITC9+5),   ULTCMO    428
     6                  ULTCOP(ITC9+6),ULTCOP(ITC9+7),ULTCOP(ITC9+8),   ULTCMO    429
     7                  NULTCO(ITC9+9)                                  ULTCMO    430
        IPLINE=IPLINE+1                                                 ULTCMO    431
        GOTO 250                                                        ULTCMO    432
      END IF                                                            ULTCMO    433
C                                                                       ULTCMO    434
      WRITE(IU6,2402) NLFP,INAME(IIP3-2),INAME(IIP3-1),                 ULTCMO    435
     1                INAME(IIP3),NLFS,INAME(IIS3-2),                   ULTCMO    436
     2                INAME(IIS3-1),INAME(IIS3),ICKT,                   ULTCMO    437
     3                NLFR,INAME(IIR3-2),INAME(IIR3-1),                 ULTCMO    438
     4                INAME(IIR3),ULTCOP(ITC9+1),ULTCOP(ITC9+2),        ULTCMO    439
     5                ULTCOP(ITC9+3),ULTCOP(ITC9+4),ULTCOP(ITC9+5),     ULTCMO    440
     6                ULTCOP(ITC9+6),ULTCOP(ITC9+7),ULTCOP(ITC9+8),     ULTCMO    441
     7                NULTCO(ITC9+9)                                    ULTCMO    442
      IPLINE=IPLINE+1                                                   ULTCMO    443
C                                                                       ULTCMO    444
 250  CONTINUE                                                          ULTCMO    445
C                                                                       ULTCMO    446
      RETURN                                                            ULTCMO    447
 1010 FORMAT(//3X,'TIME =',F8.4                                         ULTCMO    448
     1/3X,'-------------')                                              ULTCMO    449
 1020 FORMAT(/3X,'NLFP =',I5,3X,'NLFS =',I5,3X,'ID =',A2,3X,            ULTCMO    450
     &'NLFR =',I5)                                                      ULTCMO    451
 1030 FORMAT(3X,'VAM =',F8.3,3X,'VRM =',F8.3,3X,'DVR =',F8.3,3X,        ULTCMO    452
     &'ONRSTA =',F8.3)                                                  ULTCMO    453
 1040 FORMAT(3X,'EOUT =',F8.3,3X,'COUNTD =',F8.3)                       ULTCMO    454
 1050 FORMAT(3X,'IDTS =',I5)                                            ULTCMO    455
 1060 FORMAT(3X,I3,',',I3,' :  ',F15.6)                                 ULTCMO    456
 2100 FORMAT (A4,2I5,1X,2A2,2F10.3,4F10.5,10X,F10.4)                    ULTCMO    457
 2110 FORMAT(F10.5)                                                     ULTCMO    458
 2200 FORMAT(44X,'*** SUMMARY OF ULTC OPERATIONS ***')                  ULTCMO    459
 2250 FORMAT(/49X,'ONR0 - INITIAL TURNS RATIO'/                         ULTCMO    460
     1        49X,'V0   - INITIAL REGULATED BUS VOLTAGE'/               ULTCMO    461
     2        49X,'T1   - TIME (IN SECOND) OF FIRST TAP OPERATION'/     ULTCMO    462
     3        49X,'ONR1 - TURNS RATIO AFTER FIRST TAP OPERATION'/       ULTCMO    463
     4        49X,'V1   - REGULATED BUS VOLTAGE AT FIRST TAP            ULTCMO    464
     4OPERATION'/                                                       ULTCMO    465
     5        49X,'TL   - TIME (IN SECOND) OF LAST TAP OPERATION'/      ULTCMO    466
     6        49X,'ONRL - TURNS RATIO AFTER LAST TAP OPERATION'/        ULTCMO    467
     7        49X,'VL   - REGULATED BUS VOLTAGE AT LAST TAP             ULTCMO    468
     7OPERATION'/                                                       ULTCMO    469
     8        49X,'NOP  - TOTAL NUMBER OF TAP OPERATIONS')              ULTCMO    470
 2300 FORMAT (/10X,'FROM',17X,'TO',21X,'REGULATED'/,'  BUS #   BUS'     ULTCMO    471
     &,' NAME    BUS #   BUS NAME    CT#  BUS #   BUS NAME     ONR0'    ULTCMO    472
     *,'     V0     T1   ONR1     V1     TL   ONRL     VL  NOP'         ULTCMO    473
     *,/,'  ----- ------------  ----- ------------  ---'                ULTCMO    474
     &,'  ----- ------------',8(' ------'),'  ---')                     ULTCMO    475
 2400 FORMAT(2(I7,1X,3A4),3X,A2,I7,1X,3A4,8F7.3,I5,' *H')               ULTCMO    476
 2401 FORMAT(2(I7,1X,3A4),3X,A2,I7,1X,3A4,8F7.3,I5,' *L')               ULTCMO    477
 2402 FORMAT(2(I7,1X,3A4),3X,A2,I7,1X,3A4,8F7.3,I5)                     ULTCMO    478
      END                                                               ULTCMO    479
