CFPRIME PSGNAL                                                          PSGNAL      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 PSGNAL(ISTATE,EPD,EPQ)                                 PSGNAL      3
CD                                                                      PSGNAL      4
CD     TO PROCESS INPUT SIGNALS TO THE STABILIZER FOR USE IN IMPLICIT   PSGNAL      5
CD     INTEGRATION METHOD.                                              PSGNAL      6
CD                                                                      PSGNAL      7
      INCLUDE 'PARX.INS'                                                PSGNAL      8
      INCLUDE 'CNB4.INS'                                                PSGNAL      9
      INCLUDE 'CNB5.INS'                                                PSGNAL     10
      INCLUDE 'CNB9.INS'                                                PSGNAL     11
      INCLUDE 'CNB19.INS'                                               PSGNAL     12
      INCLUDE 'CNEXC.INS'                                               PSGNAL     13
      INCLUDE 'CNSTAB.INS'                                              PSGNAL     14
      INCLUDE 'CNXSTA.INS'                                              PSGNAL     15
      INCLUDE 'CNMDAT.INS'                                              PSGNAL     16
      INCLUDE 'CNVOLT.INS'                                              PSGNAL     17
      INCLUDE 'CNUNIT.INS'                                              PSGNAL     18
      INCLUDE 'CNFLAG.INS'                                              PSGNAL     19
      INCLUDE 'CNPARX.INS'                                              PSGNAL     20
      INCLUDE 'CNYVAR.INS'                                              PSGNAL     21
      INCLUDE 'EQYVAR.INS'                                              PSGNAL     22
      INCLUDE 'CNSGAL.INS'                                              PSGNAL     23
      INCLUDE 'CNABAK.INS'                                              PSGNAL     24
C                                                                       PSGNAL     25
      LDEB=.FALSE.                                                      PSGNAL     26
C                                                                       PSGNAL     27
      RCMP=0.0                                                          PSGNAL     28
      XCMP=0.0                                                          PSGNAL     29
      TFI=0.0                                                           PSGNAL     30
      NSNO2=0                                                           PSGNAL     31
C                                                                       PSGNAL     32
      NSNO1=IDDAT(JS+1)                                                 PSGNAL     33
      ITYP1=IDDAT(JS+2)                                                 PSGNAL     34
      ITYP2=-1                                                          PSGNAL     35
      IF (ISTABN.EQ.9.OR.ISTABN.EQ.12) THEN                             PSGNAL     36
         NSNO2=IDDAT(JS+3)                                              PSGNAL     37
         ITYP2=IDDAT(JS+4)                                              PSGNAL     38
      ELSE IF (ISTABN.EQ.10.OR.ISTABN.EQ.11) THEN                       PSGNAL     39
         NSNO2=ICBUSN                                                   PSGNAL     40
         ITYP2=5                                                        PSGNAL     41
      END IF                                                            PSGNAL     42
C                                                                       PSGNAL     43
C     SET REMOTE SIGNAL INFORMATION                                     PSGNAL     44
C                                                                       PSGNAL     45
      KN=0                                                              PSGNAL     46
      KN2=0                                                             PSGNAL     47
      DO 10 I=1,ICOLBV                                                  PSGNAL     48
         IF (NSNO1.EQ.NBR(I)) KN=2*I                                    PSGNAL     49
         IF (ISTABN.GE.10.AND.NSNO2.EQ.NBR(I)) KN2=2*I                  PSGNAL     50
   10 CONTINUE                                                          PSGNAL     51
      IF (KN.EQ.0) THEN                                                 PSGNAL     52
         ICOLBV=ICOLBV+1                                                PSGNAL     53
         NBR(ICOLBV)=NSNO1                                              PSGNAL     54
         KN=2*ICOLBV                                                    PSGNAL     55
      END IF                                                            PSGNAL     56
      IF (ISTABN.GE.10.AND.KN2.EQ.0) THEN                               PSGNAL     57
         ICOLBV=ICOLBV+1                                                PSGNAL     58
         NBR(ICOLBV)=NSNO2                                              PSGNAL     59
         KN2=2*ICOLBV                                                   PSGNAL     60
      END IF                                                            PSGNAL     61
C                                                                       PSGNAL     62
C     FIRST INPUT SIGNAL                                                PSGNAL     63
C                                                                       PSGNAL     64
C     TYPE  DOM PAC DF   P   V  DV                                      PSGNAL     65
      GOTO (590,540,530,540,550,550), ITYP1                             PSGNAL     66
C                                                                       PSGNAL     67
 530  ISTATE=ISTATE+1                                                   PSGNAL     68
C                                                                       PSGNAL     69
C     COUNT CURRENT COMPENSATION FOR BUS FREQUENCY INPUT (FIRST)        PSGNAL     70
C                                                                       PSGNAL     71
C            1   2   3   4   5   6   7   8                              PSGNAL     72
      GOTO (100,100,100,100,100,100,150,150,                            PSGNAL     73
C                                                                       PSGNAL     74
C            9   10  11  12                                             PSGNAL     75
     *      110,120,130,140), ISTABN                                    PSGNAL     76
C                                                                       PSGNAL     77
 100  RCMP=DDAT(JS+12)                                                  PSGNAL     78
      XCMP=DDAT(JS+13)                                                  PSGNAL     79
      TFI=1.0/DDAT(JS+11)                                               PSGNAL     80
      GOTO 150                                                          PSGNAL     81
C                                                                       PSGNAL     82
 110  RCMP=DDAT(JS+27)                                                  PSGNAL     83
      XCMP=DDAT(JS+28)                                                  PSGNAL     84
      TFI=1.0/DDAT(JS+26)                                               PSGNAL     85
      GOTO 150                                                          PSGNAL     86
C                                                                       PSGNAL     87
 120  RCMP=DDAT(JS+18)                                                  PSGNAL     88
      XCMP=DDAT(JS+19)                                                  PSGNAL     89
      TFI=1.0/DDAT(JS+17)                                               PSGNAL     90
      GOTO 150                                                          PSGNAL     91
C                                                                       PSGNAL     92
 130  RCMP=DDAT(JS+27)                                                  PSGNAL     93
      XCMP=DDAT(JS+28)                                                  PSGNAL     94
      TFI=1.0/DDAT(JS+26)                                               PSGNAL     95
      GOTO 150                                                          PSGNAL     96
C                                                                       PSGNAL     97
 140  RCMP=DDAT(JS+20)                                                  PSGNAL     98
      XCMP=DDAT(JS+21)                                                  PSGNAL     99
      TFI=1.0/DDAT(JS+19)                                               PSGNAL    100
C                                                                       PSGNAL    101
 150  CONTINUE                                                          PSGNAL    102
C                                                                       PSGNAL    103
      IF (NSNO1.NE.ICBUSN) THEN                                         PSGNAL    104
         RCMP=0.0                                                       PSGNAL    105
         XCMP=0.0                                                       PSGNAL    106
      END IF                                                            PSGNAL    107
C                                                                       PSGNAL    108
      VREAL=REAL(VOLT(NSNO1))+RCMP*CDGN-XCMP*CQGN                       PSGNAL    109
      VAMG=AIMAG(VOLT(NSNO1))+XCMP*CDGN+RCMP*CQGN                       PSGNAL    110
      VM=VREAL*VREAL+VAMG*VAMG                                          PSGNAL    111
      IF (VM.GT.1.0E-6) VM=TFI/VM                                       PSGNAL    112
C                                                                       PSGNAL    113
      ALP1=VM*(XCMP*VREAL-RCMP*VAMG)                                    PSGNAL    114
      ALP2=VM*(RCMP*VREAL+XCMP*VAMG)                                    PSGNAL    115
      ALP3=-VM*VAMG                                                     PSGNAL    116
      ALP4=VM*VREAL                                                     PSGNAL    117
C                                                                       PSGNAL    118
      A(ISTATE,ISTATE)=-TFI                                             PSGNAL    119
C                                                                       PSGNAL    120
      BC(ISTATE,1)=ALP1                                                 PSGNAL    121
      BC(ISTATE,2)=ALP2                                                 PSGNAL    122
      B(ISTATE,KN-1)=ALP3                                               PSGNAL    123
      B(ISTATE,KN)=ALP4                                                 PSGNAL    124
C                                                                       PSGNAL    125
      ALP1=ALP1/WXBASE                                                  PSGNAL    126
      ALP2=ALP2/WXBASE                                                  PSGNAL    127
      ALP3=ALP3/WXBASE                                                  PSGNAL    128
      ALP4=ALP4/WXBASE                                                  PSGNAL    129
      TFIOM0=TFI/WXBASE                                                 PSGNAL    130
C                                                                       PSGNAL    131
      GOTO 590                                                          PSGNAL    132
C                                                                       PSGNAL    133
 540  ALP1=EPD                                                          PSGNAL    134
      ALP2=EPQ                                                          PSGNAL    135
      ALP3=CDGN                                                         PSGNAL    136
      ALP4=CQGN                                                         PSGNAL    137
C                                                                       PSGNAL    138
      GOTO 590                                                          PSGNAL    139
C                                                                       PSGNAL    140
 550  VREAL=REAL(VOLT(NSNO1))                                           PSGNAL    141
      VAMG=AIMAG(VOLT(NSNO1))                                           PSGNAL    142
      VM=VREAL*VREAL+VAMG*VAMG                                          PSGNAL    143
      IF (VM.GT.1.0E-6) VM=1.0/SQRT(VM)                                 PSGNAL    144
      ALP3=VM*VREAL                                                     PSGNAL    145
      ALP4=VM*VAMG                                                      PSGNAL    146
C                                                                       PSGNAL    147
 590  CONTINUE                                                          PSGNAL    148
C                                                                       PSGNAL    149
C     SECOND INPUT SIGNAL (TYPE 9, 10, 11 AND 12 ONLY)                  PSGNAL    150
C                                                                       PSGNAL    151
      IF (ITYP2.GE.0) THEN                                              PSGNAL    152
C                                                                       PSGNAL    153
C        TYPE  DOM PAC DF   P   V  DV                                   PSGNAL    154
         GOTO (690,640,630,640,650,650), ITYP2                          PSGNAL    155
C                                                                       PSGNAL    156
  630    ISTATE=ISTATE+1                                                PSGNAL    157
C                                                                       PSGNAL    158
C     COUNT CURRENT COMPENSATION FOR BUS FREQUENCY INPUT (SECOND)       PSGNAL    159
C                                                                       PSGNAL    160
C               1   2   3   4   5   6   7   8                           PSGNAL    161
         GOTO (250,250,250,250,250,250,250,250,                         PSGNAL    162
C                                                                       PSGNAL    163
C               9   10  11  12                                          PSGNAL    164
     *         210,250,250,240), ISTABN                                 PSGNAL    165
C                                                                       PSGNAL    166
 210     RCMP=DDAT(JS+27)                                               PSGNAL    167
         XCMP=DDAT(JS+28)                                               PSGNAL    168
         TFI=1.0/DDAT(JS+26)                                            PSGNAL    169
         GOTO 250                                                       PSGNAL    170
C                                                                       PSGNAL    171
 240     RCMP=DDAT(JS+20)                                               PSGNAL    172
         XCMP=DDAT(JS+21)                                               PSGNAL    173
         TFI=1.0/DDAT(JS+19)                                            PSGNAL    174
C                                                                       PSGNAL    175
 250     CONTINUE                                                       PSGNAL    176
C                                                                       PSGNAL    177
         IF (NSNO2.NE.ICBUSN) THEN                                      PSGNAL    178
            RCMP=0.0                                                    PSGNAL    179
            XCMP=0.0                                                    PSGNAL    180
         END IF                                                         PSGNAL    181
C                                                                       PSGNAL    182
         VREAL=REAL(VOLT(NSNO2))+RCMP*CDGN-XCMP*CQGN                    PSGNAL    183
         VAMG=AIMAG(VOLT(NSNO2))+XCMP*CDGN+RCMP*CQGN                    PSGNAL    184
         VM=VREAL*VREAL+VAMG*VAMG                                       PSGNAL    185
         IF (VM.GT.1.0E-6) VM=TFI/VM                                    PSGNAL    186
C                                                                       PSGNAL    187
         ALPS1=VM*(XCMP*VREAL-RCMP*VAMG)                                PSGNAL    188
         ALPS2=VM*(RCMP*VREAL+XCMP*VAMG)                                PSGNAL    189
         ALPS3=-VM*VAMG                                                 PSGNAL    190
         ALPS4=VM*VREAL                                                 PSGNAL    191
C                                                                       PSGNAL    192
         A(ISTATE,ISTATE)=-TFI                                          PSGNAL    193
C                                                                       PSGNAL    194
         BC(ISTATE,1)=ALPS1                                             PSGNAL    195
         BC(ISTATE,2)=ALPS2                                             PSGNAL    196
         B(ISTATE,KN2-1)=ALPS3                                          PSGNAL    197
         B(ISTATE,KN2)=ALPS4                                            PSGNAL    198
C                                                                       PSGNAL    199
         ALPS1=ALPS1/WXBASE                                             PSGNAL    200
         ALPS2=ALPS2/WXBASE                                             PSGNAL    201
         ALPS3=ALPS3/WXBASE                                             PSGNAL    202
         ALPS4=ALPS4/WXBASE                                             PSGNAL    203
         TFIOM0=TFI/WXBASE                                              PSGNAL    204
C                                                                       PSGNAL    205
         GOTO 690                                                       PSGNAL    206
C                                                                       PSGNAL    207
 640     ALPS1=EPD                                                      PSGNAL    208
         ALPS2=EPQ                                                      PSGNAL    209
         ALPS3=CDGN                                                     PSGNAL    210
         ALPS4=CQGN                                                     PSGNAL    211
C                                                                       PSGNAL    212
         GOTO 690                                                       PSGNAL    213
C                                                                       PSGNAL    214
 650     VREAL=REAL(VOLT(NSNO1))                                        PSGNAL    215
         VAMG=AIMAG(VOLT(NSNO1))                                        PSGNAL    216
         VM=VREAL*VREAL+VAMG*VAMG                                       PSGNAL    217
         IF (VM.GT.1.0E-6) VM=1.0/SQRT(VM)                              PSGNAL    218
         ALPS3=VM*VREAL                                                 PSGNAL    219
         ALPS4=VM*VAMG                                                  PSGNAL    220
C                                                                       PSGNAL    221
 690     CONTINUE                                                       PSGNAL    222
C                                                                       PSGNAL    223
      END IF                                                            PSGNAL    224
C                                                                       PSGNAL    225
      RETURN                                                            PSGNAL    226
      END                                                               PSGNAL    227
