CFPRIME ICURHL                                                          ICURHL      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 ICURHL                                                 ICURHL      3
CD                                                                      ICURHL      4
CD THIS ROUTINE INITIALIZE ARRAYS TO FIND THE HIGH LOW OF A TIME CURVE  ICURHL      5
CD                                                                      ICURHL      6
      INCLUDE 'PARX.INS'                                                ICURHL      7
      INCLUDE 'CNPT.INS'                                                ICURHL      8
      INCLUDE 'CNB8.INS'                                                ICURHL      9
      INCLUDE 'CNMSTA.INS'                                              ICURHL     10
      INCLUDE 'CNMYVA.INS'                                              ICURHL     11
      INCLUDE 'CNYVAR.INS'                                              ICURHL     12
      INCLUDE 'CNMDAT.INS'                                              ICURHL     13
      INCLUDE 'CNVOLT.INS'                                              ICURHL     14
      INCLUDE 'CNB4.INS'                                                ICURHL     15
      INCLUDE 'CNCVHL.INS'                                              ICURHL     16
      INCLUDE 'CNSPC0.INS'                                              ICURHL     17
      INCLUDE 'CNSPVI.INS'                                              ICURHL     18
      INCLUDE 'CNSPC1.INS'                                              ICURHL     19
C                                                                       ICURHL     20
C                                                                       ICURHL     21
      DO 100 K=1,LASTV2                                                 ICURHL     22
      VREAL=REAL(VOLT(K))                                               ICURHL     23
      VIMAG=AIMAG(VOLT(K))                                              ICURHL     24
      VMG2=VREAL**2+VIMAG**2                                            ICURHL     25
      VOLTHL(1,K)=VMG2                                                  ICURHL     26
      VOLTHL(2,K)=0                                                     ICURHL     27
      VOLTHL(3,K)=VMG2                                                  ICURHL     28
      VOLTHL(4,K)=0                                                     ICURHL     29
      VOLTHL(5,K)=VMG2                                                  ICURHL     30
 100  CONTINUE                                                          ICURHL     31
C                                                                       ICURHL     32
      NVADD=0                                                           ICURHL     33
      DO 120 I=1,NOROWV                                                 ICURHL     34
      M=NOROV(I)                                                        ICURHL     35
      K=IBUSO(M)                                                        ICURHL     36
      IF(K.LE.LASTV2)GOTO 120                                           ICURHL     37
      NVADD=NVADD+1                                                     ICURHL     38
      IVADD(NVADD)=K                                                    ICURHL     39
      VREAL=REAL(VOLT(K))                                               ICURHL     40
      VIMAG=AIMAG(VOLT(K))                                              ICURHL     41
      VMG2=VREAL**2+VIMAG**2                                            ICURHL     42
      VOLTHL(1,LASTV2+NVADD)=VMG2                                       ICURHL     43
      VOLTHL(2,LASTV2+NVADD)=0                                          ICURHL     44
      VOLTHL(3,LASTV2+NVADD)=VMG2                                       ICURHL     45
      VOLTHL(4,LASTV2+NVADD)=0                                          ICURHL     46
      VOLTHL(5,LASTV2+NVADD)=VMG2                                       ICURHL     47
 120  CONTINUE                                                          ICURHL     48
C                                                                       ICURHL     49
      DO 200 N=1,NT                                                     ICURHL     50
      JG=JCONTA(1,N)                                                    ICURHL     51
      IF(DDAT(JG+1).LT.1.0E-5)GOTO 200                                  ICURHL     52
CD                                                                      ICURHL     53
CD 2. INITIALIZE GENERATORS WITH LOWEST AND HIGHEST FREQUENCY DEVIATION ICURHL     54
CD                                                                      ICURHL     55
      GFREQ(1,N)=0.0                                                    ICURHL     56
      GFREQ(2,N)=0.0                                                    ICURHL     57
      GFREQ(3,N)=0.0                                                    ICURHL     58
      GFREQ(4,N)=0.0                                                    ICURHL     59
CD                                                                      ICURHL     60
CD                                                                      ICURHL     61
CD 3. INITIALIZE GENERATORS HIGHEST/LOWEST ACCERATION POWER             ICURHL     62
CD                                                                      ICURHL     63
      GACCEL(1,N)=0.0                                                   ICURHL     64
      GACCEL(2,N)=0.0                                                   ICURHL     65
      GACCEL(3,N)=0.0                                                   ICURHL     66
      GACCEL(4,N)=0.0                                                   ICURHL     67
C                                                                       ICURHL     68
      IGENS=ICONTA(1,N)                                                 ICURHL     69
      IF(IGENS.NE.4)THEN                                                ICURHL     70
CD                                                                      ICURHL     71
CD 4. INITIALIZE DETAILED GENERATORS WITH HISHEST/LOWEST FIELD VOLTAGE  ICURHL     72
CD                                                                      ICURHL     73
      JYG=MYVAR(1,N)                                                    ICURHL     74
      XVALUE=EFD(JYG+4)                                                 ICURHL     75
      GFVOLT(1,N)=XVALUE                                                ICURHL     76
      GFVOLT(2,N)=0.0                                                   ICURHL     77
      GFVOLT(3,N)=XVALUE                                                ICURHL     78
      GFVOLT(4,N)=0.0                                                   ICURHL     79
      GFVOLT(5,N)=XVALUE                                                ICURHL     80
      ENDIF                                                             ICURHL     81
 200  CONTINUE                                                          ICURHL     82
C                                                                       ICURHL     83
      RETURN                                                            ICURHL     84
      END                                                               ICURHL     85
C                                                                       ICURHL     86
      SUBROUTINE CURVHL                                                 ICURHL     87
CD                                                                      ICURHL     88
CD    THIS ROUTINE FINDS THE HIGH LOW OF A TIME CURVE                   ICURHL     89
CD                                                                      ICURHL     90
      INCLUDE 'PARX.INS'                                                ICURHL     91
      INCLUDE 'CNPT.INS'                                                ICURHL     92
      INCLUDE 'CNB8.INS'                                                ICURHL     93
      INCLUDE 'CNMSTA.INS'                                              ICURHL     94
      INCLUDE 'CNMYVA.INS'                                              ICURHL     95
      INCLUDE 'CNYVAR.INS'                                              ICURHL     96
      INCLUDE 'CNVOLT.INS'                                              ICURHL     97
      INCLUDE 'CNB4.INS'                                                ICURHL     98
      INCLUDE 'CNXSTA.INS'                                              ICURHL     99
      INCLUDE 'CNMDAT.INS'                                              ICURHL    100
      INCLUDE 'CNCVHL.INS'                                              ICURHL    101
      INCLUDE 'CNSPC1.INS'                                              ICURHL    102
C                                                                       ICURHL    103
CD                                                                      ICURHL    104
CD                                                                      ICURHL    105
CD    1. RANK COMPUTED BUSES WITH LOWEST AND HIGHEST VOLTAGE MAGNITUDE  ICURHL    106
CD                                                                      ICURHL    107
CD                                                                      ICURHL    108
      DO 100 K=1,LASTV2                                                 ICURHL    109
      VREAL=REAL(VOLT(K))                                               ICURHL    110
      VIMAG=AIMAG(VOLT(K))                                              ICURHL    111
      XVALUE=VREAL**2+VIMAG**2                                          ICURHL    112
      XHIGH=VOLTHL(1,K)                                                 ICURHL    113
      XLOW=VOLTHL(3,K)                                                  ICURHL    114
      IF(XVALUE.GT.XHIGH)THEN                                           ICURHL    115
      VOLTHL(1,K)=XVALUE                                                ICURHL    116
      VOLTHL(2,K)=TS                                                    ICURHL    117
      ENDIF                                                             ICURHL    118
      IF(XVALUE.LT.XLOW)THEN                                            ICURHL    119
      VOLTHL(3,K)=XVALUE                                                ICURHL    120
      VOLTHL(4,K)=TS                                                    ICURHL    121
      ENDIF                                                             ICURHL    122
 100  CONTINUE                                                          ICURHL    123
C                                                                       ICURHL    124
      DO 120 I=1,NVADD                                                  ICURHL    125
      K=IVADD(I)                                                        ICURHL    126
      VREAL=REAL(VOLT(K))                                               ICURHL    127
      VIMAG=AIMAG(VOLT(K))                                              ICURHL    128
      XVALUE=VREAL**2+VIMAG**2                                          ICURHL    129
      XHIGH=VOLTHL(1,LASTV2+I)                                          ICURHL    130
      XLOW=VOLTHL(3,LASTV2+I)                                           ICURHL    131
      IF(XVALUE.GT.XHIGH)THEN                                           ICURHL    132
      VOLTHL(1,LASTV2+I)=XVALUE                                         ICURHL    133
      VOLTHL(2,LASTV2+I)=TS                                             ICURHL    134
      ENDIF                                                             ICURHL    135
      IF(XVALUE.LT.XLOW)THEN                                            ICURHL    136
      VOLTHL(3,LASTV2+I)=XVALUE                                         ICURHL    137
      VOLTHL(4,LASTV2+I)=TS                                             ICURHL    138
      ENDIF                                                             ICURHL    139
 120  CONTINUE                                                          ICURHL    140
C                                                                       ICURHL    141
      DO 200 N=1,NT                                                     ICURHL    142
      JG=JCONTA(1,N)                                                    ICURHL    143
      IF(DDAT(JG+1).LT.1.0E-5)GOTO 200                                  ICURHL    144
CD                                                                      ICURHL    145
CD    2. RANK GENERATORS WITH LOWEST AND HIGHEST FREQUENCY DEVIATION    ICURHL    146
CD                                                                      ICURHL    147
      JSTATE=MSTATE(1,N)                                                ICURHL    148
      XVALUE=XSTATE(JSTATE+1)                                           ICURHL    149
      XHIGH=GFREQ(1,N)                                                  ICURHL    150
      XLOW=GFREQ(3,N)                                                   ICURHL    151
      IF(XVALUE.GT.XHIGH)THEN                                           ICURHL    152
      GFREQ(1,N)=XVALUE                                                 ICURHL    153
      GFREQ(2,N)=TS                                                     ICURHL    154
      ENDIF                                                             ICURHL    155
      IF(XVALUE.LT.XLOW)THEN                                            ICURHL    156
      GFREQ(3,N)=XVALUE                                                 ICURHL    157
      GFREQ(4,N)=TS                                                     ICURHL    158
      ENDIF                                                             ICURHL    159
CD                                                                      ICURHL    160
      IGENS=ICONTA(1,N)                                                 ICURHL    161
      JYG=MYVAR(1,N)                                                    ICURHL    162
      IF(IGENS.EQ.4)THEN                                                ICURHL    163
CD                                                                      ICURHL    164
CD    3. RANK CLASSICAL GENERATORS HIGHEST/LOWEST ACCERATION POWER      ICURHL    165
CD                                                                      ICURHL    166
      XVALUE=ACCP(JYG+5)                                                ICURHL    167
      XHIGH=GACCEL(1,N)                                                 ICURHL    168
      XLOW=GACCEL(3,N)                                                  ICURHL    169
      IF(XVALUE.GT.XHIGH)THEN                                           ICURHL    170
      GACCEL(1,N)=XVALUE                                                ICURHL    171
      GACCEL(2,N)=TS                                                    ICURHL    172
      ENDIF                                                             ICURHL    173
      IF(XVALUE.LT.XLOW)THEN                                            ICURHL    174
      GACCEL(3,N)=XVALUE                                                ICURHL    175
      GACCEL(4,N)=TS                                                    ICURHL    176
      ENDIF                                                             ICURHL    177
C                                                                       ICURHL    178
      ELSE                                                              ICURHL    179
CD                                                                      ICURHL    180
CD    4. RANK DETAILED GENERATORS WITH HISHEST/LOWEST FIELD VOLTAGE     ICURHL    181
CD                                                                      ICURHL    182
      XVALUE=EFD(JYG+4)                                                 ICURHL    183
      XHIGH=GFVOLT(1,N)                                                 ICURHL    184
      XLOW=GFVOLT(3,N)                                                  ICURHL    185
      IF(XVALUE.GT.XHIGH)THEN                                           ICURHL    186
      GFVOLT(1,N)=XVALUE                                                ICURHL    187
      GFVOLT(2,N)=TS                                                    ICURHL    188
      ENDIF                                                             ICURHL    189
      IF(XVALUE.LT.XLOW)THEN                                            ICURHL    190
      GFVOLT(3,N)=XVALUE                                                ICURHL    191
      GFVOLT(4,N)=TS                                                    ICURHL    192
      ENDIF                                                             ICURHL    193
CD                                                                      ICURHL    194
CD    5. RANK DETAILED GENERATORS HIGHEST/LOWEST ACCERATION POWER       ICURHL    195
CD                                                                      ICURHL    196
      XVALUE=ACCP(JYG+6)                                                ICURHL    197
      XHIGH=GACCEL(1,N)                                                 ICURHL    198
      XLOW=GACCEL(3,N)                                                  ICURHL    199
      IF(XVALUE.GT.XHIGH)THEN                                           ICURHL    200
      GACCEL(1,N)=XVALUE                                                ICURHL    201
      GACCEL(2,N)=TS                                                    ICURHL    202
      ENDIF                                                             ICURHL    203
      IF(XVALUE.LT.XLOW)THEN                                            ICURHL    204
      GACCEL(3,N)=XVALUE                                                ICURHL    205
      GACCEL(4,N)=TS                                                    ICURHL    206
      ENDIF                                                             ICURHL    207
      ENDIF                                                             ICURHL    208
 200  CONTINUE                                                          ICURHL    209
C                                                                       ICURHL    210
      RETURN                                                            ICURHL    211
      END                                                               ICURHL    212
C                                                                       ICURHL    213
      SUBROUTINE RANKVM                                                 ICURHL    214
CD                                                                      ICURHL    215
CD    THIS ROUTINE RANK BUSES/GENERATORS WITH LOWEST/HIGHEST            ICURHL    216
CD                                                                      ICURHL    217
      INCLUDE 'PARX.INS'                                                ICURHL    218
      INCLUDE 'CNPT.INS'                                                ICURHL    219
      INCLUDE 'CNB8.INS'                                                ICURHL    220
      INCLUDE 'CNMDAT.INS'                                              ICURHL    221
      INCLUDE 'CNCVHL.INS'                                              ICURHL    222
      INCLUDE 'CNHL20.INS'                                              ICURHL    223
      INCLUDE 'CNSPC1.INS'                                              ICURHL    224
C                                                                       ICURHL    225
      NHV=0                                                             ICURHL    226
      NLV=0                                                             ICURHL    227
      JHV=0                                                             ICURHL    228
      JLV=0                                                             ICURHL    229
      NHFRQ=0                                                           ICURHL    230
      NLFRQ=0                                                           ICURHL    231
      NHAP=0                                                            ICURHL    232
      NLAP=0                                                            ICURHL    233
      NHFIV=0                                                           ICURHL    234
      NLFIV=0                                                           ICURHL    235
C                                                                       ICURHL    236
      MI=MIN0(LASTV2+NVADD,20)                                          ICURHL    237
      DO 100 K=1,LASTV2                                                 ICURHL    238
      VMG2=VOLTHL(1,K)                                                  ICURHL    239
      T1=VOLTHL(2,K)                                                    ICURHL    240
      CALL RANKHV(MI,NHV,K,VMG2,T1,HVBOND,KHVBUS,HVVALU,HVTIME)         ICURHL    241
      VMG2=VOLTHL(3,K)                                                  ICURHL    242
      T1=VOLTHL(4,K)                                                    ICURHL    243
      CALL RANKLV(MI,NLV,K,VMG2,T1,VLBOND, LVBUS,VLVALU,VLTIME)         ICURHL    244
 100  CONTINUE                                                          ICURHL    245
      DO 120 I=1,NVADD                                                  ICURHL    246
      K=IVADD(I)                                                        ICURHL    247
      VMG2=VOLTHL(1,LASTV2+I)                                           ICURHL    248
      T1=VOLTHL(2,LASTV2+I)                                             ICURHL    249
      CALL RANKHV(MI,NHV,K,VMG2,T1,HVBOND,KHVBUS,HVVALU,HVTIME)         ICURHL    250
      VMG2=VOLTHL(3,LASTV2+I)                                           ICURHL    251
      T1=VOLTHL(4,LASTV2+I)                                             ICURHL    252
      CALL RANKLV(MI,NLV,K,VMG2,T1,VLBOND, LVBUS,VLVALU,VLTIME)         ICURHL    253
 120  CONTINUE                                                          ICURHL    254
C                                                                       ICURHL    255
      DO 130 K=1,LASTV2                                                 ICURHL    256
      VMG2=VOLTHL(1,K)/VOLTHL(5,K)                                      ICURHL    257
      T1=VOLTHL(2,K)                                                    ICURHL    258
      CALL RANKHV(MI,JHV,K,VMG2,T1,RHVBON,JHVBUS,RHVVAL,RHVTIM)         ICURHL    259
      VMG2=VOLTHL(3,K)/VOLTHL(5,K)                                      ICURHL    260
      T1=VOLTHL(4,K)                                                    ICURHL    261
      CALL RANKLV(MI,JLV,K,VMG2,T1,RVLBON,JLVBUS,RVLVAL,RVLTIM)         ICURHL    262
 130  CONTINUE                                                          ICURHL    263
      DO 140 I=1,NVADD                                                  ICURHL    264
      K=IVADD(I)                                                        ICURHL    265
      VMG2=VOLTHL(1,LASTV2+I)/VOLTHL(5,LASTV2+I)                        ICURHL    266
      T1=VOLTHL(2,LASTV2+I)                                             ICURHL    267
      CALL RANKHV(MI,JHV,K,VMG2,T1,RHVBON,JHVBUS,RHVVAL,RHVTIM)         ICURHL    268
      VMG2=VOLTHL(3,LASTV2+I)/VOLTHL(5,LASTV2+I)                        ICURHL    269
      T1=VOLTHL(4,LASTV2+I)                                             ICURHL    270
      CALL RANKLV(MI,JLV,K,VMG2,T1,RVLBON,JLVBUS,RVLVAL,RVLTIM)         ICURHL    271
 140  CONTINUE                                                          ICURHL    272
C                                                                       ICURHL    273
      MI=MIN0(NT,20)                                                    ICURHL    274
      DO 200 N=1,NT                                                     ICURHL    275
      JG=JCONTA(1,N)                                                    ICURHL    276
      IF(DDAT(JG+1).LT.1.0E-5)GOTO 200                                  ICURHL    277
CD                                                                      ICURHL    278
CD    2. RANK GENERATORS WITH LOWEST AND HIGHEST FREQUENCY DEVIATION    ICURHL    279
CD                                                                      ICURHL    280
      XVALUE=GFREQ(1,N)                                                 ICURHL    281
      T1=GFREQ(2,N)                                                     ICURHL    282
      CALL RANKHV(MI,NHFRQ,N,XVALUE,T1,GHFBON,ITHGEN,GHFVAL,GHFTIM)     ICURHL    283
      XVALUE=GFREQ(3,N)                                                 ICURHL    284
      T1=GFREQ(4,N)                                                     ICURHL    285
      CALL RANKLV(MI,NLFRQ,N,XVALUE,T1,GLFBON,JTHGEN,GLFVAL,GLFTIM)     ICURHL    286
CD                                                                      ICURHL    287
CD    3. RANK GENERATORS WITH HIGHEST/LOWEST ACCERATION POWER           ICURHL    288
CD                                                                      ICURHL    289
      XVALUE=GACCEL(1,N)                                                ICURHL    290
      T1=GACCEL(2,N)                                                    ICURHL    291
      CALL RANKHV(MI,NHAP,N,XVALUE,T1,GHAPBO,KTHGEN,GHAPVA,GHAPTI)      ICURHL    292
      XVALUE=GACCEL(3,N)                                                ICURHL    293
      T1=GACCEL(4,N)                                                    ICURHL    294
      CALL RANKLV(MI,NLAP,N,XVALUE,T1,GLAPBO,LTHGEN,GLAPVA,GLAPTI)      ICURHL    295
CD                                                                      ICURHL    296
      IGENS=ICONTA(1,N)                                                 ICURHL    297
      IF(IGENS.NE.4)THEN                                                ICURHL    298
CD                                                                      ICURHL    299
CD    4. RANK DETAILED GENERATORS WITH HISHEST/LOWEST FIELD VOLTAGE     ICURHL    300
CD                                                                      ICURHL    301
      XVALUE=GFVOLT(1,N)                                                ICURHL    302
      T1=GFVOLT(2,N)                                                    ICURHL    303
      CALL RANKHV(MI,NHFIV,N,XVALUE,T1,GHFIBO,MTHGEN,GHFIVA,GHFITI)     ICURHL    304
      XVALUE=GFVOLT(3,N)                                                ICURHL    305
      T1=GFVOLT(4,N)                                                    ICURHL    306
      CALL RANKLV(MI,NLFIV,N,XVALUE,T1,GLFIBO,NTHGEN,GLFIVA,GLFITI)     ICURHL    307
      ENDIF                                                             ICURHL    308
 200  CONTINUE                                                          ICURHL    309
C                                                                       ICURHL    310
      RETURN                                                            ICURHL    311
      END                                                               ICURHL    312
C                                                                       ICURHL    313
C                                                                       ICURHL    314
C                                                                       ICURHL    315
      SUBROUTINE RANKHV(MI,ITEM,NPROG,XVALUE,TI,XBOND,KDBUS,HVALUE,XTIM)ICURHL    316
C                                                                       ICURHL    317
CD                                                                      ICURHL    318
CD    THIS ROUTINE RANK UP TO 20 HIGHEST VARIABLES                      ICURHL    319
CD                                                                      ICURHL    320
      DIMENSION KDBUS(20),HVALUE(20),XTIM(20)                           ICURHL    321
C                                                                       ICURHL    322
      IF(ITEM.EQ.MI)THEN                                                ICURHL    323
C                                                                       ICURHL    324
           IF(XVALUE.LT.XBOND) RETURN                                   ICURHL    325
C                                                                       ICURHL    326
           DO 100 K=1,MI                                                ICURHL    327
           IF(XVALUE.GT.HVALUE(K))GOTO 150                              ICURHL    328
 100       CONTINUE                                                     ICURHL    329
           RETURN                                                       ICURHL    330
 150       CONTINUE                                                     ICURHL    331
           DO 170 L=MI,K+1,-1                                           ICURHL    332
           HVALUE(L)=HVALUE(L-1)                                        ICURHL    333
           KDBUS(L)=KDBUS(L-1)                                          ICURHL    334
           XTIM(L)=XTIM(L-1)                                            ICURHL    335
 170       CONTINUE                                                     ICURHL    336
           HVALUE(K)=XVALUE                                             ICURHL    337
           KDBUS(K)=NPROG                                               ICURHL    338
           XTIM(K)=TI                                                   ICURHL    339
C                                                                       ICURHL    340
      ELSEIF(ITEM.GT.1)THEN                                             ICURHL    341
C                                                                       ICURHL    342
           DO 300 K=1,ITEM                                              ICURHL    343
           IF(XVALUE.GT.HVALUE(K))GOTO 350                              ICURHL    344
 300       CONTINUE                                                     ICURHL    345
           ITEM=ITEM+1                                                  ICURHL    346
           HVALUE(ITEM)=XVALUE                                          ICURHL    347
           KDBUS(ITEM)=NPROG                                            ICURHL    348
           XTIM(ITEM)=TI                                                ICURHL    349
           GOTO 500                                                     ICURHL    350
 350       CONTINUE                                                     ICURHL    351
           ITEM=ITEM+1                                                  ICURHL    352
           DO 370 L=ITEM,K+1,-1                                         ICURHL    353
           HVALUE(L)=HVALUE(L-1)                                        ICURHL    354
           KDBUS(L)=KDBUS(L-1)                                          ICURHL    355
           XTIM(L)=XTIM(L-1)                                            ICURHL    356
 370       CONTINUE                                                     ICURHL    357
           HVALUE(K)=XVALUE                                             ICURHL    358
           KDBUS(K)=NPROG                                               ICURHL    359
           XTIM(K)=TI                                                   ICURHL    360
C                                                                       ICURHL    361
      ELSEIF(ITEM.EQ.0)THEN                                             ICURHL    362
C                                                                       ICURHL    363
           ITEM=1                                                       ICURHL    364
           HVALUE(ITEM)=XVALUE                                          ICURHL    365
           KDBUS(ITEM)=NPROG                                            ICURHL    366
           XTIM(ITEM)=TI                                                ICURHL    367
C                                                                       ICURHL    368
      ELSEIF(ITEM.EQ.1)THEN                                             ICURHL    369
C                                                                       ICURHL    370
           ITEM=2                                                       ICURHL    371
           IF(XVALUE.LT.XBOND)THEN                                      ICURHL    372
           HVALUE(ITEM)=XVALUE                                          ICURHL    373
           KDBUS(ITEM)=NPROG                                            ICURHL    374
           XTIM(ITEM)=TI                                                ICURHL    375
           ELSE                                                         ICURHL    376
           HVALUE(2)=HVALUE(1)                                          ICURHL    377
           KDBUS(2)=KDBUS(1)                                            ICURHL    378
           XTIM(2)=XTIM(1)                                              ICURHL    379
           HVALUE(1)=XVALUE                                             ICURHL    380
           KDBUS(1)=NPROG                                               ICURHL    381
           XTIM(1)=TI                                                   ICURHL    382
           ENDIF                                                        ICURHL    383
      ENDIF                                                             ICURHL    384
C                                                                       ICURHL    385
 500  XBOND=HVALUE(ITEM)                                                ICURHL    386
C                                                                       ICURHL    387
      RETURN                                                            ICURHL    388
      END                                                               ICURHL    389
C                                                                       ICURHL    390
C                                                                       ICURHL    391
      SUBROUTINE RANKLV(MI,ITEM,NPROG,XVALUE,TI,XBOND,KDBUS,XLVALU,XTIM)ICURHL    392
CD                                                                      ICURHL    393
CD    THIS ROUTINE RANK UP TO 20 LOWEST VARIABLES                       ICURHL    394
CD                                                                      ICURHL    395
      DIMENSION KDBUS(20),XLVALU(20),XTIM(20)                           ICURHL    396
C                                                                       ICURHL    397
      IF(ITEM.EQ.MI)THEN                                                ICURHL    398
C                                                                       ICURHL    399
           IF(XVALUE.GT.XBOND) RETURN                                   ICURHL    400
C                                                                       ICURHL    401
           DO 100 K=1,MI                                                ICURHL    402
           IF(XVALUE.LT.XLVALU(K))GOTO 150                              ICURHL    403
 100       CONTINUE                                                     ICURHL    404
           RETURN                                                       ICURHL    405
 150       CONTINUE                                                     ICURHL    406
           DO 170 L=MI,K+1,-1                                           ICURHL    407
           XLVALU(L)=XLVALU(L-1)                                        ICURHL    408
           KDBUS(L)=KDBUS(L-1)                                          ICURHL    409
           XTIM(L)=XTIM(L-1)                                            ICURHL    410
 170       CONTINUE                                                     ICURHL    411
           XLVALU(K)=XVALUE                                             ICURHL    412
           KDBUS(K)=NPROG                                               ICURHL    413
           XTIM(K)=TI                                                   ICURHL    414
           XBOND=XLVALU(1)                                              ICURHL    415
C                                                                       ICURHL    416
      ELSEIF(ITEM.GT.1)THEN                                             ICURHL    417
C                                                                       ICURHL    418
           DO 300 K=1,ITEM                                              ICURHL    419
           IF(XVALUE.LT.XLVALU(K))GOTO 350                              ICURHL    420
 300       CONTINUE                                                     ICURHL    421
           ITEM=ITEM+1                                                  ICURHL    422
           XLVALU(ITEM)=XVALUE                                          ICURHL    423
           KDBUS(ITEM)=NPROG                                            ICURHL    424
           XTIM(ITEM)=TI                                                ICURHL    425
           GOTO 500                                                     ICURHL    426
 350       CONTINUE                                                     ICURHL    427
           ITEM=ITEM+1                                                  ICURHL    428
           DO 370 L=ITEM,K+1,-1                                         ICURHL    429
           XLVALU(L)=XLVALU(L-1)                                        ICURHL    430
           KDBUS(L)=KDBUS(L-1)                                          ICURHL    431
           XTIM(L)=XTIM(L-1)                                            ICURHL    432
 370       CONTINUE                                                     ICURHL    433
           XLVALU(K)=XVALUE                                             ICURHL    434
           KDBUS(K)=NPROG                                               ICURHL    435
           XTIM(K)=TI                                                   ICURHL    436
C                                                                       ICURHL    437
      ELSEIF(ITEM.EQ.0)THEN                                             ICURHL    438
C                                                                       ICURHL    439
           ITEM=1                                                       ICURHL    440
           XLVALU(ITEM)=XVALUE                                          ICURHL    441
           KDBUS(ITEM)=NPROG                                            ICURHL    442
           XTIM(ITEM)=TI                                                ICURHL    443
C                                                                       ICURHL    444
      ELSEIF(ITEM.EQ.1)THEN                                             ICURHL    445
C                                                                       ICURHL    446
           ITEM=2                                                       ICURHL    447
           IF(XVALUE.GT.XBOND)THEN                                      ICURHL    448
           XLVALU(ITEM)=XVALUE                                          ICURHL    449
           KDBUS(ITEM)=NPROG                                            ICURHL    450
           XTIM(ITEM)=TI                                                ICURHL    451
           ELSE                                                         ICURHL    452
           XLVALU(2)=XLVALU(1)                                          ICURHL    453
           KDBUS(2)=KDBUS(1)                                            ICURHL    454
           XTIM(2)=XTIM(1)                                              ICURHL    455
           XLVALU(1)=XVALUE                                             ICURHL    456
           KDBUS(1)=NPROG                                               ICURHL    457
           XTIM(1)=TI                                                   ICURHL    458
           ENDIF                                                        ICURHL    459
      ENDIF                                                             ICURHL    460
C                                                                       ICURHL    461
 500  XBOND=XLVALU(1)                                                   ICURHL    462
C                                                                       ICURHL    463
      RETURN                                                            ICURHL    464
      END                                                               ICURHL    465
