CFPRIME GVHIST                                                          GVHIST      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  GVHIST                                                GVHIST      3
CD -------------------------------------------------------------------  GVHIST      4
CD                                                                      GVHIST      5
CD              *****     GVHIST  ROUTINE   *****                       GVHIST      6
CD                                                                      GVHIST      7
CD -------------------------------------------------------------------  GVHIST      8
CD                                                                      GVHIST      9
CD       PURPOSE:  Initializes history terms for line models.           GVHIST     10
CD                                                                      GVHIST     11
CD                                                                      GVHIST     12
CD       DEFINITION OF LOCAL VARIABLES:                                 GVHIST     13
CD                 I      -  first bus on line.                         GVHIST     14
CD                 II     - 'do' loop index.                            GVHIST     15
CD                 J      -  second bus on line.                        GVHIST     16
CD                 JPOSN   -  storage position for dc information.      GVHIST     17
CD                 VALUE  -  voltage across branch.                     GVHIST     18
CD                                                                      GVHIST     19
CD -------------------------------------------------------------------  GVHIST     20
      INCLUDE 'PARX.INS'                                                GVHIST     21
      INCLUDE 'GRDC01.INS'                                              GVHIST     22
      INCLUDE 'GRDC03.INS'                                              GVHIST     23
      INCLUDE 'UDCJ.INS'                                                GVHIST     24
C                                                                       GVHIST     25
C---------------------------------------------------------------------  GVHIST     26
C                                                                       GVHIST     27
      DO 20 II = 1, ILDC                                                GVHIST     28
         IF(IDCL(II) .NE. 0)THEN                                        GVHIST     29
C                                                                       GVHIST     30
            JPOSN = IDCL(II)                                            GVHIST     31
            I = LINREF(JPOSN,1)                                         GVHIST     32
            J = LINREF(JPOSN,2)                                         GVHIST     33
C                                                                       GVHIST     34
            IF(I.EQ.0)THEN                                              GVHIST     35
               VALUE = 0.0                                              GVHIST     36
            ELSE                                                        GVHIST     37
               VALUE = VDCNOD(I)                                        GVHIST     38
            END IF                                                      GVHIST     39
C                                                                       GVHIST     40
            IF(J .NE. 0)THEN                                            GVHIST     41
               VALUE = VALUE - VDCNOD(J)                                GVHIST     42
            END IF                                                      GVHIST     43
C                                                                       GVHIST     44
            IF(LINTYP(JPOSN).EQ.'RL')THEN                               GVHIST     45
C                                                                       GVHIST     46
C              Save voltage history term, and current history term.     GVHIST     47
C                                                                       GVHIST     48
               VHIST1(JPOSN) = VALUE                                    GVHIST     49
C                                                                       GVHIST     50
               XHIST1(JPOSN) = (VHIST1(JPOSN) / RDCOHM(JPOSN))          GVHIST     51
C                                                                       GVHIST     52
            ELSEIF(LINTYP(JPOSN).EQ.'RLC')THEN                          GVHIST     53
C                                                                       GVHIST     54
C              Save voltage history terms                               GVHIST     55
C                                                                       GVHIST     56
               VHIST1(JPOSN) = VALUE                                    GVHIST     57
               IF(I.NE.0) THEN                                          GVHIST     58
                  VHIST2(JPOSN) = VDCNOD(I)                             GVHIST     59
               ELSE                                                     GVHIST     60
                  VHIST2(JPOSN) = 0.0                                   GVHIST     61
               END IF                                                   GVHIST     62
               IF(J.NE.0) THEN                                          GVHIST     63
                  VHIST3(JPOSN) = VDCNOD(J)                             GVHIST     64
               ELSE                                                     GVHIST     65
                  VHIST3(JPOSN) = 0.0                                   GVHIST     66
               END IF                                                   GVHIST     67
C                                                                       GVHIST     68
C                                                                       GVHIST     69
C              Save current injection history terms.                    GVHIST     70
C                                                                       GVHIST     71
               XHIST1(JPOSN) = VHIST1(JPOSN) / RDCOHM(JPOSN)            GVHIST     72
               XHIST2(JPOSN) = 0.0                                      GVHIST     73
               XHIST3(JPOSN) = 0.0                                      GVHIST     74
C                                                                       GVHIST     75
            END IF                                                      GVHIST     76
C                                                                       GVHIST     77
        END IF                                                          GVHIST     78
20    CONTINUE                                                          GVHIST     79
C                                                                       GVHIST     80
C                                                                       GVHIST     81
C---------------------------------------------------------------------  GVHIST     82
C                                                                       GVHIST     83
      RETURN                                                            GVHIST     84
C                                                                       GVHIST     85
C---------------------------------------------------------------------  GVHIST     86
C                                                                       GVHIST     87
      END                                                               GVHIST     88
