CFPRIME IFLTER                                                          IFLTER      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 IFLTER(ISMAX,ISMIN)                                    IFLTER      3
CD                                                                      IFLTER      4
CD    TO PERFORM INITIALIZATION AND DATA CHECK FOR STABILIZER           IFLTER      5
CD    TORSIONAL FILTER.                                                 IFLTER      6
CD                                                                      IFLTER      7
CD    THE DATA STRUCTURE AFTER THE INITIALIZATION IS GIVEN BELOW.       IFLTER      8
CD                                                                      IFLTER      9
CD   5.1 Stabilizer torsional filter type 1                             IFLTER     10
CD                                                                      IFLTER     11
CD     Torsional filter data                                            IFLTER     12
CD                                                                      IFLTER     13
CD     DDAT(JF+ 1)    = T6                                              IFLTER     14
CD     DDAT(JF+ 2)    = A5                                              IFLTER     15
CD     DDAT(JF+ 3)    = A3                                              IFLTER     16
CD     DDAT(JF+ 4)    = A6                                              IFLTER     17
CD     DDAT(JF+ 5)    = A4                                              IFLTER     18
CD     DDAT(JF+ 6)    = A1                                              IFLTER     19
CD     DDAT(JF+ 7)    = A2                                              IFLTER     20
CD     DDAT(JF+ 8)    = A0                                              IFLTER     21
CD                                                                      IFLTER     22
CD     Torsional filter states                                          IFLTER     23
CD                                                                      IFLTER     24
CD     XSTATE(JSSL+1) = T6 block                    : optional          IFLTER     25
CD     XSTATE(JSSL+2) = first state in A3/A4 block  : optional          IFLTER     26
CD     XSTATE(JSSL+3) = second state in A3/A4 block : optional          IFLTER     27
CD     XSTATE(JSSL+4) = first state in A1/A2 block  : optional          IFLTER     28
CD     XSTATE(JSSL+5) = second state in A1/A2 block : optional          IFLTER     29
CD                                                                      IFLTER     30
CD     Where JSSL is the last state of the associated stabilizer        IFLTER     31
CD                                                                      IFLTER     32
CD     Torsional filter Y-variables                                     IFLTER     33
CD                                                                      IFLTER     34
CD     There are no Y-variables for stabilizer torsional filter         IFLTER     35
CD                                                                      IFLTER     36
      INCLUDE 'PARX.INS'                                                IFLTER     37
      INCLUDE 'CNMDAT.INS'                                              IFLTER     38
      INCLUDE 'CNSTN.INS'                                               IFLTER     39
      INCLUDE 'CNB1.INS'                                                IFLTER     40
      INCLUDE 'CNB4.INS'                                                IFLTER     41
      INCLUDE 'CNXSTA.INS'                                              IFLTER     42
      INCLUDE 'CNB8.INS'                                                IFLTER     43
      INCLUDE 'CNUNIT.INS'                                              IFLTER     44
      INCLUDE 'CNEXC.INS'                                               IFLTER     45
      INCLUDE 'CNMSG.INS'                                               IFLTER     46
C                                                                       IFLTER     47
      DATA BIG/99.9/                                                    IFLTER     48
C                                                                       IFLTER     49
C   TORSIONAL FILTER                                                    IFLTER     50
C                                                                       IFLTER     51
      JF=JCONTA(5,N)                                                    IFLTER     52
      KSTATE=0                                                          IFLTER     53
C                                                                       IFLTER     54
C  INPUT TIME CONSTANTS CHECK AND RESET                                 IFLTER     55
C                                                                       IFLTER     56
      IF(DDAT(JF+1).LT.TMIN.AND.IDDAT(JF+1).NE.0)THEN                   IFLTER     57
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       IFLTER     58
     *            ,NDGC(N)                                              IFLTER     59
         WRITE(MSG(2),9020) 'T6',DDAT(JF+1),TMIN                        IFLTER     60
         IF(MTFLAG.EQ.0) THEN                                           IFLTER     61
            CALL PRTMSG(2)                                              IFLTER     62
         ELSE                                                           IFLTER     63
            WRITE(MSG(3),9030) 'T6',0.0                                 IFLTER     64
            CALL PRTMSG(3)                                              IFLTER     65
            DDAT(JF+1)=0.0                                              IFLTER     66
         ENDIF                                                          IFLTER     67
      ENDIF                                                             IFLTER     68
C                                                                       IFLTER     69
      IF(IDDAT(JF+5).EQ.0)THEN                                          IFLTER     70
         IF(DDAT(JF+3).LT.TMIN.AND.IDDAT(JF+3).NE.0)THEN                IFLTER     71
            WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)    IFLTER     72
     *                        ,NDGC(N)                                  IFLTER     73
            WRITE(MSG(2),9040)                                          IFLTER     74
            WRITE(MSG(3),9050)                                          IFLTER     75
            WRITE(MSG(4),9060)                                          IFLTER     76
            CALL PRTMSG(4)                                              IFLTER     77
C            DDAT(JF+3)=0.0                                             IFLTER     78
         ENDIF                                                          IFLTER     79
      ELSEIF(DDAT(JF+5).LT.TMIN)THEN                                    IFLTER     80
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       IFLTER     81
     *            ,NDGC(N)                                              IFLTER     82
         WRITE(MSG(2),9040)                                             IFLTER     83
         WRITE(MSG(3),9050)                                             IFLTER     84
         WRITE(MSG(4),9060)                                             IFLTER     85
         CALL PRTMSG(4)                                                 IFLTER     86
C         DDAT(JF+5)=0.0                                                IFLTER     87
C         DDAT(JF+3)=0.0                                                IFLTER     88
      ENDIF                                                             IFLTER     89
C                                                                       IFLTER     90
      IF(IDDAT(JF+7).EQ.0)THEN                                          IFLTER     91
         IF(DDAT(JF+6).LT.TMIN.AND.IDDAT(JF+6).NE.0)THEN                IFLTER     92
            WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)    IFLTER     93
     *                        ,NDGC(N)                                  IFLTER     94
            WRITE(MSG(2),9040)                                          IFLTER     95
            WRITE(MSG(3),9050)                                          IFLTER     96
            WRITE(MSG(4),9060)                                          IFLTER     97
            CALL PRTMSG(4)                                              IFLTER     98
C            DDAT(JF+6)=0.0                                             IFLTER     99
         ENDIF                                                          IFLTER    100
      ELSEIF(DDAT(JF+7).LT.TMIN)THEN                                    IFLTER    101
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       IFLTER    102
     *            ,NDGC(N)                                              IFLTER    103
         WRITE(MSG(2),9040)                                             IFLTER    104
         WRITE(MSG(3),9050)                                             IFLTER    105
         WRITE(MSG(4),9060)                                             IFLTER    106
         CALL PRTMSG(4)                                                 IFLTER    107
C         DDAT(JF+7)=0.0                                                IFLTER    108
C         DDAT(JF+6)=0.0                                                IFLTER    109
      ENDIF                                                             IFLTER    110
C                                                                       IFLTER    111
C  TRANSFER THE LIMITS FROM STABILIZER TO FILTER, THEN RELEASE THE ONE  IFLTER    112
C  IN STABILIZER                                                        IFLTER    113
C                                                                       IFLTER    114
         DDAT(JF+9)=DDAT(ISMAX)                                         IFLTER    115
         DDAT(JF+10)=DDAT(ISMIN)                                        IFLTER    116
         DDAT(ISMAX)=BIG                                                IFLTER    117
         DDAT(ISMIN)=-BIG                                               IFLTER    118
         IF(IDDAT(JF+5).EQ.0) DDAT(JF+4)=0.0                            IFLTER    119
         IF(IDDAT(JF+7).EQ.0) DDAT(JF+8)=0.0                            IFLTER    120
         DDAT(JF+11)=0.0                                                IFLTER    121
C                                                                       IFLTER    122
      IF (IDDAT(JF+1).NE.0) THEN                                        IFLTER    123
         KSTATE=KSTATE+1                                                IFLTER    124
         XSTATE(JSTATE+KSTATE)=0.0                                      IFLTER    125
      ENDIF                                                             IFLTER    126
      IF(IDDAT(JF+3).EQ.0.AND.IDDAT(JF+5).EQ.0) GOTO 100                IFLTER    127
      IF (IDDAT(JF+5).NE.0) THEN                                        IFLTER    128
         XSTATE(JSTATE+KSTATE+1)=0.0                                    IFLTER    129
         XSTATE(JSTATE+KSTATE+2)=0.0                                    IFLTER    130
         KSTATE=KSTATE+2                                                IFLTER    131
      ELSE                                                              IFLTER    132
         KSTATE=KSTATE+1                                                IFLTER    133
         XSTATE(JSTATE+KSTATE)=0.0                                      IFLTER    134
      ENDIF                                                             IFLTER    135
  100 CONTINUE                                                          IFLTER    136
      IF(IDDAT(JF+6).EQ.0.AND.IDDAT(JF+7).EQ.0) GOTO 200                IFLTER    137
      IF (IDDAT(JF+7).NE.0) THEN                                        IFLTER    138
         XSTATE(JSTATE+KSTATE+1)=0.0                                    IFLTER    139
         XSTATE(JSTATE+KSTATE+2)=0.0                                    IFLTER    140
         KSTATE=KSTATE+2                                                IFLTER    141
      ELSE                                                              IFLTER    142
         KSTATE=KSTATE+1                                                IFLTER    143
         XSTATE(JSTATE+KSTATE)=0.0                                      IFLTER    144
      ENDIF                                                             IFLTER    145
  200 CONTINUE                                                          IFLTER    146
C                                                                       IFLTER    147
      JSTATE=JSTATE+KSTATE                                              IFLTER    148
C                                                                       IFLTER    149
      RETURN                                                            IFLTER    150
C                                                                       IFLTER    151
 9000 FORMAT(' *** WARNING GENERATOR AT BUS: ',I5,' STATION: ',3A4      IFLTER    152
     *,' GID:',A4)                                                      IFLTER    153
 9020 FORMAT(5X,'TORSIONAL FILTER ',A,'=',F8.6                          IFLTER    154
     *,' IS BELOW THE LIMIT VALUE OF ',F4.2)                            IFLTER    155
 9030 FORMAT(5X,A,' HAS BEEN SET TO ',F4.2)                             IFLTER    156
 9040 FORMAT(5X,'THERE ARE VERY SMALL TIME CONSTANTS IN THE TORSIONAL ',IFLTER    157
     *'FILTER.')                                                        IFLTER    158
 9050 FORMAT(5X,'SMALL INTEGRATION STEP SIZE MAY HAVE TO BE USED IN ',  IFLTER    159
     *'THE SIMULATION')                                                 IFLTER    160
 9060 FORMAT(5X,'IF YOU EXPERIENCE ANY NUMERICAL PROBLEMS.')            IFLTER    161
      END                                                               IFLTER    162
