CFPRIME IEPSS                                                           IEPSS       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 IEPSS(IREC,IU,DA,NCARD,NTHGEN,NEXTG,MGEN,MPSS,NB,NM,   IEPSS       3
     1                 UNITID,ERR)                                      IEPSS       4
CD                                                                      IEPSS       5
CD    TO READ STABILIZER CARDS FROM IEEE FORMAT DYNAMIC DATA.           IEPSS       6
CD                                                                      IEPSS       7
      INCLUDE 'CNUNIT.INS'                                              IEPSS       8
      INCLUDE 'CNMSG.INS'                                               IEPSS       9
*IF -MI2                                                                IEPSS      10
      INTEGER*2 NTHGEN,NEXTG,MGEN,MPSS                                  IEPSS      11
*ENDIF                                                                  IEPSS      12
      DIMENSION NTHGEN(NB),NEXTG(NM),MGEN(NM),MPSS(NM)                  IEPSS      13
                                                                        IEPSS      14
      CHARACTER*(*) DA(NCARD)                                           IEPSS      15
      CHARACTER*(*) UNITID(NM)                                          IEPSS      16
      CHARACTER*4 UID                                                   IEPSS      17
      CHARACTER*80 LINE                                                 IEPSS      18
                                                                        IEPSS      19
      LOGICAL ERR                                                       IEPSS      20
C                                                                       IEPSS      21
      IBUSNO=0                                                          IEPSS      22
      ERR=.FALSE.                                                       IEPSS      23
      ICMT=0                                                            IEPSS      24
      ISANTY=0                                                          IEPSS      25
C                                                                       IEPSS      26
      CALL GETLIN(IU,LINE)                                              IEPSS      27
      IF (LINE(2:16).NE.'STABILIZER DATA') THEN                         IEPSS      28
        WRITE(MSG(3),1010) LINE(2:16)                                   IEPSS      29
        WRITE(MSG(1),1000)                                              IEPSS      30
        WRITE(MSG(2),3000)                                              IEPSS      31
        CALL PRTMSG(3)                                                  IEPSS      32
        ERR=.TRUE.                                                      IEPSS      33
        GOTO 9999                                                       IEPSS      34
      ENDIF                                                             IEPSS      35
C                                                                       IEPSS      36
   1  CONTINUE                                                          IEPSS      37
      DO 110 I=1,NCARD                                                  IEPSS      38
        CALL GETLIN(IU,LINE)                                            IEPSS      39
        IF (LINE(2:5).EQ.'-999') GOTO 9999                              IEPSS      40
        IF(I.EQ.1) THEN                                                 IEPSS      41
            READ(LINE(1:5),'(I5)',IOSTAT=IOS)IBUSNO                     IEPSS      42
            IF(IBUSNO.LE.0.OR.IOS.NE.0) GOTO 9990                       IEPSS      43
            READ(LINE(7:18),'(A12)',IOSTAT=IOS)BUSNAM                   IEPSS      44
            IF(IOS.NE.0) GOTO 9995                                      IEPSS      45
            READ(LINE(20:23),'(A4)',IOSTAT=IOS)UID                      IEPSS      46
            IF(IOS.NE.0) GOTO 9995                                      IEPSS      47
        ENDIF                                                           IEPSS      48
        IF (LINE(2:20) .EQ. 'SPEED GOVERNOR DATA') THEN                 IEPSS      49
            WRITE(MSG(3),1010) LINE(2:16)                               IEPSS      50
            WRITE(MSG(1),1000)                                          IEPSS      51
            WRITE(MSG(2),3020)                                          IEPSS      52
            CALL PRTMSG(3)                                              IEPSS      53
            ERR=.TRUE.                                                  IEPSS      54
            GOTO 9997                                                   IEPSS      55
        ENDIF                                                           IEPSS      56
        ICMT=ICMT+1                                                     IEPSS      57
        DA(ICMT)=LINE                                                   IEPSS      58
 110  CONTINUE                                                          IEPSS      59
C                                                                       IEPSS      60
      ISANTY=ISANTY+ICMT                                                IEPSS      61
      IREC=IREC+1                                                       IEPSS      62
      ISTREC=IREC                                                       IEPSS      63
      WRITE(IU31,REC=IREC)DA(1), DA(2)                                  IEPSS      64
      IREC=IREC+1                                                       IEPSS      65
      WRITE(IU31,REC=IREC)DA(3)                                         IEPSS      66
C    ...............................................................    IEPSS      67
C    :SET UP MPSS() POINTERS                                       :    IEPSS      68
C    :                                                             :    IEPSS      69
      ITHGEN=NTHGEN(IBUSNO)                                             IEPSS      70
      IF(ITHGEN.NE.0) THEN                                              IEPSS      71
C        :YES there is a generator at this bus:                         IEPSS      72
 140     CONTINUE                                                       IEPSS      73
         IF(UID.EQ.UNITID(ITHGEN)) THEN                                 IEPSS      74
C           :id matched :                                               IEPSS      75
            MPSS(ITHGEN)=ISTREC                                         IEPSS      76
         ELSE                                                           IEPSS      77
C           :generator id not match, see if there is another:           IEPSS      78
C           :generator on the same bus                      :           IEPSS      79
            ITHGEN=NEXTG(ITHGEN)                                        IEPSS      80
            IF(ITHGEN.NE.0) GOTO 140                                    IEPSS      81
            WRITE(MSG(1),5115) IBUSNO                                   IEPSS      82
            CALL PRTMSG(1)                                              IEPSS      83
         ENDIF                                                          IEPSS      84
      ELSE                                                              IEPSS      85
         WRITE(MSG(1),5100) IBUSNO                                      IEPSS      86
         CALL PRTMSG(1)                                                 IEPSS      87
      ENDIF                                                             IEPSS      88
C    :.............................................................:    IEPSS      89
      GOTO 1                                                            IEPSS      90
C                                                                       IEPSS      91
 9990 CONTINUE                                                          IEPSS      92
      WRITE(MSG(1),3050)                                                IEPSS      93
      MSG(2)=LINE                                                       IEPSS      94
      CALL PRTMSG(2)                                                    IEPSS      95
      ERR=.TRUE.                                                        IEPSS      96
      GOTO 9999                                                         IEPSS      97
 9995 CONTINUE                                                          IEPSS      98
      WRITE(MSG(1),3060)                                                IEPSS      99
      MSG(2)=LINE                                                       IEPSS     100
      CALL PRTMSG(2)                                                    IEPSS     101
      ERR=.TRUE.                                                        IEPSS     102
      GOTO 9999                                                         IEPSS     103
 9997 CONTINUE                                                          IEPSS     104
      WRITE(MSG(1),3080)                                                IEPSS     105
      CALL PRTMSG(1)                                                    IEPSS     106
      ERR=.TRUE.                                                        IEPSS     107
      GOTO 9999                                                         IEPSS     108
                                                                        IEPSS     109
 9999 CONTINUE                                                          IEPSS     110
      ICHECK=MOD(ISANTY,NCARD)                                          IEPSS     111
      IF(ICHECK.NE.0)THEN                                               IEPSS     112
         WRITE(MSG(1),3070) ISANTY                                      IEPSS     113
         CALL PRTMSG(1)                                                 IEPSS     114
      ENDIF                                                             IEPSS     115
      RETURN                                                            IEPSS     116
C                                                                       IEPSS     117
 1000 FORMAT(' *** ERROR READING IEEE FORMAT STABILIZER DATA CARS.')    IEPSS     118
 1010 FORMAT(11X,'DATA READ IN IS:',A)                                  IEPSS     119
 3000 FORMAT(11X,'EXPECTING  "STABILIZER DATA" IN COLUMNS 2 TO 16.')    IEPSS     120
 3020 FORMAT(11X,'EXPECTING  "-999" TO END STABILIZER')                 IEPSS     121
 3050 FORMAT(' *** ERROR READING BUS NUMBER OF THIS DATA LINE :')       IEPSS     122
 3060 FORMAT(' *** ERROR READING BUS NAME OF THIS DATA LINE :')         IEPSS     123
 3070 FORMAT(' *** PSS CARD ERROR. READ IN ',I6,' CARDS. ')             IEPSS     124
 3080 FORMAT(' *** ERROR "-999" CARD MISSING FOR PSS DATA BLOCK')       IEPSS     125
 5115 FORMAT(' *** WARNING CAN NOT MATCH PSS WITH GENERATOR ON BUS',I6) IEPSS     126
 5100 FORMAT(' *** WARNING PSS ON BUS ',I6                              IEPSS     127
     *,' BUT NO GENERATOR. THIS PSS IS IGNORED.')                       IEPSS     128
      END                                                               IEPSS     129
