CFPRIME SETUP                                                           SETUP       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 SETUP(IEBK)                                            SETUP       3
CD                                                                      SETUP       4
CD    TO OPEN WARNING/ERROR MESSAGE, DATA, SIMULATION FILES AND PRINT   SETUP       5
CD    HEADING PAGE OF PROGRESS REPORT AND WARNING/ERROR MESSAGE REPORT. SETUP       6
CD                                                                      SETUP       7
      INCLUDE 'CNLSTA.INS'                                              SETUP       8
      INCLUDE 'CNUNIT.INS'                                              SETUP       9
      INCLUDE 'CNFLAG.INS'                                              SETUP      10
      INCLUDE 'CNLUN.INS'                                               SETUP      11
      INCLUDE 'CNMSG.INS'                                               SETUP      12
C                                                                       SETUP      13
      CHARACTER*7 SUBPMT                                                SETUP      14
      CHARACTER*50 FILENA                                               SETUP      15
      CHARACTER*80 EMSG,STRING                                          SETUP      16
C                                                                       SETUP      17
      LOGICAL LCASE                                                     SETUP      18
C                                                                       SETUP      19
      DATA FILENA/'                                                  '/ SETUP      20
      DATA SUBPMT/' SETUP '/                                            SETUP      21
C                                                                       SETUP      22
      LDEB=.FALSE.                                                      SETUP      23
      IEBK=0                                                            SETUP      24
      MEMOUT=0                                                          SETUP      25
      IPAGE=0                                                           SETUP      26
      IL=61                                                             SETUP      27
C                                                                       SETUP      28
 110   CONTINUE                                                         SETUP      29
       MEMOUT=MEMOUT+1                                                  SETUP      30
       IF(MEMOUT.GT.5)THEN                                              SETUP      31
         WRITE(LOUT,1000)                                               SETUP      32
         IEBK=1                                                         SETUP      33
         RETURN                                                         SETUP      34
       ENDIF                                                            SETUP      35
C                                                                       SETUP      36
       EMSG='ENTER THE OUTPUT FILE NAME (WITHOUT EXTENSION NAME):'      SETUP      37
       LMSG=52                                                          SETUP      38
       CALL REDLIN(LOUT,LIN,JERR,LMSG,EMSG,SUBPMT,'FIL',STRING,RECORD   SETUP      39
     *,IREC,KLAYER,KEND,KREAD,PLAYBA)                                   SETUP      40
       IF (JERR.LT.0) THEN                                              SETUP      41
          WRITE(LOUT,5000)                                              SETUP      42
          KREAD=.TRUE.                                                  SETUP      43
          GOTO 110                                                      SETUP      44
       END IF                                                           SETUP      45
       IF (STRING(1:4).EQ.'QUIT'.OR.STRING(1:5).EQ.'ABORT'.OR.          SETUP      46
     1 STRING(1:4).EQ.'quit'.OR.STRING(1:5).EQ.'abort') THEN            SETUP      47
          IEBK=2                                                        SETUP      48
          RETURN                                                        SETUP      49
       ELSEIF(STRING(1:4).EQ.'FRUN'.OR.STRING(1:4).EQ.'frun')THEN       SETUP      50
         CFLRUN=.TRUE.                                                  SETUP      51
         RETURN                                                         SETUP      52
       END IF                                                           SETUP      53
C                                                                       SETUP      54
       I=0                                                              SETUP      55
       DO 120 J=1,80                                                    SETUP      56
          IF(I.EQ.0)THEN                                                SETUP      57
             IF(STRING(J:J).EQ.' ') GOTO 120                            SETUP      58
             I=J                                                        SETUP      59
          ENDIF                                                         SETUP      60
          IF(STRING(J:J).GE.'A'.AND.STRING(J:J).LE.'Z')THEN             SETUP      61
             LCASE=.FALSE.                                              SETUP      62
          ELSEIF(STRING(J:J).GE.'a'.AND.STRING(J:J).LE.'z')THEN         SETUP      63
             LCASE=.TRUE.                                               SETUP      64
          ELSEIF(STRING(J:J).NE.' ')THEN                                SETUP      65
             GOTO 120                                                   SETUP      66
          ENDIF                                                         SETUP      67
          GOTO 140                                                      SETUP      68
 120   CONTINUE                                                         SETUP      69
       GOTO 110                                                         SETUP      70
C                                                                       SETUP      71
 140   CONTINUE                                                         SETUP      72
       FILENA=STRING(I:I+49)                                            SETUP      73
       CALL PARSIU(FILENA,LENFIL,IU,LO)                                 SETUP      74
C                                                                       SETUP      75
       IF(IU.GT.0)THEN                                                  SETUP      76
         LENFIL=LO                                                      SETUP      77
         STRING(1:LENFIL)=FILENA(1:LENFIL)                              SETUP      78
         IU16=IU                                                        SETUP      79
         CALL FBOKEP(IU16,IBACK)                                        SETUP      80
         IF(IBACK.LT.0)THEN                                             SETUP      81
           WRITE(LOUT,1100)                                             SETUP      82
           RETURN                                                       SETUP      83
         ENDIF                                                          SETUP      84
 142     IU=IU+1                                                        SETUP      85
         IU6=IU                                                         SETUP      86
         CALL FBOKEP(IU6,IBACK)                                         SETUP      87
         IF(IBACK.LT.0) GOTO 142                                        SETUP      88
C 143     IU=IU+1                                                       SETUP      89
C         IU17=IU                                                       SETUP      90
C         CALL FBOKEP(IU17,IBACK)                                       SETUP      91
C         IF(IBACK.LT.0) GOTO 143                                       SETUP      92
 144     IU=IU+1                                                        SETUP      93
         IU8=IU                                                         SETUP      94
         CALL FBOKEP(IU8,IBACK)                                         SETUP      95
         IF(IBACK.LT.0) GOTO 144                                        SETUP      96
       ELSEIF(IU.LT.0)THEN                                              SETUP      97
         KREAD=.TRUE.                                                   SETUP      98
         GOTO 110                                                       SETUP      99
       ENDIF                                                            SETUP     100
C                                                                       SETUP     101
       I1=INDEX(FILENA,' ')                                             SETUP     102
       IF(LCASE)THEN                                                    SETUP     103
          FILENA(I1:I1+3)='.msg'                                        SETUP     104
       ELSE                                                             SETUP     105
          FILENA(I1:I1+3)='.MSG'                                        SETUP     106
       ENDIF                                                            SETUP     107
       LO=I1+3                                                          SETUP     108
C                                                                       SETUP     109
       IKEY=6                                                           SETUP     110
       JLENG=133                                                        SETUP     111
       CALL OPENRE(IU16,FILENA,JLENG,IKEY,ISTAT,LO)                     SETUP     112
C                                                                       SETUP     113
       IF(ISTAT.NE.0)THEN                                               SETUP     114
          WRITE(LOUT,'(/A/)')                                           SETUP     115
     *    ' *** ERROR IN OPENING WARNING AND ERROR MESSAGES REPORT'     SETUP     116
          GOTO 110                                                      SETUP     117
       ELSE                                                             SETUP     118
          LUNITS(IU16)=.TRUE.                                           SETUP     119
       ENDIF                                                            SETUP     120
C                                                                       SETUP     121
      EMSG='WARNING AND ERROR MESSAGES REPORT'                          SETUP     122
      LMSG=33                                                           SETUP     123
      CALL PHEAD(IU16,LMSG,EMSG)                                        SETUP     124
C                                                                       SETUP     125
      IF(LCASE)THEN                                                     SETUP     126
         FILENA(I1:I1+3)='.prg'                                         SETUP     127
      ELSE                                                              SETUP     128
         FILENA(I1:I1+3)='.PRG'                                         SETUP     129
      ENDIF                                                             SETUP     130
C                                                                       SETUP     131
C                                                                       SETUP     132
       IKEY=6                                                           SETUP     133
       JLENG=133                                                        SETUP     134
       CALL OPENRE(IU6,FILENA,JLENG,IKEY,ISTAT,LO)                      SETUP     135
C                                                                       SETUP     136
       IF(ISTAT.NE.0)THEN                                               SETUP     137
          MSG(1)=' *** ERROR IN OPENING PROGRAM PROGRESS REPORT'        SETUP     138
          CALL PRTMSG(1)                                                SETUP     139
          GOTO 110                                                      SETUP     140
       ELSE                                                             SETUP     141
          LUNITS(IU6)=.TRUE.                                            SETUP     142
       ENDIF                                                            SETUP     143
C                                                                       SETUP     144
C      IF(LCASE)THEN                                                    SETUP     145
C         FILENA(I1:I1+3)='.res'                                        SETUP     146
C      ELSE                                                             SETUP     147
C         FILENA(I1:I1+3)='.RES'                                        SETUP     148
C      ENDIF                                                            SETUP     149
C                                                                       SETUP     150
C       IKEY=6                                                          SETUP     151
C       JLENG=133                                                       SETUP     152
C       CALL OPENRE(IU17,FILENA,JLENG,IKEY,ISTAT,LO)                    SETUP     153
C                                                                       SETUP     154
C       IF(ISTAT.NE.0)THEN                                              SETUP     155
C          MSG(1)=' *** ERROR IN OPENING SIMULATION RESULT REPORT'      SETUP     156
C          CALL PRTMSG(1)                                               SETUP     157
C          GOTO 110                                                     SETUP     158
C       ELSE                                                            SETUP     159
C          LUNITS(IU17)=.TRUE.                                          SETUP     160
C       ENDIF                                                           SETUP     161
C                                                                       SETUP     162
      IF(LCASE)THEN                                                     SETUP     163
         FILENA(I1:I1+3)='.bin'                                         SETUP     164
      ELSE                                                              SETUP     165
         FILENA(I1:I1+3)='.BIN'                                         SETUP     166
      ENDIF                                                             SETUP     167
C                                                                       SETUP     168
       IKEY=5                                                           SETUP     169
       JLENG=128                                                        SETUP     170
       CALL OPENRE(IU8,FILENA,JLENG,IKEY,ISTAT,LO)                      SETUP     171
C                                                                       SETUP     172
       IF(ISTAT.NE.0)THEN                                               SETUP     173
          MSG(1)=' *** ERROR IN OPENING SIMULATION RESULT BINARY FILE'  SETUP     174
          CALL PRTMSG(1)                                                SETUP     175
          GOTO 110                                                      SETUP     176
       ELSE                                                             SETUP     177
          LUNITS(IU8)=.TRUE.                                            SETUP     178
       ENDIF                                                            SETUP     179
C                                                                       SETUP     180
      IF(LCASE)THEN                                                     SETUP     181
C      WRITE(LOUT,2000) FILENA(1:I1)//'msg',IU16,FILENA(1:I1)//'prg',IU6SETUP     182
C     *                ,FILENA(1:I1)//'res',IU17,FILENA(1:LO),IU8       SETUP     183
      WRITE(LOUT,2000) FILENA(1:I1)//'msg',IU16,FILENA(1:I1)//'prg',IU6 SETUP     184
     *                ,FILENA(1:LO),IU8                                 SETUP     185
      ELSE                                                              SETUP     186
C      WRITE(LOUT,2000) FILENA(1:I1)//'MSG',IU16,FILENA(1:I1)//'PRG',IU6SETUP     187
C     *                ,FILENA(1:I1)//'RES',IU17,FILENA(1:LO),IU8       SETUP     188
      WRITE(LOUT,2000) FILENA(1:I1)//'MSG',IU16,FILENA(1:I1)//'PRG',IU6 SETUP     189
     *                ,FILENA(1:LO),IU8                                 SETUP     190
      ENDIF                                                             SETUP     191
C                                                                       SETUP     192
      EMSG='PROGRAM PROGRESS REPORT'                                    SETUP     193
      LMSG=23                                                           SETUP     194
      CALL PHEAD(IU6,LMSG,EMSG)                                         SETUP     195
C                                                                       SETUP     196
      RETURN                                                            SETUP     197
C                                                                       SETUP     198
 1000 FORMAT(//,                                                        SETUP     199
     1  10X,'......................................',/,                 SETUP     200
     1  10X,':  -- TOO MANY INVALID FILE NAME --  :',/,                 SETUP     201
     1  10X,':....................................:',//)                SETUP     202
 1100 FORMAT(/,' LOGICAL UNIT NUMBER ',I2,' ALREADY IN USE',/)          SETUP     203
 2000 FORMAT(/,' OUTPUT FILES OPENED:',//                               SETUP     204
     *,'   WARNING AND ERROR MESSAGES REPORT :  ',A                     SETUP     205
     *,'   LUNIT <',I2,'>',/                                            SETUP     206
     *,'          SIMULATION PROGRESS REPORT :  ',A                     SETUP     207
     *,'   LUNIT <',I2,'>',/                                            SETUP     208
C     *,'            SIMULATION RESULT REPORT :  ',A                    SETUP     209
C     *,'   LUNIT <',I2,'>',/                                           SETUP     210
     *,'       SIMULATION RESULT BINARY FILE :  ',A                     SETUP     211
     *,'   LUNIT <',I2,'>',/)                                           SETUP     212
 5000 FORMAT(//,                                                        SETUP     213
     1  10X,'......................................',/,                 SETUP     214
     1  10X,':       -- FILE NAME ERROR --        :',/,                 SETUP     215
     1  10X,':....................................:',//)                SETUP     216
C                                                                       SETUP     217
      END                                                               SETUP     218
