CFPRIME DAIWR4                                                          DAIWR4      1
C***********************************************************************RIGHTE      1
C*                                                                     *RIGHTE      2
C*               Output Analysis Program for ETMSP (OAP)               *RIGHTE      4
C*               =======================================               *RIGHTE      5
C*                                                                     *RIGHTE     11
C*        copyright @(1993) Electric Power Research Institute          *RIGHTE     12
C*                                                                     *RIGHTE     13
C* EPRI reserves all rights in the software and associated             *RIGHTE     14
C* documentation as delivered. The software and its associated         *RIGHTE     15
C* documention or any portion thereof may not be reproduced in any form*RIGHTE     16
C* whatsoever without the consent of EPRI, except as explicity provided*RIGHTE     17
C* for by license. Licensee shall submit a detailed description to EPRI*RIGHTE     18
C* of any changes or modifications to the software within two (2)      *RIGHTE     19
C* months after such changes or modifications are made. At EPRI's sole *RIGHTE     20
C* discretion, the software, as changed or modified, shall be given a  *RIGHTE     21
C* new designation sufficiently different from its then current        *RIGHTE     22
C* designation as to prevent mistake,confusion, or deception as between*RIGHTE     23
C* the current software as changed or modified.                        *RIGHTE     24
C*                                                                     *RIGHTE     25
C* A license under EPRI's rights in the software can be obtained       *RIGHTE     26
C* directly from EPRI.                                                 *RIGHTE     27
C*                                                                     *RIGHTE     28
C* This program and supporting materials may be independently available*RIGHTE     29
C* from Electric Power Software centre (EPSC) for an appropriate       *RIGHTE     30
C* distribution fee. The EPSC is a service of                          *RIGHTE     31
C*                                                                     *RIGHTE     32
C*                    Power Computing Company                          *RIGHTE     33
C*                    1930 Hi Line                                     *RIGHTE     34
C*                    Dallas, Tx 75207                                 *RIGHTE     35
C*                                                                     *RIGHTE     36
C* NEITHER EPRI, ANY MEMBER OF EPRI, NOR ANY PERSON OR  ORGANIZATION   *RIGHTE     37
C* ACTING ON BEHAVE OF THEM:                                           *RIGHTE     38
C*                                                                     *RIGHTE     39
C* 1. MAKE ANY WARRANTY OR REPRESENTATION WHATSOEVER, EXPRESS OR       *RIGHTE     40
C*    IMPLIED, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR FITNESS OR *RIGHTE     41
C*    ANY PURPOSE WITH RESPECT TO THE SOFTWARE OR ITS ASSOCIATED       *RIGHTE     42
C*    DOCUMENTATION; OR                                                *RIGHTE     43
C*                                                                     *RIGHTE     44
C* 2. ASSUMES ANY LIABILITY WHATSOEVER WITH RESPECT TO ANY USE OF THE  *RIGHTE     45
C*    SOFTWARE OR ITS ASSOCIATED DOCUMENTATION OR ANY PORTION THEREOF  *RIGHTE     46
C*    OR WITH RESPECT TO ANY DAMAGES WHICH MAY RESULT FROM SUCH USE.   *RIGHTE     47
C*                                                                     *RIGHTE     48
C* THIS NOTICE MAY NOT BE REMOVED FROM THE SOFTWARE BY ANY USER        *RIGHTE     49
C* THEREOF.                                                            *RIGHTE     50
C*                                                                     *RIGHTE     51
C***********************************************************************RIGHTE     52
      SUBROUTINE DAIWR4(IUNIT,N,NREC,IARRAY,LENG,IEND)                  DAIWR4      3
CD                                                                      DAIWR4      4
CD             THE ROUTINE PERFORMS DIRECT ACCESS READ OR WRITE         DAIWR4      5
CD             OF AN INTEGER*4 ARRAY                                    DAIWR4      6
CD                                                                      DAIWR4      7
CD             CALLING PARAMETERS :                                     DAIWR4      8
CD                                                                      DAIWR4      9
CD                         IUNIT  : LOGICAL UNIT                        DAIWR4     10
CD                         N      : FLAG INDICATING READ OR WRITE       DAIWR4     11
CD                                  0 : READ    ; 1 : WRITE             DAIWR4     12
CD                         NREC   : RECORD NUMBER                       DAIWR4     13
CD                         IARRAY : INTEGER ARRAY TO BE READ IN OR      DAIWR4     14
CD                                  WRITTEN INTO                        DAIWR4     15
CD                         LENG   : DIMENSION OF THE ARRAY IARRAY       DAIWR4     16
CD                         IEND   : LOGICAL INDICATING THE COMPLETION   DAIWR4     17
CD                                  READ OR WRITE PROCESS               DAIWR4     18
CD                                                                      DAIWR4     19
      INTEGER*4 IARRAY(LENG)                                            DAIWR4     20
      LOGICAL IEND                                                      DAIWR4     21
      IEND=.FALSE.                                                      DAIWR4     22
      IF(N.EQ.0)THEN                                                    DAIWR4     23
         WRITE(IUNIT,REC=NREC) IARRAY                                   DAIWR4     24
      ELSE                                                              DAIWR4     25
         READ(IUNIT,REC=NREC,IOSTAT=IOS) IARRAY                         DAIWR4     26
         IF(IOS.NE.0) GOTO 100                                          DAIWR4     27
      ENDIF                                                             DAIWR4     28
      NREC=NREC+1                                                       DAIWR4     29
      RETURN                                                            DAIWR4     30
 100  CONTINUE                                                          DAIWR4     31
      IEND=.TRUE.                                                       DAIWR4     32
      RETURN                                                            DAIWR4     33
      END                                                               DAIWR4     34
                                                                        DAIWR4     35
      SUBROUTINE IHWR (IUNIT,IMODE,ITEM,IARRAY)                         DAIWR4     36
CD                                                                      DAIWR4     37
CD           THIS ROUTINE READS OR WRITES OF AN INTEGER*2 ARRAY         DAIWR4     38
CD                                                                      DAIWR4     39
CD             CALLING PARAMETERS :                                     DAIWR4     40
CD                                                                      DAIWR4     41
CD                         IUNIT  : LOGICAL UNIT                        DAIWR4     42
CD                         IMODE  : FLAG INDICATING READ OR WRITE       DAIWR4     43
CD                                  0 : READ    ; 1 : WRITE             DAIWR4     44
CD                         ITEM   : DIMENSION OF THE ARRAY IARRAY       DAIWR4     45
CD                         IARRAY : INTEGER ARRAY TO BE READ IN OR      DAIWR4     46
CD                                  WRITTEN INTO                        DAIWR4     47
CD                                                                      DAIWR4     48
      INTEGER*2 IARRAY(ITEM)                                            DAIWR4     49
      IF(IMODE.EQ.0)THEN                                                DAIWR4     50
      WRITE(IUNIT) IARRAY                                               DAIWR4     51
      ELSE                                                              DAIWR4     52
      READ (IUNIT) IARRAY                                               DAIWR4     53
      ENDIF                                                             DAIWR4     54
      RETURN                                                            DAIWR4     55
      END                                                               DAIWR4     56
                                                                        DAIWR4     57
      SUBROUTINE IFWR (IUNIT,IMODE,ITEM,IARRAY)                         DAIWR4     58
CD                                                                      DAIWR4     59
CD           THIS ROUTINE READS OR WRITES OF AN INTEGER*4 ARRAY         DAIWR4     60
CD                                                                      DAIWR4     61
CD             CALLING PARAMETERS :                                     DAIWR4     62
CD                                                                      DAIWR4     63
CD                         IUNIT  : LOGICAL UNIT                        DAIWR4     64
CD                         IMODE  : FLAG INDICATING READ OR WRITE       DAIWR4     65
CD                                  0 : READ    ; 1 : WRITE             DAIWR4     66
CD                         ITEM   : DIMENSION OF THE ARRAY IARRAY       DAIWR4     67
CD                         IARRAY : INTEGER ARRAY TO BE READ IN OR      DAIWR4     68
CD                                  WRITTEN INTO                        DAIWR4     69
CD                                                                      DAIWR4     70
      INTEGER IARRAY(ITEM)                                              DAIWR4     71
      IF(IMODE.EQ.0)THEN                                                DAIWR4     72
      WRITE(IUNIT) IARRAY                                               DAIWR4     73
      ELSE                                                              DAIWR4     74
      READ (IUNIT) IARRAY                                               DAIWR4     75
      ENDIF                                                             DAIWR4     76
      RETURN                                                            DAIWR4     77
      END                                                               DAIWR4     78
                                                                        DAIWR4     79
      SUBROUTINE FLWR (IUNIT,IMODE,ITEM,ARRAY)                          DAIWR4     80
CD                                                                      DAIWR4     81
CD              THIS ROUTINE READS OR WRITES OF A REAL*4 ARRAY          DAIWR4     82
CD                                                                      DAIWR4     83
CD             CALLING PARAMETERS :                                     DAIWR4     84
CD                                                                      DAIWR4     85
CD                         IUNIT  : LOGICAL UNIT                        DAIWR4     86
CD                         IMODE  : FLAG INDICATING READ OR WRITE       DAIWR4     87
CD                                  0 : READ    ; 1 : WRITE             DAIWR4     88
CD                         ITEM   : DIMENSION OF THE ARRAY IARRAY       DAIWR4     89
CD                         ARRAY  : REAL ARRAY TO BE READ IN OR         DAIWR4     90
CD                                  WRITTEN INTO                        DAIWR4     91
CD                                                                      DAIWR4     92
      DIMENSION ARRAY(ITEM)                                             DAIWR4     93
      IF(IMODE.EQ.0)THEN                                                DAIWR4     94
      WRITE(IUNIT) ARRAY                                                DAIWR4     95
      ELSE                                                              DAIWR4     96
      READ (IUNIT) ARRAY                                                DAIWR4     97
      ENDIF                                                             DAIWR4     98
      RETURN                                                            DAIWR4     99
      END                                                               DAIWR4    100
                                                                        DAIWR4    101
      SUBROUTINE FL2WR (IUNIT,IMODE,ITEM,ARRAY)                         DAIWR4    102
CD                                                                      DAIWR4    103
CD            THIS ROUTINE READS OR WRITES OF A REAL*4                  DAIWR4    104
CD            TWO-DIMENSION ARRAY                                       DAIWR4    105
CD                                                                      DAIWR4    106
CD             CALLING PARAMETERS :                                     DAIWR4    107
CD                                                                      DAIWR4    108
CD                         IUNIT  : LOGICAL UNIT                        DAIWR4    109
CD                         IMODE  : FLAG INDICATING READ OR WRITE       DAIWR4    110
CD                                  0 : READ    ; 1 : WRITE             DAIWR4    111
CD                         ITEM   : DIMENSION OF THE ARRAY IARRAY       DAIWR4    112
CD                         ARRAY  : REAL ARRAY TO BE READ IN OR         DAIWR4    113
CD                                  WRITTEN INTO                        DAIWR4    114
CD                                                                      DAIWR4    115
      DIMENSION ARRAY(2,ITEM)                                           DAIWR4    116
      IF(IMODE.EQ.0)THEN                                                DAIWR4    117
      WRITE(IUNIT) ARRAY                                                DAIWR4    118
      ELSE                                                              DAIWR4    119
      READ (IUNIT) ARRAY                                                DAIWR4    120
      ENDIF                                                             DAIWR4    121
      RETURN                                                            DAIWR4    122
      END                                                               DAIWR4    123
                                                                        DAIWR4    124
      SUBROUTINE CMPWR (IUNIT,IMODE,ITEM,ARRAY)                         DAIWR4    125
CD                                                                      DAIWR4    126
CD        THIS ROUTINE READS OR WRITES OF A COMPLEX ARRAY               DAIWR4    127
CD                                                                      DAIWR4    128
CD             CALLING PARAMETERS :                                     DAIWR4    129
CD                                                                      DAIWR4    130
CD                         IUNIT  : LOGICAL UNIT                        DAIWR4    131
CD                         IMODE  : FLAG INDICATING READ OR WRITE       DAIWR4    132
CD                                  0 : READ    ; 1 : WRITE             DAIWR4    133
CD                         ITEM   : DIMENSION OF THE ARRAY IARRAY       DAIWR4    134
CD                         ARRAY  : COMPLEX ARRAY TO BE READ IN OR      DAIWR4    135
CD                                  WRITTEN INTO                        DAIWR4    136
CD                                                                      DAIWR4    137
CD                                                                      DAIWR4    138
      COMPLEX ARRAY(ITEM)                                               DAIWR4    139
      IF(IMODE.EQ.0)THEN                                                DAIWR4    140
      WRITE(IUNIT) ARRAY                                                DAIWR4    141
      ELSE                                                              DAIWR4    142
      READ (IUNIT) ARRAY                                                DAIWR4    143
      ENDIF                                                             DAIWR4    144
      RETURN                                                            DAIWR4    145
      END                                                               DAIWR4    146
                                                                        DAIWR4    147
      SUBROUTINE DAFLWR(IUNIT,N,NREC,ARRAY,LENG,IEND)                   DAIWR4    148
CD                                                                      DAIWR4    149
CD           THIS ROUTINE PERFORMS DIRECT ACCESS READ OR                DAIWR4    150
CD           WRITE OF A REAL*4 ARRAY                                    DAIWR4    151
CD                                                                      DAIWR4    152
CD             CALLING PARAMETERS :                                     DAIWR4    153
CD                                                                      DAIWR4    154
CD                         IUNIT  : LOGICAL UNIT                        DAIWR4    155
CD                         N      : FLAG INDICATING READ OR WRITE       DAIWR4    156
CD                                  0 : READ    ; 1 : WRITE             DAIWR4    157
CD                         NREC   : RECORD NUMBER                       DAIWR4    158
CD                         IARRAY : INTEGER ARRAY TO BE READ IN OR      DAIWR4    159
CD                                  WRITTEN INTO                        DAIWR4    160
CD                         LENG   : DIMENSION OF THE ARRAY IARRAY       DAIWR4    161
CD                         IEND   : LOGICAL INDICATING THE COMPLETION   DAIWR4    162
CD                                  READ OR WRITE PROCESS               DAIWR4    163
CD                                                                      DAIWR4    164
      DIMENSION ARRAY(LENG)                                             DAIWR4    165
      INCLUDE 'DBFLG.INS'                                               DAIWR4    166
      LOGICAL IEND                                                      DAIWR4    167
      LDEBUG=DEBUG(12)                                                  DAIWR4    168
      IEND=.FALSE.                                                      DAIWR4    169
      IF(N.EQ.0)THEN                                                    DAIWR4    170
         WRITE(IUNIT,REC=NREC) ARRAY                                    DAIWR4    171
      ELSE                                                              DAIWR4    172
         READ(IUNIT,REC=NREC,IOSTAT=IOS) ARRAY                          DAIWR4    173
         IF(IOS.NE.0) GOTO 100                                          DAIWR4    174
         IF(LDEBUG) THEN                                                DAIWR4    175
            PRINT*,' DEBUG WRITE TO UNIT 99. CONTROL Y TO ABORT'        DAIWR4    176
            WRITE(99,*)'  +++++++++++++++++++++++++++++++++++++'        DAIWR4    177
            WRITE(99,*) ARRAY                                           DAIWR4    178
            WRITE(99,*)'  '                                             DAIWR4    179
         ENDIF                                                          DAIWR4    180
      ENDIF                                                             DAIWR4    181
      NREC=NREC+1                                                       DAIWR4    182
      RETURN                                                            DAIWR4    183
 100  CONTINUE                                                          DAIWR4    184
      IEND=.TRUE.                                                       DAIWR4    185
      RETURN                                                            DAIWR4    186
      END                                                               DAIWR4    187
                                                                        DAIWR4    188
      SUBROUTINE DAIWR(IUNIT,N,NREC,IARRAY,LENG,IEND)                   DAIWR4    189
CD                                                                      DAIWR4    190
CD        THIS ROUTINE PERFORMS DIRECT ACCESS READ OR                   DAIWR4    191
CD        WRITE OF AN INTEGER*2 ARRAY                                   DAIWR4    192
CD                                                                      DAIWR4    193
CD             CALLING PARAMETERS :                                     DAIWR4    194
CD                                                                      DAIWR4    195
CD                         IUNIT  : LOGICAL UNIT                        DAIWR4    196
CD                         N      : FLAG INDICATING READ OR WRITE       DAIWR4    197
CD                                  0 : READ    ; 1 : WRITE             DAIWR4    198
CD                         NREC   : RECORD NUMBER                       DAIWR4    199
CD                         IARRAY : INTEGER ARRAY TO BE READ IN OR      DAIWR4    200
CD                                  WRITTEN INTO                        DAIWR4    201
CD                         LENG   : DIMENSION OF THE ARRAY IARRAY       DAIWR4    202
CD                         IEND   : LOGICAL INDICATING THE COMPLETION   DAIWR4    203
CD                                  READ OR WRITE PROCESS               DAIWR4    204
CD                                                                      DAIWR4    205
      INTEGER*2 IARRAY(LENG)                                            DAIWR4    206
      LOGICAL IEND                                                      DAIWR4    207
      IEND=.FALSE.                                                      DAIWR4    208
      IF(N.EQ.0)THEN                                                    DAIWR4    209
         WRITE(IUNIT,REC=NREC) IARRAY                                   DAIWR4    210
      ELSE                                                              DAIWR4    211
         READ(IUNIT,REC=NREC,IOSTAT=IOS) IARRAY                         DAIWR4    212
         IF(IOS.NE.0) GOTO 100                                          DAIWR4    213
      ENDIF                                                             DAIWR4    214
      NREC=NREC+1                                                       DAIWR4    215
      RETURN                                                            DAIWR4    216
 100  CONTINUE                                                          DAIWR4    217
      IEND=.TRUE.                                                       DAIWR4    218
      RETURN                                                            DAIWR4    219
      END                                                               DAIWR4    220
                                                                        DAIWR4    221
