CFPRIME ISGNAL                                                          ISGNAL      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 ISGNAL(K)                                              ISGNAL      3
CD                                                                      ISGNAL      4
CD    TO PERFORM INITIALIZATION AND DATA CHECK FOR STABILIZER INPUT     ISGNAL      5
CD    SIGNALS.                                                          ISGNAL      6
CD                                                                      ISGNAL      7
      INCLUDE 'PARX.INS'                                                ISGNAL      8
      INCLUDE 'CNB5.INS'                                                ISGNAL      9
      INCLUDE 'CNB8.INS'                                                ISGNAL     10
      INCLUDE 'CNB19.INS'                                               ISGNAL     11
      INCLUDE 'CNSTN.INS'                                               ISGNAL     12
      INCLUDE 'CNEXC.INS'                                               ISGNAL     13
      INCLUDE 'CNVOLT.INS'                                              ISGNAL     14
      INCLUDE 'CNMDAT.INS'                                              ISGNAL     15
      INCLUDE 'CNXSTA.INS'                                              ISGNAL     16
      INCLUDE 'CNIPTR.INS'                                              ISGNAL     17
      INCLUDE 'CNPARX.INS'                                              ISGNAL     18
      INCLUDE 'CNYVAR.INS'                                              ISGNAL     19
      INCLUDE 'EQYVAR.INS'                                              ISGNAL     20
      INCLUDE 'CNUNIT.INS'                                              ISGNAL     21
      INCLUDE 'CNFLAG.INS'                                              ISGNAL     22
      INCLUDE 'CNSGAL.INS'                                              ISGNAL     23
C                                                                       ISGNAL     24
      LDEB=(JDEB(75).NE.0)                                              ISGNAL     25
C                                                                       ISGNAL     26
      JS2=JYS+2                                                         ISGNAL     27
C                                                                       ISGNAL     28
      NSNO1=IDDAT(JS+1)                                                 ISGNAL     29
      ITYP1=IDDAT(JS+2)                                                 ISGNAL     30
      NSNO2=K                                                           ISGNAL     31
      ITYP2=1                                                           ISGNAL     32
      IF (ISTABN.EQ.9.OR.ISTABN.EQ.12) THEN                             ISGNAL     33
         NSNO2=IDDAT(JS+3)                                              ISGNAL     34
         ITYP2=IDDAT(JS+4)                                              ISGNAL     35
         IF (NSNO2.EQ.0) THEN                                           ISGNAL     36
            NSNO2=K                                                     ISGNAL     37
            IDDAT(JS+3)=K                                               ISGNAL     38
         END IF                                                         ISGNAL     39
      END IF                                                            ISGNAL     40
C                                                                       ISGNAL     41
      IF (ITYP1.EQ.3) THEN                                              ISGNAL     42
         JY=JY+3                                                        ISGNAL     43
         IF (NSNO1.EQ.K) THEN                                           ISGNAL     44
C                                                                       ISGNAL     45
C                  1   2   3   4   5   6   7   8                        ISGNAL     46
            GOTO (100,100,100,100,100,100,150,150,                      ISGNAL     47
C                                                                       ISGNAL     48
C                  9   10  11  12                                       ISGNAL     49
     *            110,120,130,140), ISTABN                              ISGNAL     50
C                                                                       ISGNAL     51
 100        RCMP=DDAT(JS+12)                                            ISGNAL     52
            XCMP=DDAT(JS+13)                                            ISGNAL     53
            GOTO 150                                                    ISGNAL     54
C                                                                       ISGNAL     55
 110        RCMP=DDAT(JS+27)                                            ISGNAL     56
            XCMP=DDAT(JS+28)                                            ISGNAL     57
            GOTO 150                                                    ISGNAL     58
C                                                                       ISGNAL     59
 120        RCMP=DDAT(JS+18)                                            ISGNAL     60
            XCMP=DDAT(JS+19)                                            ISGNAL     61
            GOTO 150                                                    ISGNAL     62
C                                                                       ISGNAL     63
 130        RCMP=DDAT(JS+27)                                            ISGNAL     64
            XCMP=DDAT(JS+28)                                            ISGNAL     65
            GOTO 150                                                    ISGNAL     66
C                                                                       ISGNAL     67
 140        RCMP=DDAT(JS+20)                                            ISGNAL     68
            XCMP=DDAT(JS+21)                                            ISGNAL     69
C                                                                       ISGNAL     70
 150        CONTINUE                                                    ISGNAL     71
C                                                                       ISGNAL     72
         ELSE                                                           ISGNAL     73
C                                                                       ISGNAL     74
            RCMP=0.0                                                    ISGNAL     75
            XCMP=0.0                                                    ISGNAL     76
C                                                                       ISGNAL     77
         END IF                                                         ISGNAL     78
      END IF                                                            ISGNAL     79
C                                                                       ISGNAL     80
      IF (ITYP1.EQ.6) JY=JY+1                                           ISGNAL     81
      IF (ISTABN.EQ.9.OR.ISTABN.EQ.12) THEN                             ISGNAL     82
         IF (ITYP2.EQ.3) THEN                                           ISGNAL     83
            JY=JY+3                                                     ISGNAL     84
            IF (NSNO2.EQ.K) THEN                                        ISGNAL     85
C                                                                       ISGNAL     86
               IF (ISTABN.EQ.9) THEN                                    ISGNAL     87
                  RCMP=DDAT(JS+27)                                      ISGNAL     88
                  XCMP=DDAT(JS+28)                                      ISGNAL     89
               ELSE                                                     ISGNAL     90
                  RCMP=DDAT(JS+20)                                      ISGNAL     91
                  XCMP=DDAT(JS+21)                                      ISGNAL     92
               END IF                                                   ISGNAL     93
C                                                                       ISGNAL     94
            ELSE                                                        ISGNAL     95
C                                                                       ISGNAL     96
               RCMP=0.0                                                 ISGNAL     97
               XCMP=0.0                                                 ISGNAL     98
C                                                                       ISGNAL     99
            END IF                                                      ISGNAL    100
         END IF                                                         ISGNAL    101
         IF (ITYP2.EQ.6) JY=JY+1                                        ISGNAL    102
      END IF                                                            ISGNAL    103
C                                                                       ISGNAL    104
      VSI1=0.0                                                          ISGNAL    105
C                                                                       ISGNAL    106
C INPUT TYPE 1   2   3   4   5   6                                      ISGNAL    107
C     VAR.  DOM PAC DF   P   V  DV                                      ISGNAL    108
      GOTO (600,610,620,630,640,650), ITYP1                             ISGNAL    109
C                                                                       ISGNAL    110
C  ITYP1= 1. DELTA OMEGA; 2. PACCL; 3. DELTA FRE.; 4. P TERMINAL; 5. VT;ISGNAL    111
C         6. DELTA VT.                                                  ISGNAL    112
C                                                                       ISGNAL    113
  600 IF (ISTABN.EQ.2.OR.ISTABN.EQ.3.OR.ISTABN.EQ.5.OR.ISTABN.EQ.6) THENISGNAL    114
         DDAT(JS+3)=DDAT(JS+3)/WXBASE                                   ISGNAL    115
         DDAT(JS+15)=DDAT(JS+15)/WXBASE                                 ISGNAL    116
      ELSE IF (ISTABN.EQ.9) THEN                                        ISGNAL    117
         DDAT(JS+15)=DDAT(JS+15)/WXBASE                                 ISGNAL    118
      ELSE IF(ISTABN.EQ.12) THEN                                        ISGNAL    119
         DDAT(JS+5)=DDAT(JS+5)/WXBASE                                   ISGNAL    120
      ELSE                                                              ISGNAL    121
         DDAT(JS+3)=DDAT(JS+3)/WXBASE                                   ISGNAL    122
      END IF                                                            ISGNAL    123
      GOTO 690                                                          ISGNAL    124
C                                                                       ISGNAL    125
  610 IF (ISTABN.EQ.2.OR.ISTABN.EQ.3.OR.ISTABN.EQ.5.OR.ISTABN.EQ.6) THENISGNAL    126
         DDAT(JS+3)=DDAT(JS+3)/BASPRN                                   ISGNAL    127
         DDAT(JS+15)=DDAT(JS+15)/BASPRN                                 ISGNAL    128
      ELSE IF (ISTABN.EQ.9) THEN                                        ISGNAL    129
         DDAT(JS+15)=DDAT(JS+15)/BASPRN                                 ISGNAL    130
      ELSE IF(ISTABN.EQ.12) THEN                                        ISGNAL    131
         DDAT(JS+5)=DDAT(JS+5)/BASPRN                                   ISGNAL    132
      ELSE                                                              ISGNAL    133
         DDAT(JS+3)=DDAT(JS+3)/BASPRN                                   ISGNAL    134
      END IF                                                            ISGNAL    135
      GOTO 690                                                          ISGNAL    136
C                                                                       ISGNAL    137
  620 KSTATE=KSTATE+1                                                   ISGNAL    138
      IF (LDEB) ICOUNT=0                                                ISGNAL    139
      IYVAR(JS2+1)=0                                                    ISGNAL    140
      IYVAR(JS2+2)=0                                                    ISGNAL    141
C                                                                       ISGNAL    142
C     COUNT CURRENT COMPENSATION FOR BUS FREQUENCY INPUT (FIRST)        ISGNAL    143
C                                                                       ISGNAL    144
      VREAL=REAL(VOLT(NSNO1))+RCMP*CDG(1,N)-XCMP*CDG(2,N)               ISGNAL    145
      VAMG=AIMAG(VOLT(NSNO1))+XCMP*CDG(1,N)+RCMP*CDG(2,N)               ISGNAL    146
      VM=VREAL*VREAL+VAMG*VAMG                                          ISGNAL    147
      IF (VM.NE.0.0) VSI1=ATAN2(VAMG,VREAL)                             ISGNAL    148
      IF (VSI1.LT.0.0) VSI1=6.2831853+VSI1                              ISGNAL    149
      XSTATE(JSTATE+KSTATE)=VSI1                                        ISGNAL    150
      YVAR(JS2+3)=0.0                                                   ISGNAL    151
      JS2=JS2+3                                                         ISGNAL    152
      VSI1=0.0                                                          ISGNAL    153
      IF(LDEB)WRITE(IUD6,1100)VOLT(NSNO1),XSTATE(JSTATE+KSTATE)         ISGNAL    154
      GOTO 690                                                          ISGNAL    155
C                                                                       ISGNAL    156
  630 VSI1=PDGN                                                         ISGNAL    157
      IF (ISTABN.EQ.2.OR.ISTABN.EQ.3.OR.ISTABN.EQ.5.OR.ISTABN.EQ.6) THENISGNAL    158
         DDAT(JS+3)=DDAT(JS+3)/BASPRN                                   ISGNAL    159
         DDAT(JS+15)=DDAT(JS+15)/BASPRN                                 ISGNAL    160
      ELSE IF (ISTABN.EQ.9) THEN                                        ISGNAL    161
         DDAT(JS+15)=DDAT(JS+15)/BASPRN                                 ISGNAL    162
      ELSE IF(ISTABN.EQ.12) THEN                                        ISGNAL    163
         DDAT(JS+5)=DDAT(JS+5)/BASPRN                                   ISGNAL    164
      ELSE                                                              ISGNAL    165
         DDAT(JS+3)=DDAT(JS+3)/BASPRN                                   ISGNAL    166
      END IF                                                            ISGNAL    167
      GOTO 690                                                          ISGNAL    168
C                                                                       ISGNAL    169
  640 VSI1=CABS(VOLT(NSNO1))                                            ISGNAL    170
      GOTO 690                                                          ISGNAL    171
C                                                                       ISGNAL    172
  650 YVAR(JS2+1)=CABS(VOLT(NSNO1))                                     ISGNAL    173
      JS2=JS2+1                                                         ISGNAL    174
C                                                                       ISGNAL    175
  690 CONTINUE                                                          ISGNAL    176
      IF(LDEB)WRITE(IUD6,1000)NSNO1,ITYP1,KSTATE,VSI1                   ISGNAL    177
C                                                                       ISGNAL    178
C  SECOND OPTIONAL INPUT SIGNAL (TYPE 9 AND 12 ONLY)                    ISGNAL    179
C                                                                       ISGNAL    180
      IF (ISTABN.EQ.9.OR.ISTABN.EQ.12) THEN                             ISGNAL    181
         VSI2=0.0                                                       ISGNAL    182
C  INPUT TYPE   1   2   3   4   5   6                                   ISGNAL    183
C        VAR.  DOM PAC DF   P   V  DV                                   ISGNAL    184
         GOTO (700,710,720,730,740,750), ITYP2                          ISGNAL    185
C                                                                       ISGNAL    186
C  ITYP2= 1. DELTA OMEGA; 2. PACCL; 3. DELTA FRE.; 4. P TERMINAL; 5. VT;ISGNAL    187
C         6. DELTA VT.                                                  ISGNAL    188
C                                                                       ISGNAL    189
  700    IF (ISTABN.EQ.9) THEN                                          ISGNAL    190
            DDAT(JS+19)=DDAT(JS+19)/WXBASE                              ISGNAL    191
         ELSE                                                           ISGNAL    192
            DDAT(JS+7)=DDAT(JS+7)/WXBASE                                ISGNAL    193
         END IF                                                         ISGNAL    194
         GOTO 790                                                       ISGNAL    195
C                                                                       ISGNAL    196
  710    IF (ISTABN.EQ.9) THEN                                          ISGNAL    197
            DDAT(JS+19)=DDAT(JS+19)/BASPRN                              ISGNAL    198
         ELSE                                                           ISGNAL    199
            DDAT(JS+7)=DDAT(JS+7)/BASPRN                                ISGNAL    200
         END IF                                                         ISGNAL    201
         GOTO 790                                                       ISGNAL    202
C                                                                       ISGNAL    203
  720    KSTATE=KSTATE+1                                                ISGNAL    204
         IYVAR(JS2+1)=0                                                 ISGNAL    205
         IYVAR(JS2+2)=0                                                 ISGNAL    206
C                                                                       ISGNAL    207
C     COUNT CURRENT COMPENSATION FOR BUS FREQUENCY INPUT (SECOND)       ISGNAL    208
C                                                                       ISGNAL    209
         VREAL=REAL(VOLT(NSNO2))+RCMP*CDG(1,N)-XCMP*CDG(2,N)            ISGNAL    210
         VAMG=AIMAG(VOLT(NSNO2))+XCMP*CDG(1,N)+RCMP*CDG(2,N)            ISGNAL    211
         VM=VREAL*VREAL+VAMG*VAMG                                       ISGNAL    212
         IF (VM.NE.0.0) VSI2=ATAN2(VAMG,VREAL)                          ISGNAL    213
         IF (VSI2.LT.0.0) VSI2=6.2831853+VSI2                           ISGNAL    214
         XSTATE(JSTATE+KSTATE)=VSI2                                     ISGNAL    215
         YVAR(JS2+3)=0.0                                                ISGNAL    216
         JS2=JS2+3                                                      ISGNAL    217
         VSI2=0.0                                                       ISGNAL    218
         IF(LDEB)WRITE(IUD6,1200)VOLT(NSNO2),XSTATE(JSTATE+KSTATE)      ISGNAL    219
         GOTO 790                                                       ISGNAL    220
C                                                                       ISGNAL    221
  730    VSI2=PDGN                                                      ISGNAL    222
         IF (ISTABN.EQ.9) THEN                                          ISGNAL    223
            DDAT(JS+19)=DDAT(JS+19)/BASPRN                              ISGNAL    224
         ELSE                                                           ISGNAL    225
            DDAT(JS+7)=DDAT(JS+7)/BASPRN                                ISGNAL    226
         END IF                                                         ISGNAL    227
         GOTO 790                                                       ISGNAL    228
C                                                                       ISGNAL    229
  740    VSI2=CABS(VOLT(NSNO2))                                         ISGNAL    230
         GOTO 790                                                       ISGNAL    231
C                                                                       ISGNAL    232
  750    YVAR(JS2+1)=CABS(VOLT(NSNO2))                                  ISGNAL    233
         JS2=JS2+1                                                      ISGNAL    234
C                                                                       ISGNAL    235
  790    CONTINUE                                                       ISGNAL    236
         IF(LDEB)WRITE(IUD6,2000)NSNO2,ITYP2,KSTATE,VSI2                ISGNAL    237
      END IF                                                            ISGNAL    238
C                                                                       ISGNAL    239
 1000    FORMAT(' %DEBUG IN ISGNAL : NSNO1 =',I5,' ITYP1 =',I5,         ISGNAL    240
     &   ' KSTATE =',I5,' VSI1= ',F12.5)                                ISGNAL    241
 1100    FORMAT(' %DEBUG IN ISGNAL VOLT(1),VOLT(2),VSI1 ',3G12.5)       ISGNAL    242
 1200    FORMAT(' %DEBUG IN ISGNAL VOLT(1),VOLT(2),VSI2 ',3G12.5)       ISGNAL    243
 2000    FORMAT(' %DEBUG IN ISGNAL : NSNO2 =',I5,' ITYP2 =',I5,         ISGNAL    244
     &   ' KSTATE =',I5,' VSI2 = ',F12.5)                               ISGNAL    245
C                                                                       ISGNAL    246
         RETURN                                                         ISGNAL    247
         END                                                            ISGNAL    248
