CFPRIME STSVCD                                                          STSVCD      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 STSVCD                                                 STSVCD      3
CD                                                                      STSVCD      4
CD    TO STORE CONVERTED SVC DATA.                                      STSVCD      5
CD                                                                      STSVCD      6
CD    ROUTINE INPUTS:                                                   STSVCD      7
CD                                                                      STSVCD      8
CD    IEBK IS THE ERROR INDICATOR                                       STSVCD      9
CD    IEBK =1 WHEN NUMBER OF SVC EXCEEDS THE PROGRAM LIMIT              STSVCD     10
CD    IEBK =2 WHEN THE SVC BUS IS NOT IN THE LOAD FLOW CASE.            STSVCD     11
CD            THE SVC DATA WILL BE IGNORED IN THIS CASE                 STSVCD     12
CD                                                                      STSVCD     13
      INCLUDE 'PARX.INS'                                                STSVCD     14
      INCLUDE 'CNPARX.INS'                                              STSVCD     15
      INCLUDE 'CNFLAG.INS'                                              STSVCD     16
      INCLUDE 'CNB19.INS'                                               STSVCD     17
      INCLUDE 'CNMNEW.INS'                                              STSVCD     18
      INCLUDE 'CNPT.INS'                                                STSVCD     19
      INCLUDE 'CNJPT.INS'                                               STSVCD     20
      INCLUDE 'CNJDAT.INS'                                              STSVCD     21
      INCLUDE 'CNTMDA.INS'                                              STSVCD     22
      INCLUDE 'CNTGED.INS'                                              STSVCD     23
      INCLUDE 'CNSVCD.INS'                                              STSVCD     24
      INCLUDE 'CNGSRC.INS'                                              STSVCD     25
      INCLUDE 'CNMSG.INS'                                               STSVCD     26
C                                                                       STSVCD     27
      CHARACTER*80 SIMBUF                                               STSVCD     28
C                                                                       STSVCD     29
      LDEB=(JDEB(8).NE.0)                                               STSVCD     30
C                                                                       STSVCD     31
      IEBK=0                                                            STSVCD     32
C                                                                       STSVCD     33
      JPQ=0                                                             STSVCD     34
      JTHGSR=0                                                          STSVCD     35
C                                                                       STSVCD     36
      IF(MNEW(NLFSV).EQ.0)THEN                                          STSVCD     37
        JDSTAT=5                                                        STSVCD     38
        IEBK=2                                                          STSVCD     39
        WRITE(MSG(1),1170)NLFSV,SVCNAM,SVCKT                            STSVCD     40
        WRITE(MSG(2),1171)                                              STSVCD     41
        CALL PRTMSG(2)                                                  STSVCD     42
        GOTO 110                                                        STSVCD     43
      ENDIF                                                             STSVCD     44
C                                                                       STSVCD     45
      IF(NGSREC.NE.0)THEN                                               STSVCD     46
        CALL ADFGEN(1,JTHGSR,NGSREC,NLFSV,SVCKT,LFGEN,XGEID,NSORDE)     STSVCD     47
        IF(JTHGSR.LE.0)THEN                                             STSVCD     48
          JTHGSR=0                                                      STSVCD     49
          JDSTAT=3                                                      STSVCD     50
        ELSE                                                            STSVCD     51
          JPQ=1                                                         STSVCD     52
          JDSTAT=IGENST(JTHGSR)                                         STSVCD     53
          JTHGSR=NSORDE(JTHGSR)                                         STSVCD     54
        ENDIF                                                           STSVCD     55
      ELSE                                                              STSVCD     56
        JDSTAT=1                                                        STSVCD     57
      ENDIF                                                             STSVCD     58
C                                                                       STSVCD     59
 110  JSVC=JSVC+1                                                       STSVCD     60
      IF(JSVC.GT.NXSR)GOTO 1000                                         STSVCD     61
      JSAB(JSVC)=NLFSV                                                  STSVCD     62
      SVCID(JSVC)='  '//SVCKT                                           STSVCD     63
      JSTHGS(JSVC)=JTHGSR                                               STSVCD     64
      JDSSAB(JSVC)=JDSTAT                                               STSVCD     65
      JJSDAT(JSVC)=JTLN                                                 STSVCD     66
C                                                                       STSVCD     67
      ITDDAT(JTLN+9)=ISVC                                               STSVCD     68
      IF(JPQ.EQ.0)THEN                                                  STSVCD     69
        ITDDAT(JTLN+11)=IQF                                             STSVCD     70
      ELSE                                                              STSVCD     71
        TDDAT(JTLN+11)=GSRCD(2,JTHGSR)                                  STSVCD     72
      ENDIF                                                             STSVCD     73
      IF(ISDIV.LT.1)ISDIV=1                                             STSVCD     74
      ITDDAT(JTLN+12)=ISDIV                                             STSVCD     75
C                                                                       STSVCD     76
      IF(ISVC.GT.5) THEN                                                STSVCD     77
        DO 200 II=1,4                                                   STSVCD     78
          TDDAT(JTLN+II)=SVCDA(II)                                      STSVCD     79
 200    CONTINUE                                                        STSVCD     80
        ITDDAT(JTLN+10)=0                                               STSVCD     81
        JTLN=JTLN+12                                                    STSVCD     82
        CALL MCHECK (NLFSV,14,JTLN,'STSVCD')                            STSVCD     83
        GOTO 9900                                                       STSVCD     84
      ELSE                                                              STSVCD     85
        IF(ISVC.EQ.1) THEN                                              STSVCD     86
          DO 300 II=1,8                                                 STSVCD     87
            TDDAT(JTLN+II)=SVCDA(II)                                    STSVCD     88
 300      CONTINUE                                                      STSVCD     89
          IF(TDDAT(JTLN+1).LE.0.0)THEN                                  STSVCD     90
            WRITE(MSG(1),1150) JSVC,TDDAT(JTLN+1)                       STSVCD     91
            CALL PRTMSG(1)                                              STSVCD     92
            GOTO 9000                                                   STSVCD     93
          ENDIF                                                         STSVCD     94
          IF(TDDAT(JTLN+2).LE.0.0.OR.TDDAT(JTLN+3).LT.0.0)THEN          STSVCD     95
            WRITE(MSG(1),1030)JSVC                                      STSVCD     96
            WRITE(MSG(2),1031)TDDAT(JTLN+2),TDDAT(JTLN+3)               STSVCD     97
            CALL PRTMSG(2)                                              STSVCD     98
            GOTO 9000                                                   STSVCD     99
          ENDIF                                                         STSVCD    100
          IF(NVSENX.GT.0)THEN                                           STSVCD    101
            IF(MNEW(NVSENX).EQ.0)THEN                                   STSVCD    102
              WRITE(MSG(1),1050) NVSENX,NLFSV,SVCNAM                    STSVCD    103
              WRITE(MSG(2),1051)                                        STSVCD    104
              CALL PRTMSG(2)                                            STSVCD    105
              CALL ASTOP('STSVCD: FATAL ERROR',19)                      STSVCD    106
            ENDIF                                                       STSVCD    107
          ELSE                                                          STSVCD    108
            NVSENX=NLFSV                                                STSVCD    109
          ENDIF                                                         STSVCD    110
          ITDDAT(JTLN+10)=NVSENX                                        STSVCD    111
C                                                                       STSVCD    112
          JTLN=JTLN+12                                                  STSVCD    113
          CALL MCHECK (NLFSV,14,JTLN,'STSVCD')                          STSVCD    114
          GOTO 9900                                                     STSVCD    115
C                                                                       STSVCD    116
C     WSCC SVC'S                                                        STSVCD    117
C                                                                       STSVCD    118
        ELSEIF(ISVC.EQ.2.OR.ISVC.EQ.3)THEN                              STSVCD    119
          DO 400 II=1,8                                                 STSVCD    120
            TDDAT(JTLN+II)=SVCDA(II)                                    STSVCD    121
 400      CONTINUE                                                      STSVCD    122
          ITDDAT(JTLN+10)=NVSENX                                        STSVCD    123
          DO 500 II=13,27                                               STSVCD    124
            TDDAT(JTLN+II)=SVCDA(II-4)                                  STSVCD    125
 500      CONTINUE                                                      STSVCD    126
          JTLN=JTLN+27                                                  STSVCD    127
          IF(ISVC.EQ.3) THEN                                            STSVCD    128
            ITDDAT(JTLN+1)=MT1                                          STSVCD    129
            ITDDAT(JTLN+2)=MT2                                          STSVCD    130
C                                                                       STSVCD    131
            IF(MT1.EQ.0)THEN                                            STSVCD    132
              ITDDAT(JTLN+3)=NVSEN1                                     STSVCD    133
              ITDDAT(JTLN+4)=NVSEN2                                     STSVCD    134
              CALL PACK(LCKT,0,JLCKT)                                   STSVCD    135
              ITDDAT(JTLN+5)=JLCKT                                      STSVCD    136
C                                                                       STSVCD    137
            ELSEIF(MT1.EQ.1)THEN                                        STSVCD    138
              TDDAT(JTLN+3)=0.02                                        STSVCD    139
              ITDDAT(JTLN+4)=NVSEN1                                     STSVCD    140
C                                                                       STSVCD    141
            ELSE                                                        STSVCD    142
              ITDDAT(JTLN+3)=NVSEN1                                     STSVCD    143
              CALL PACK(GENCKT,0,IDGEN)                                 STSVCD    144
              ITDDAT(JTLN+4)=IDGEN                                      STSVCD    145
            ENDIF                                                       STSVCD    146
C                                                                       STSVCD    147
            DO 600 II=6,16                                              STSVCD    148
              TDDAT(JTLN+II)=SVCDA(II+18)                               STSVCD    149
 600        CONTINUE                                                    STSVCD    150
            JTLN=JTLN+16                                                STSVCD    151
C                                                                       STSVCD    152
          ENDIF                                                         STSVCD    153
C                                                                       STSVCD    154
          CALL MCHECK (NLFSV,14,JTLN,'STSVCD')                          STSVCD    155
          GOTO 9900                                                     STSVCD    156
        ELSE                                                            STSVCD    157
          WRITE(MSG(1),1080) JSVC,ISVC                                  STSVCD    158
          CALL PRTMSG(1)                                                STSVCD    159
          SIMBUF='STSVCD: SVC TYPE ERROR'                               STSVCD    160
          CALL ASTOP(SIMBUF,22)                                         STSVCD    161
        ENDIF                                                           STSVCD    162
      ENDIF                                                             STSVCD    163
C                                                                       STSVCD    164
 1000 CONTINUE                                                          STSVCD    165
      WRITE(MSG(1),1040)NLFSV,SVCNAM,NXSR                               STSVCD    166
      WRITE(MSG(2),1041)                                                STSVCD    167
      CALL PRTMSG(2)                                                    STSVCD    168
      IEBK=1                                                            STSVCD    169
      GOTO 9900                                                         STSVCD    170
C                                                                       STSVCD    171
 9000 SIMBUF='STSVCD: SVC DATA ERROR'                                   STSVCD    172
      CALL ASTOP (SIMBUF,22)                                            STSVCD    173
C                                                                       STSVCD    174
 9900 RETURN                                                            STSVCD    175
C                                                                       STSVCD    176
 1030 FORMAT(1X,'*** ERROR SVC# ',I3,' QL MUST BE LARGER THAN'          STSVCD    177
     &,' ZERO AND QC NON-NEGATIVE.')                                    STSVCD    178
 1031 FORMAT(5X,'QL=',F10.5,' MVA  QC=',F10.5,' MVA')                   STSVCD    179
 1040 FORMAT(1X,'*** ERROR SVC/SATURABLE REACTOR ON BUS ',I4            STSVCD    180
     &,'EXCEEDS THE LIMIT OF ',I4)                                      STSVCD    181
 1041 FORMAT(5X,'INCREASE NSR IN PARX.INS')                             STSVCD    182
 1050 FORMAT(' *** ERROR SENSING BUS ',I5,' OF SVC ON BUS ',I5,1X,A12)  STSVCD    183
 1051 FORMAT(5X,'IS NOT IN THE BASE LOADFLOW. PLEASE CHECK YOUR DATA.') STSVCD    184
 1080 FORMAT(' *** ERROR SVC# ',I3,'HAS UNKOWN TYPE',I5)                STSVCD    185
 1150 FORMAT(' *** ERROR SVC# ',I3,' KSVC=',F10.5                       STSVCD    186
     *,' MUST BE LARGER THAN ZERO')                                     STSVCD    187
 1170 FORMAT(' *** WARNING - SVC BUS',I6,1X,A12,' ID: ',A2)             STSVCD    188
 1171 FORMAT(5X,'IS NOT IN THE BASE LOADFLOW. THE SVC IS IGNORED.')     STSVCD    189
      END                                                               STSVCD    190
