CFPRIME SETSIM                                                          SETSIM      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 SETSIM(PARAM,LENPAR,IUY,KLAYER)                        SETSIM      3
CD                                                                      SETSIM      4
CD    THIS SUBROUTINE PROMPTS QUESTIONS AND RECEIVES ASNWERS FROM       SETSIM      5
CD    THE USER SO AS TO GUIDE THE USER THROUGH A COMPLETE ETMSP RUN.    SETSIM      6
CD                                                                      SETSIM      7
      INCLUDE 'PARX.INS'                                                SETSIM      8
      INCLUDE 'CNPT.INS'                                                SETSIM      9
      INCLUDE 'CNLSTA.INS'                                              SETSIM     10
      INCLUDE 'CNKEYW.INS'                                              SETSIM     11
      INCLUDE 'CNTMDA.INS'                                              SETSIM     12
      INCLUDE 'CNUNIT.INS'                                              SETSIM     13
C                                                                       SETSIM     14
      CHARACTER*80 STRING,MSG                                           SETSIM     15
      CHARACTER*50 PARAM                                                SETSIM     16
      CHARACTER*7 SUBPMT                                                SETSIM     17
      LOGICAL LRECOR                                                    SETSIM     18
C                                                                       SETSIM     19
C                                                                       SETSIM     20
      DATA LRECOR/.FALSE./                                              SETSIM     21
C                                                                       SETSIM     22
      SUBPMT='SETSIM '                                                  SETSIM     23
CD                                                                      SETSIM     24
CD    STEP 1 : CASE                                                     SETSIM     25
CD                                                                      SETSIM     26
 100  CONTINUE                                                          SETSIM     27
      WRITE(LOUT,*)                                                     SETSIM     28
      MSG='DO YOU WANT TO CHANGE SIMULATION CONTROL AND '//             SETSIM     29
     &    'PARAMETER SETUP ? (Y/N)'                                     SETSIM     30
      CALL REDLIN(LOUT,LIN,IOERR,68,MSG,SUBPMT,'SE1',STRING,LRECOR,     SETSIM     31
     &IREC,KLAYER,KEND,KREAD,PLAYBA)                                    SETSIM     32
      IF (IOERR.LT.0) GOTO 150                                          SETSIM     33
      IF (STRING(1:1).EQ.'Y'.OR.STRING(1:1).EQ.'y') THEN                SETSIM     34
         IF (RECORD)WRITE(IREC,'(A)') 'CASE '                           SETSIM     35
         CALL CASE(PARAM,LENPAR,LDUMP,NCAS,KDEB,LFEPRI,KLAYER)          SETSIM     36
      ELSE IF (STRING(1:1).EQ.'Q'.OR.STRING(1:1).EQ.'q') THEN           SETSIM     37
         RETURN                                                         SETSIM     38
      ELSE IF (STRING(1:1).NE.'N'.AND.STRING(1:1).NE.'n') THEN          SETSIM     39
         GOTO 100                                                       SETSIM     40
      END IF                                                            SETSIM     41
CD                                                                      SETSIM     42
CD    STEP 2 : LOADFLOW                                                 SETSIM     43
CD                                                                      SETSIM     44
      IF (RECORD)WRITE(IREC,'(A)') 'LOADFL '                            SETSIM     45
      CALL LOADFL(PARAM,LENPAR,LDUMP,NCAS,KDEB,LFEPRI,KLAYER,LEBK)      SETSIM     46
CD                                                                      SETSIM     47
CD    STEP 3 : DYNDAT                                                   SETSIM     48
CD                                                                      SETSIM     49
      IF (RECORD)WRITE(IREC,'(A)') 'DYNDAT '                            SETSIM     50
      JTLN=0                                                            SETSIM     51
      CALL DYNDAT(PARAM,LENPAR,IUY,KLAYER)                              SETSIM     52
CD                                                                      SETSIM     53
CD    STEP 4 : MDYNDAT                                                  SETSIM     54
CD                                                                      SETSIM     55
 150  CONTINUE                                                          SETSIM     56
      WRITE(LOUT,*)                                                     SETSIM     57
      MSG='DO YOU WANT TO MODIFY OR READ MORE DYNAMIC DATA ? (Y/N)'     SETSIM     58
      CALL REDLIN(LOUT,LIN,IOERR,55,MSG,SUBPMT,'SE2',STRING,LRECOR,     SETSIM     59
     &IREC,KLAYER,KEND,KREAD,PLAYBA)                                    SETSIM     60
      IF (IOERR.LT.0) GOTO 150                                          SETSIM     61
      IF (STRING(1:1).EQ.'Y'.OR.STRING(1:1).EQ.'y') THEN                SETSIM     62
         IF (RECORD)WRITE(IREC,'(A)') 'MDYNDAT '                        SETSIM     63
         CALL MDYNDA(PARAM,LENPAR,IUY,KLAYER)                           SETSIM     64
      ELSE IF (STRING(1:1).EQ.'Q'.OR.STRING(1:1).EQ.'q') THEN           SETSIM     65
         RETURN                                                         SETSIM     66
      ELSE IF (STRING(1:1).NE.'N'.AND.STRING(1:1).NE.'n') THEN          SETSIM     67
         GOTO 150                                                       SETSIM     68
      END IF                                                            SETSIM     69
CD                                                                      SETSIM     70
CD    STEP 5 : WDYNDAT                                                  SETSIM     71
CD                                                                      SETSIM     72
 160  CONTINUE                                                          SETSIM     73
      WRITE(LOUT,*)                                                     SETSIM     74
      MSG='DO YOU WANT TO EXPORT DYNAMIC DATA IN EPRI FORMAT ? (Y/N)'   SETSIM     75
      CALL REDLIN(LOUT,LIN,IOERR,57,MSG,SUBPMT,'SE3',STRING,LRECOR,     SETSIM     76
     &IREC,KLAYER,KEND,KREAD,PLAYBA)                                    SETSIM     77
      IF (IOERR.LT.0) GOTO 160                                          SETSIM     78
      IF (STRING(1:1).EQ.'Y'.OR.STRING(1:1).EQ.'y') THEN                SETSIM     79
         IF (RECORD)WRITE(IREC,'(A)') 'WDYNDAT '                        SETSIM     80
         CALL WDYNDA(PARAM,LENPAR,IUY,KLAYER)                           SETSIM     81
      ELSE IF (STRING(1:1).EQ.'Q'.OR.STRING(1:1).EQ.'q') THEN           SETSIM     82
         RETURN                                                         SETSIM     83
      ELSE IF (STRING(1:1).NE.'N'.AND.STRING(1:1).NE.'n') THEN          SETSIM     84
         GOTO 160                                                       SETSIM     85
      END IF                                                            SETSIM     86
CD                                                                      SETSIM     87
CD    STEP 6 : LDYNDATA                                                 SETSIM     88
CD                                                                      SETSIM     89
      IF (RECORD)WRITE(IREC,'(A)') 'LDYNDAT '                           SETSIM     90
      CALL LDYNDA(IUY,IEBK)                                             SETSIM     91
      IF (IEBK.NE.0) GOTO 1000                                          SETSIM     92
CD                                                                      SETSIM     93
CD    STEP 7 : RELADATA                                                 SETSIM     94
CD                                                                      SETSIM     95
 170  CONTINUE                                                          SETSIM     96
      WRITE(LOUT,*)                                                     SETSIM     97
      MSG='DO YOU HAVE AN EXISTING AUTOMATIC RELAY DATA FILE ? (Y/N)'   SETSIM     98
      CALL REDLIN(LOUT,LIN,IOERR,57,MSG,SUBPMT,'SE4',STRING,LRECOR,     SETSIM     99
     &IREC,KLAYER,KEND,KREAD,PLAYBA)                                    SETSIM    100
      IF (IOERR.LT.0) GOTO 170                                          SETSIM    101
      IF (STRING(1:1).EQ.'Y'.OR.STRING(1:1).EQ.'y') THEN                SETSIM    102
         IF(RECORD)WRITE(IREC,'(A)') 'RELADA '                          SETSIM    103
         CALL RELADA(PARAM,LENPAR,IUX,IUY)                              SETSIM    104
      ELSE IF (STRING(1:1).EQ.'Q'.OR.STRING(1:1).EQ.'q') THEN           SETSIM    105
         RETURN                                                         SETSIM    106
      ELSE IF (STRING(1:1).NE.'N'.AND.STRING(1:1).NE.'n') THEN          SETSIM    107
         GOTO 170                                                       SETSIM    108
      END IF                                                            SETSIM    109
CD                                                                      SETSIM    110
CD    STEP 8 : RRESDAT                                                  SETSIM    111
CD                                                                      SETSIM    112
      IF (RECORD) WRITE(IREC,'(A)') 'RRESDA '                           SETSIM    113
      CALL RRESDA(PARAM,LENPAR,IUX,IUY)                                 SETSIM    114
      CALL REBUS                                                        SETSIM    115
      CALL HEAD                                                         SETSIM    116
      CALL YSELF                                                        SETSIM    117
      CALL RENET                                                        SETSIM    118
      IF (NAUT.NE.0) CALL ASWINT                                        SETSIM    119
      IF (KCDC.NE.0) CALL DCCONT                                        SETSIM    120
CD                                                                      SETSIM    121
CD    STEP 9 : SWITDATA                                                 SETSIM    122
CD                                                                      SETSIM    123
      IF (RECORD) WRITE(IREC,'(A)') 'SWITDAT '                          SETSIM    124
      CALL SWITDA(PARAM,LENPAR,IUX,IUY,IEBK)                            SETSIM    125
      IF (IEBK.NE.0) GOTO 1000                                          SETSIM    126
CD                                                                      SETSIM    127
CD    STEP 10 : MSWITDA                                                 SETSIM    128
CD                                                                      SETSIM    129
 175  CONTINUE                                                          SETSIM    130
      WRITE(LOUT,*)                                                     SETSIM    131
      MSG='DO YOU WANT TO MODIFY SIMULATION SPECIFICATION DATA ? (Y/N)' SETSIM    132
      CALL REDLIN(LOUT,LIN,IOERR,59,MSG,SUBPMT,'SE5',STRING,LRECOR,     SETSIM    133
     &IREC,KLAYER,KEND,KREAD,PLAYBA)                                    SETSIM    134
      IF (IOERR.LT.0) GOTO 175                                          SETSIM    135
      IF (STRING(1:1).EQ.'Y'.OR.STRING(1:1).EQ.'y') THEN                SETSIM    136
         IF(RECORD)WRITE(IREC,'(A)') 'MSWITDA '                         SETSIM    137
         CALL EDTFIL(IU52,IU31)                                         SETSIM    138
      ELSE IF (STRING(1:1).EQ.'Q'.OR.STRING(1:1).EQ.'q') THEN           SETSIM    139
         RETURN                                                         SETSIM    140
      ELSE IF (STRING(1:1).NE.'N'.AND.STRING(1:1).NE.'n') THEN          SETSIM    141
         GOTO 175                                                       SETSIM    142
      END IF                                                            SETSIM    143
CD                                                                      SETSIM    144
CD    STEP 11 : LSWITDA                                                 SETSIM    145
CD                                                                      SETSIM    146
      IF (RECORD) WRITE(IREC,'(A)') 'LSWITDA '                          SETSIM    147
      IPSWIT=0                                                          SETSIM    148
      CALL LSWITD(IEBK,IPSWIT,IUY)                                      SETSIM    149
C                                                                       SETSIM    150
      CALL YBRAN                                                        SETSIM    151
C                                                                       SETSIM    152
      IF (IEBK.NE.0) GOTO 1000                                          SETSIM    153
      IF (IPSWIT.NE.0) CALL PSWITS(IUY)                                 SETSIM    154
      CALL ACHAN                                                        SETSIM    155
CD                                                                      SETSIM    156
CD    STEP 12 : TABDATA                                                 SETSIM    157
CD                                                                      SETSIM    158
 180  CONTINUE                                                          SETSIM    159
      WRITE(LOUT,*)                                                     SETSIM    160
      MSG='DO YOU WANT TO TABULATE THE DYNAMIC AND '//                  SETSIM    161
     &    'OTHER ASSOCIATED DATA ? (Y/N)'                               SETSIM    162
      CALL REDLIN(LOUT,LIN,IOERR,69,MSG,SUBPMT,'SE6',STRING,LRECOR,     SETSIM    163
     &IREC,KLAYER,KEND,KREAD,PLAYBA)                                    SETSIM    164
      IF (IOERR.LT.0) GOTO 180                                          SETSIM    165
      IF (STRING(1:1).EQ.'Y'.OR.STRING(1:1).EQ.'y') THEN                SETSIM    166
         IF (RECORD) WRITE(IREC,'(A)') 'TADATA  '                       SETSIM    167
         CALL TABDAT                                                    SETSIM    168
      ELSE IF (STRING(1:1).EQ.'Q'.OR.STRING(1:1).EQ.'q') THEN           SETSIM    169
         RETURN                                                         SETSIM    170
      ELSE IF (STRING(1:1).NE.'N'.AND.STRING(1:1).NE.'n') THEN          SETSIM    171
         GOTO 180                                                       SETSIM    172
      END IF                                                            SETSIM    173
CD                                                                      SETSIM    174
CD    STEP 13 : INITIALIZATION                                          SETSIM    175
CD                                                                      SETSIM    176
 200  CONTINUE                                                          SETSIM    177
      WRITE(LOUT,*)                                                     SETSIM    178
      MSG='DO YOU WANT TO PERFORM THE INITIALIZATION ? (Y/N)'           SETSIM    179
      CALL REDLIN(LOUT,LIN,IOERR,49,MSG,SUBPMT,'SE7',STRING,LRECOR,     SETSIM    180
     &IREC,KLAYER,KEND,KREAD,PLAYBA)                                    SETSIM    181
      IF (IOERR.LT.0) GOTO 200                                          SETSIM    182
      IF (STRING(1:1).EQ.'Y'.OR.STRING(1:1).EQ.'y') THEN                SETSIM    183
         IF (RECORD) WRITE(IREC,'(A)') 'INITIA '                        SETSIM    184
         CALL INITIA                                                    SETSIM    185
      ELSE IF (STRING(1:1).EQ.'Q'.OR.STRING(1:1).EQ.'q') THEN           SETSIM    186
         RETURN                                                         SETSIM    187
      ELSE IF (STRING(1:1).NE.'N'.AND.STRING(1:1).NE.'n') THEN          SETSIM    188
         GOTO 200                                                       SETSIM    189
      ELSE                                                              SETSIM    190
         GOTO 500                                                       SETSIM    191
      END IF                                                            SETSIM    192
CD                                                                      SETSIM    193
CD    STEP 14 : TABINT                                                  SETSIM    194
CD                                                                      SETSIM    195
 250  CONTINUE                                                          SETSIM    196
      WRITE(LOUT,*)                                                     SETSIM    197
      MSG='DO YOU WANT TO TABULATE INITIAL CONDITIONS ? (Y/N)'          SETSIM    198
      CALL REDLIN(LOUT,LIN,IOERR,50,MSG,SUBPMT,'SE8',STRING,LRECOR,     SETSIM    199
     &IREC,KLAYER,KEND,KREAD,PLAYBA)                                    SETSIM    200
      IF (IOERR.LT.0) GOTO 250                                          SETSIM    201
      IF (STRING(1:1).EQ.'Y'.OR.STRING(1:1).EQ.'y') THEN                SETSIM    202
         IF (RECORD) WRITE(IREC,'(A)') 'TAINI  '                        SETSIM    203
         CALL TABINI(PARAM,LENPAR)                                      SETSIM    204
      ELSE IF (STRING(1:1).EQ.'Q'.OR.STRING(1:1).EQ.'q') THEN           SETSIM    205
         RETURN                                                         SETSIM    206
      ELSE IF (STRING(1:1).NE.'N'.AND.STRING(1:1).NE.'n') THEN          SETSIM    207
         GOTO 250                                                       SETSIM    208
      ELSE                                                              SETSIM    209
         GOTO 300                                                       SETSIM    210
      END IF                                                            SETSIM    211
CD                                                                      SETSIM    212
CD    STEP 15 : SIMULATION                                              SETSIM    213
CD                                                                      SETSIM    214
 300  CONTINUE                                                          SETSIM    215
      WRITE(LOUT,*)                                                     SETSIM    216
      MSG='DO YOU WANT TO START THE SIMULATION ? (Y/N)'                 SETSIM    217
      CALL REDLIN(LOUT,LIN,IOERR,43,MSG,SUBPMT,'SE9',STRING,LRECOR,     SETSIM    218
     &IREC,KLAYER,KEND,KREAD,PLAYBA)                                    SETSIM    219
      IF (IOERR.LT.0) GOTO 300                                          SETSIM    220
      IF (STRING(1:1).EQ.'Y'.OR.STRING(1:1).EQ.'y') THEN                SETSIM    221
         IF (RECORD) WRITE(IREC,'(A)') 'SIMULA '                        SETSIM    222
         CALL SIMULA                                                    SETSIM    223
      ELSE IF (STRING(1:1).EQ.'Q'.OR.STRING(1:1).EQ.'q') THEN           SETSIM    224
         RETURN                                                         SETSIM    225
      ELSE IF (STRING(1:1).NE.'N'.AND.STRING(1:1).NE.'n') THEN          SETSIM    226
         GOTO 300                                                       SETSIM    227
      ELSE                                                              SETSIM    228
         GOTO 510                                                       SETSIM    229
      END IF                                                            SETSIM    230
C                                                                       SETSIM    231
      RETURN                                                            SETSIM    232
C                                                                       SETSIM    233
  500 CONTINUE                                                          SETSIM    234
C                                                                       SETSIM    235
      WRITE(LOUT,5000)                                                  SETSIM    236
      MSG=' ETMSP TERMINATED WITH NO INITIALIZATION'                    SETSIM    237
      CALL ASTOP(MSG,40)                                                SETSIM    238
C                                                                       SETSIM    239
  510 CONTINUE                                                          SETSIM    240
C                                                                       SETSIM    241
      WRITE(LOUT,5010)                                                  SETSIM    242
      IF (RECORD)CALL CLOSEF(IREC)                                      SETSIM    243
      MSG=' ETMSP TERMINATED WITH INITIALIZATION ONLY'                  SETSIM    244
      CALL ASTOP(MSG,42)                                                SETSIM    245
C                                                                       SETSIM    246
 1000 CONTINUE                                                          SETSIM    247
      WRITE(LOUT,5030)                                                  SETSIM    248
      MSG=' ETMSP ABNORMAL TERMINATION'                                 SETSIM    249
      CALL ASTOP(MSG,27)                                                SETSIM    250
C                                                                       SETSIM    251
 5000 FORMAT(//,                                                        SETSIM    252
     110X,'....................................................',/,     SETSIM    253
     210X,':  -- ETMSP TERMINATION WITH NO INITIALIZATION--   :',/,     SETSIM    254
     310X,':..................................................:',//)    SETSIM    255
 5010 FORMAT(//,                                                        SETSIM    256
     110X,'.................................................',/,        SETSIM    257
     210X,':  -- ETMSP TERMINATION WITH INITIALIZATION--   :',/,        SETSIM    258
     310X,':...............................................:',//)       SETSIM    259
 5020 FORMAT(/,1X,'** DEBUG (GOTOS) ** ',A8,2X,A)                       SETSIM    260
 5030 FORMAT(//,                                                        SETSIM    261
     110X,'.......................................',/,                  SETSIM    262
     210X,':  -- ETMSP ABNORMAL TERMINATION --   :',/,                  SETSIM    263
     310X,':.....................................:',//)                 SETSIM    264
      END                                                               SETSIM    265
