CFPRIME DCCONT                                                          DCCONT      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  DCCONT                                                DCCONT      3
CD -------------------------------------------------------------------  DCCONT      4
CD                                                                      DCCONT      5
CD              *****     DCCONT  ROUTINE   *****                       DCCONT      6
CD                                                                      DCCONT      7
CD -------------------------------------------------------------------  DCCONT      8
CD                                                                      DCCONT      9
CD       PURPOSE: Control the reading of the UDC controls and           DCCONT     10
CD                initialization of the dc solution.                    DCCONT     11
CD                                                                      DCCONT     12
CD                                                                      DCCONT     13
CD       DEFINITION OF LOCAL VARIABLES:                                 DCCONT     14
CD                ERROR  -  unable to establish a solution order.       DCCONT     15
CD                I      - 'do' loop index.                             DCCONT     16
CD                XSTOP  -  unable to establist a solution order.       DCCONT     17
CD          (P)   TIMX   -  time.                                       DCCONT     18
CD                                                                      DCCONT     19
CD                                                                      DCCONT     20
CD       SUBROUTINES REQUIRED:  ACXREF, BINJCT, CONVOL, DCEFCT,         DCCONT     21
CD                              INITDC, INTINJ, SPOWER, STDCPU,         DCCONT     22
CD                              UDREAD, UDSORT, URDEFN,                 DCCONT     23
CD                              URLIST, URPRNT,                         DCCONT     24
CD                                                                      DCCONT     25
CD -------------------------------------------------------------------  DCCONT     26
      INCLUDE 'CNUNIT.INS'                                              DCCONT     27
      INCLUDE 'PARX.INS'                                                DCCONT     28
      INCLUDE 'CNPT.INS'                                                DCCONT     29
      INCLUDE 'GRDC01.INS'                                              DCCONT     30
      INCLUDE 'GRPDCS.INS'                                              DCCONT     31
      INCLUDE 'UDCA.INS'                                                DCCONT     32
      INCLUDE 'UDCB.INS'                                                DCCONT     33
      INCLUDE 'UDCE.INS'                                                DCCONT     34
      INCLUDE 'UDCF.INS'                                                DCCONT     35
      INCLUDE 'UDCG.INS'                                                DCCONT     36
      INCLUDE 'UDCH.INS'                                                DCCONT     37
      INCLUDE 'UDCJ.INS'                                                DCCONT     38
      INCLUDE 'CNNNEW.INS'                                              DCCONT     39
      INCLUDE 'CNVOLT.INS'                                              DCCONT     40
      INCLUDE 'CNSTN.INS'                                               DCCONT     41
      INCLUDE 'CNFLAG.INS'                                              DCCONT     42
      INCLUDE 'CNMSG.INS'                                               DCCONT     43
C                                                                       DCCONT     44
C                                                                       DCCONT     45
      CHARACTER*4 CNAME                                                 DCCONT     46
      CHARACTER*12 SNAME                                                DCCONT     47
      EQUIVALENCE (JNAME,CNAME)                                         DCCONT     48
C                                                                       DCCONT     49
      LOGICAL       ERROR, XSTOP                                        DCCONT     50
C                                                                       DCCONT     51
      LDEB=(JDEB(303).NE.0)                                             DCCONT     52
C                                                                       DCCONT     53
      TIME = 0.0                                                        DCCONT     54
      NCTP = 0                                                          DCCONT     55
      NDTP = 0                                                          DCCONT     56
C                                                                       DCCONT     57
C   STORE PROGRAM BUS NUMBER AND INITIALIZE VOLTAGES                    DCCONT     58
C                                                                       DCCONT     59
        DO 10 I=1,NACBUS                                                DCCONT     60
        NPROGB=NNEW(IUQABU(I))                                          DCCONT     61
        VR=REAL(VOLT(NPROGB))                                           DCCONT     62
        VI=AIMAG(VOLT(NPROGB))                                          DCCONT     63
        DCEA(I) = VR                                                    DCCONT     64
        DCEB(I) = VI                                                    DCCONT     65
        DCEAT(I) = VR                                                   DCCONT     66
        DCEBT(I) = VI                                                   DCCONT     67
        N3=NPROGB*3                                                     DCCONT     68
        JNAME=INAME(N3-2)                                               DCCONT     69
        SNAME(1:4)=CNAME                                                DCCONT     70
        JNAME=INAME(N3-1)                                               DCCONT     71
        SNAME(5:8)=CNAME                                                DCCONT     72
        JNAME=INAME(N3)                                                 DCCONT     73
        SNAME(9:12)=CNAME                                               DCCONT     74
        ACNAME(I)=SNAME                                                 DCCONT     75
        PTHVDC(I)=0.0                                                   DCCONT     76
        QTHVDC(I)=0.0                                                   DCCONT     77
 10    CONTINUE                                                         DCCONT     78
        DO 20 I=NACBUS+1,NACTOT                                         DCCONT     79
        NPROGB=NNEW(IUQABU(I))                                          DCCONT     80
        VR=REAL(VOLT(NPROGB))                                           DCCONT     81
        VI=AIMAG(VOLT(NPROGB))                                          DCCONT     82
        DCEA(I) = VR                                                    DCCONT     83
        DCEB(I) = VI                                                    DCCONT     84
        DCEAT(I) = VR                                                   DCCONT     85
        DCEBT(I) = VI                                                   DCCONT     86
        N3=NPROGB*3                                                     DCCONT     87
        JNAME=INAME(N3-2)                                               DCCONT     88
        SNAME(1:4)=CNAME                                                DCCONT     89
        JNAME=INAME(N3-1)                                               DCCONT     90
        SNAME(5:8)=CNAME                                                DCCONT     91
        JNAME=INAME(N3)                                                 DCCONT     92
        SNAME(9:12)=CNAME                                               DCCONT     93
        ACNAME(I)=SNAME                                                 DCCONT     94
 20    CONTINUE                                                         DCCONT     95
C                                                                       DCCONT     96
C     Initialize all flags to build G matrix, etc.                      DCCONT     97
C                                                                       DCCONT     98
      MODCHG =.TRUE.                                                    DCCONT     99
      ACCHNG =.TRUE.                                                    DCCONT    100
      DCCHNG =.TRUE.                                                    DCCONT    101
      FILLED =.FALSE.                                                   DCCONT    102
      SORTED =.FALSE.                                                   DCCONT    103
      NEGCUR =.FALSE.                                                   DCCONT    104
      COMFAL =.FALSE.                                                   DCCONT    105
      SOLN =.FALSE.                                                     DCCONT    106
C                                                                       DCCONT    107
C     First set up the required dc initializations                      DCCONT    108
C                                                                       DCCONT    109
      IF(HIST)THEN                                                      DCCONT    110
C                                                                       DCCONT    111
C        First convert dc pu data to kv, kA and MW                      DCCONT    112
C                                                                       DCCONT    113
         CALL INITDC                                                    DCCONT    114
C                                                                       DCCONT    115
C        Set up per unitizing factors                                   DCCONT    116
C                                                                       DCCONT    117
         CALL STDCPU                                                    DCCONT    118
C                                                                       DCCONT    119
C        Set up ac voltage pointers and transfer voltages into dc       DCCONT    120
C        arrays.                                                        DCCONT    121
C                                                                       DCCONT    122
         CALL ACXREF                                                    DCCONT    123
         DO 30 I=1,NACTOT                                               DCCONT    124
         IUQABU(I)=NNEW(IUQABU(I))                                      DCCONT    125
   30    CONTINUE                                                       DCCONT    126
C                                                                       DCCONT    127
         CALL CONVOL                                                    DCCONT    128
C                                                                       DCCONT    129
C        Set up current injection history terms                         DCCONT    130
C                                                                       DCCONT    131
         CALL INTINJ                                                    DCCONT    132
C                                                                       DCCONT    133
C        Set up ac current injections                                   DCCONT    134
C                                                                       DCCONT    135
         INIT = 0                                                       DCCONT    136
         CALL SPOWER(INIT)                                              DCCONT    137
C                                                                       DCCONT    138
         CALL BINJCT                                                    DCCONT    139
         NDSTEP = 1                                                     DCCONT    140
         CALL DCEFCT                                                    DCCONT    141
C                                                                       DCCONT    142
      ENDIF                                                             DCCONT    143
C                                                                       DCCONT    144
      IF(IUDC.GT.0) THEN                                                DCCONT    145
         UDEXST = .TRUE.                                                DCCONT    146
      ELSE                                                              DCCONT    147
         UDEXST = .FALSE.                                               DCCONT    148
      ENDIF                                                             DCCONT    149
C                                                                       DCCONT    150
      CALL URDEFN                                                       DCCONT    151
      WRITE(MSG(1),9100)                                                DCCONT    152
      WRITE(MSG(2),9110) IUDC                                           DCCONT    153
      WRITE(MSG(3),9120) NUDC                                           DCCONT    154
      WRITE(MSG(4),9130) IERCNT                                         DCCONT    155
      CALL PRTMSG(4)                                                    DCCONT    156
      IF(IERCNT.GT.0)THEN                                               DCCONT    157
      MSG(1)='TERMINATED DUE TO UDC INPUT ERRORS'                       DCCONT    158
      CALL ASTOP(MSG(1),34)                                             DCCONT    159
      ENDIF                                                             DCCONT    160
C                                                                       DCCONT    161
C                                                                       DCCONT    162
      IERCNT = 0                                                        DCCONT    163
      CALL UDSORT (ERROR, XSTOP)                                        DCCONT    164
      IF(XSTOP.OR.ERROR)THEN                                            DCCONT    165
         I=1                                                            DCCONT    166
         IF(ERROR)THEN                                                  DCCONT    167
            WRITE(MSG(2),9210)                                          DCCONT    168
            WRITE(MSG(3),9220)                                          DCCONT    169
            I=3                                                         DCCONT    170
         ENDIF                                                          DCCONT    171
         WRITE(MSG(1),9200)                                             DCCONT    172
         CALL PRTMSG(I)                                                 DCCONT    173
         MSG(1)='TERMINATED DUE TO POOR SYSTEM'                         DCCONT    174
         CALL ASTOP(MSG(1),29)                                          DCCONT    175
      ENDIF                                                             DCCONT    176
C                                                                       DCCONT    177
C                                                                       DCCONT    178
      SOLN =.TRUE.                                                      DCCONT    179
      CALL URLIST                                                       DCCONT    180
      IF(LDEB)THEN                                                      DCCONT    181
      CALL URPRNT ('***  SOLUTION ORDER FOR UDC BLOCKS  ***')           DCCONT    182
      ENDIF                                                             DCCONT    183
C                                                                       DCCONT    184
C---------------------------------------------------------------------  DCCONT    185
C                                                                       DCCONT    186
      RETURN                                                            DCCONT    187
C                                                                       DCCONT    188
C---------------------------------------------------------------------  DCCONT    189
C                                                                       DCCONT    190
 9100 FORMAT(' *** MTDC DATA AND ERROR MESSAGE:')                       DCCONT    191
 9110 FORMAT(5X,'THERE ARE ',I4,' UDC BLOCKS.')                         DCCONT    192
 9120 FORMAT(5X,'THE MAXIMUM NUMBER OF UDC BLOCKS IS ',I4)              DCCONT    193
 9130 FORMAT(5X                                                         DCCONT    194
     *,'THERE WERE ',I2,' USER DEFINED CONTROL (UDC) INPUT ERRORS.')    DCCONT    195
 9200 FORMAT(' *** MTDC ERROR:'                                         DCCONT    196
     *,' THIS A POOR SYSTEM, CHECK YOUR UDC INPUT FILE.')               DCCONT    197
 9210 FORMAT(14X                                                        DCCONT    198
     *,'TO SOLVE THE PROBLEM OF NOT FINDING A SUBSYSTEM, MOVE THE')     DCCONT    199
 9220 FORMAT(5X                                                         DCCONT    200
     *,'SUBSYSTEM BLOCK, NEAR THE TOP OF THE INPUT FILE.')              DCCONT    201
C                                                                       DCCONT    202
C---------------------------------------------------------------------  DCCONT    203
C                                                                       DCCONT    204
      END                                                               DCCONT    205
