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