CFPRIME ICSTAB                                                          ICSTAB      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 ICSTAB(K)                                              ICSTAB      3
CD                                                                      ICSTAB      4
CD    TO CHECK STABILIZER DATA AND PRINT ERROR OR WARNING MESSAGES      ICSTAB      5
CD    IF NECESSARY.                                                     ICSTAB      6
CD                                                                      ICSTAB      7
      INCLUDE 'PARX.INS'                                                ICSTAB      8
      INCLUDE 'CNMDAT.INS'                                              ICSTAB      9
      INCLUDE 'CNSTN.INS'                                               ICSTAB     10
      INCLUDE 'CNXSTA.INS'                                              ICSTAB     11
      INCLUDE 'CNIPTR.INS'                                              ICSTAB     12
      INCLUDE 'CNB1.INS'                                                ICSTAB     13
      INCLUDE 'CNB8.INS'                                                ICSTAB     14
      INCLUDE 'CNEXC.INS'                                               ICSTAB     15
      INCLUDE 'CNUNIT.INS'                                              ICSTAB     16
      INCLUDE 'CNMSG.INS'                                               ICSTAB     17
C                                                                       ICSTAB     18
      CHARACTER*4 CKID                                                  ICSTAB     19
C                                                                       ICSTAB     20
      DATA BIG/99.9/                                                    ICSTAB     21
C                                                                       ICSTAB     22
       IF(ISTABN.NE.7)THEN                                              ICSTAB     23
         NSNO1=IDDAT(JS+1)                                              ICSTAB     24
         ITYP1=IDDAT(JS+2)                                              ICSTAB     25
         IF (NSNO1.EQ.0) THEN                                           ICSTAB     26
           NSNO1=K                                                      ICSTAB     27
           IDDAT(JS+1)=K                                                ICSTAB     28
         ENDIF                                                          ICSTAB     29
         KSNO1=NOLD(NSNO1)                                              ICSTAB     30
C                                                                       ICSTAB     31
         IF(ISTABN.EQ.12)THEN                                           ICSTAB     32
           NSNO2=IDDAT(JS+3)                                            ICSTAB     33
           ITYP2=IDDAT(JS+4)                                            ICSTAB     34
           IF (NSNO2.EQ.0) THEN                                         ICSTAB     35
             NSNO2=K                                                    ICSTAB     36
             IDDAT(JS+3)=K                                              ICSTAB     37
           ENDIF                                                        ICSTAB     38
         ENDIF                                                          ICSTAB     39
       ENDIF                                                            ICSTAB     40
C                                                                       ICSTAB     41
C  SET DEFAULT VALUES TO UNDEFINED DATA (FOR TYPE 1-6)                  ICSTAB     42
C                                                                       ICSTAB     43
      IF (ISTABN.EQ.2.OR.ISTABN.EQ.3.OR.ISTABN.EQ.5                     ICSTAB     44
     &.OR.ISTABN.EQ.6)THEN                                              ICSTAB     45
C                                                                       ICSTAB     46
C  ISTAB = 2,3,5,6, TEST VS3MX, VS3MN, VANGM AND VANGMX.                ICSTAB     47
C                                                                       ICSTAB     48
         IF (IDDAT(JS+19).EQ.0.AND.IDDAT(JS+20).EQ.0)THEN               ICSTAB     49
           DDAT(JS+19)=BIG                                              ICSTAB     50
           DDAT(JS+20)=-BIG                                             ICSTAB     51
         ENDIF                                                          ICSTAB     52
        IF (DDAT(JS+19).LT.0.0.OR.DDAT(JS+20).GT.0.0) THEN              ICSTAB     53
         CKID(1:2)=NDGC(N)(3:4)                                         ICSTAB     54
         WRITE(MSG(1),1900) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       ICSTAB     55
     *                     ,CKID                                        ICSTAB     56
         WRITE(MSG(2),1970) ISTABN,DDAT(JS+19),DDAT(JS+20)              ICSTAB     57
         CALL PRTMSG(2)                                                 ICSTAB     58
        END IF                                                          ICSTAB     59
C                                                                       ICSTAB     60
         IF (IDDAT(JS+21).EQ.0) DDAT(JS+21)=BIG                         ICSTAB     61
         IF (IDDAT(JS+22).EQ.0) DDAT(JS+22)=BIG                         ICSTAB     62
        IF (DDAT(JS+22).LT.0.0) THEN                                    ICSTAB     63
         CKID(1:2)=NDGC(N)(3:4)                                         ICSTAB     64
         WRITE(MSG(1),1900) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       ICSTAB     65
     *                     ,CKID                                        ICSTAB     66
         WRITE(MSG(2),1980) ISTABN,DDAT(JS+22)                          ICSTAB     67
         CALL PRTMSG(2)                                                 ICSTAB     68
        END IF                                                          ICSTAB     69
C                                                                       ICSTAB     70
C  SET SW1 STATUS OPEN                                                  ICSTAB     71
C                                                                       ICSTAB     72
         IDDAT(JS+23)=0                                                 ICSTAB     73
C                                                                       ICSTAB     74
C   DEFAULT VALUE FOR THRESHOLD VALUE OF  ET                            ICSTAB     75
C                                                                       ICSTAB     76
         IF (IDDAT(JS+18).EQ.0) DDAT(JS+18)=0.6                         ICSTAB     77
C                                                                       ICSTAB     78
      ENDIF                                                             ICSTAB     79
C                                                                       ICSTAB     80
      IF (ISTABN.LE.6) THEN                                             ICSTAB     81
C                                                                       ICSTAB     82
C      TEST VSMX AND VSMN.                                              ICSTAB     83
C                                                                       ICSTAB     84
        IF (IDDAT(JS+9).EQ.0.AND.IDDAT(JS+10).EQ.0)THEN                 ICSTAB     85
          DDAT(JS+9)=BIG                                                ICSTAB     86
          DDAT(JS+10)=-BIG                                              ICSTAB     87
        ENDIF                                                           ICSTAB     88
        IF (DDAT(JS+9).LT.0.0.OR.DDAT(JS+10).GT.0.0) THEN               ICSTAB     89
         CKID(1:2)=NDGC(N)(3:4)                                         ICSTAB     90
         WRITE(MSG(1),1900) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       ICSTAB     91
     *                     ,CKID                                        ICSTAB     92
         WRITE(MSG(2),1960) ISTABN,DDAT(JS+9),DDAT(JS+10)               ICSTAB     93
         CALL PRTMSG(2)                                                 ICSTAB     94
        END IF                                                          ICSTAB     95
      ENDIF                                                             ICSTAB     96
C                                                                       ICSTAB     97
      KN=K*3                                                            ICSTAB     98
      NLF=NOLD(K)                                                       ICSTAB     99
C                                                                       ICSTAB    100
C   PRINT STABILIZER DATA                                               ICSTAB    101
C                                                                       ICSTAB    102
C             1   2   3   4   5   6   7   8   9  10  11  12             ICSTAB    103
      GO TO (760,760,760,760,760,760,850,850,790,800,810,820), ISTABN   ICSTAB    104
C                                                                       ICSTAB    105
 790  IF (IDDAT(JS+6).GT.IDDAT(JS+5)) THEN                              ICSTAB    106
         CKID(1:2)=NDGC(N)(3:4)                                         ICSTAB    107
         WRITE(MSG(1),1900) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       ICSTAB    108
     *                     ,CKID                                        ICSTAB    109
         WRITE(MSG(2),1950) IDDAT(JS+6),IDDAT(JS+5)                     ICSTAB    110
         CALL PRTMSG(2)                                                 ICSTAB    111
         IDDAT(JS+6)=IDDAT(JS+5)                                        ICSTAB    112
      END IF                                                            ICSTAB    113
      PTHR=DDAT(JS+29)                                                  ICSTAB    114
      GO TO 830                                                         ICSTAB    115
C                                                                       ICSTAB    116
 800  PTHR=DDAT(JS+20)                                                  ICSTAB    117
      GO TO 830                                                         ICSTAB    118
C                                                                       ICSTAB    119
 810  PTHR=DDAT(JS+30)                                                  ICSTAB    120
      GO TO 830                                                         ICSTAB    121
C                                                                       ICSTAB    122
 820  PTHR=DDAT(JS+24)                                                  ICSTAB    123
      GO TO 830                                                         ICSTAB    124
C                                                                       ICSTAB    125
 760  PTHR=DDAT(JS+14)                                                  ICSTAB    126
 830  IF (PDGN.LT.PTHR) THEN                                            ICSTAB    127
         ICONTA(5,N)=-ICONTA(5,N)                                       ICSTAB    128
         CKID(1:2)=NDGC(N)(3:4)                                         ICSTAB    129
         WRITE(MSG(1),1900) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       ICSTAB    130
     *                     ,CKID                                        ICSTAB    131
         WRITE(MSG(2),1920) ISTABN                                      ICSTAB    132
         WRITE(MSG(3),1930)                                             ICSTAB    133
         WRITE(MSG(4),1940)                                             ICSTAB    134
         CALL PRTMSG(4)                                                 ICSTAB    135
      END IF                                                            ICSTAB    136
 850  CONTINUE                                                          ICSTAB    137
C                                                                       ICSTAB    138
      RETURN                                                            ICSTAB    139
C                                                                       ICSTAB    140
 1900 FORMAT(' *** WARNING GENERATOR AT BUS:',I6,' STATION: ',3A4       ICSTAB    141
     *,' GID: ',A2)                                                     ICSTAB    142
 1920 FORMAT(14X,'TYPE',I5,' STABILIZER IS ASSUMED NOT CONNECTED TO')   ICSTAB    143
 1930 FORMAT(14X                                                        ICSTAB    144
     *,'THE EXCITATION CONTROL SYSTEM DUE TO GENERATION IS LESS')       ICSTAB    145
 1940 FORMAT(14X,'THAN THE THRESHOLD LEVEL')                            ICSTAB    146
 1950 FORMAT(14X,'TYPE 9 STATILIZER M=',I2,' IS GREATER THAN N=',I2     ICSTAB    147
     *,' M IS SET TO N.')                                               ICSTAB    148
 1960 FORMAT(5X,'TYPE',I5,' STABILIZER DATA ERROR. VSMAX=',F10.5        ICSTAB    149
     *,' VSMIN=',F10.5)                                                 ICSTAB    150
 1970 FORMAT(5X,'TYPE',I5,' STABILIZER DATA ERROR. VS3MX=',F10.5        ICSTAB    151
     *,' VS3MN=',F10.5)                                                 ICSTAB    152
 1980 FORMAT(5X,'TYPE',I5,' STABILIZER DATA ERROR. VANGMX=',F10.5)      ICSTAB    153
C                                                                       ICSTAB    154
      END                                                               ICSTAB    155
