      INTEGER EVENT0
      INTEGER CPUQU0
      INTEGER DISKQ0
      INTEGER MEMOR0
      INTEGER CPUOW0
      INTEGER DISKO0
      INTEGER AVAIL0
      INTEGER MAXME0
      INTEGER * 4 SIMUL0
      INTEGER * 4 SYSTE0
      INTEGER JOBSI0
      INTEGER JOBSC0
      INTEGER * 4 TOTAL0
      INTEGER * 4 TRANS0
      INTEGER * 4 ACCES0
      INTEGER * 4 LASTC0
      INTEGER * 4 LASTD0
      INTEGER * 4 LASTM0
      INTEGER * 4 CPUUT0
      INTEGER * 4 DISKU0
      REAL * 8 MEMOS0
      INTEGER * 4 MEANJ0
      INTEGER EVENU0
      INTEGER MINRE0
      INTEGER MAXRE0
      INTEGER IOMEAN
      INTEGER IOSTD0
      INTEGER CPUME0
      INTEGER CPUST0
      INTEGER * 4 OVERH0
      INTEGER * 4 RELOC0
      COMMON /CBASYS/EVENT0,CPUQU0,DISKQ0,MEMOR0,CPUOW0,DISKO0,AVAIL0,MA
     *XME0,SIMUL0,SYSTE0,JOBSI0,JOBSC0,TOTAL0,TRANS0,ACCES0,LASTC0,LASTD
     *0,LASTM0,CPUUT0,DISKU0,MEMOS0,MEANJ0,EVENU0,MINRE0,MAXRE0,IOMEAN,I
     *OSTD0,CPUME0,CPUST0,OVERH0,RELOC0
      INTEGER JOBPR0(1)
      INTEGER * 4 ARRIV0(1)
      INTEGER RECOR0(1)
      INTEGER IOREQ0(1)
      INTEGER MEMOT0(1)
      INTEGER * 4 AVGIO0(1)
      INTEGER INTER0(1)
      INTEGER * 4 REMAI0(1)
      INTEGER JOBNU0(1)
      INTEGER JOBPO0(1)
      INTEGER * 4 EVENV0(1)
      INTEGER * 4 EVENW0(1)
      INTEGER LINK(1)
      INTEGER * 4 TIMEIN(1)
      INTEGER * 4 QPRIO0(1)
      INTEGER QUEUE0(1)
      INTEGER * 4 MAXWA0(1)
      INTEGER * 4 WAITT0(1)
      INTEGER MAXLE0(1)
      INTEGER QUEUF0(1)
      INTEGER * 4 TIMEL0(1)
      INTEGER * 4 LASTA0(1)
      INTEGER ENTRY0(1)
      INTEGER MEM(8192)
      COMMON /DSMEM$/MEM
      INTEGER FIRST0
      INTEGER ALLOC
      EQUIVALENCE (MEM(1),JOBPO0(1))
      EQUIVALENCE (MEM(2),EVENV0(1))
      EQUIVALENCE (MEM(4),EVENW0(1))
      EQUIVALENCE (MEM(6),LINK(1))
      EQUIVALENCE (MEM(2),TIMEIN(1))
      EQUIVALENCE (MEM(4),QPRIO0(1))
      EQUIVALENCE (MEM(1),QUEUE0(1))
      EQUIVALENCE (MEM(2),MAXWA0(1))
      EQUIVALENCE (MEM(4),WAITT0(1))
      EQUIVALENCE (MEM(6),MAXLE0(1))
      EQUIVALENCE (MEM(7),QUEUF0(1))
      EQUIVALENCE (MEM(8),TIMEL0(1))
      EQUIVALENCE (MEM(10),LASTA0(1))
      EQUIVALENCE (MEM(12),ENTRY0(1))
      EQUIVALENCE (MEM(1),JOBPR0(1))
      EQUIVALENCE (MEM(2),ARRIV0(1))
      EQUIVALENCE (MEM(4),RECOR0(1))
      EQUIVALENCE (MEM(5),IOREQ0(1))
      EQUIVALENCE (MEM(6),MEMOT0(1))
      EQUIVALENCE (MEM(7),AVGIO0(1))
      EQUIVALENCE (MEM(9),INTER0(1))
      EQUIVALENCE (MEM(10),REMAI0(1))
      EQUIVALENCE (MEM(12),JOBNU0(1))
      CALL INITI0
      FIRST0=ALLOC(12)
      CALL SETJO0(FIRST0)
      CALL SCHED0(1,FIRST0,SYSTE0)
      CALL SCHEE0
      CALL SUMMA0
      CALL SWT
      END
      SUBROUTINE ADVAN0
      INTEGER EVENT0
      INTEGER CPUQU0
      INTEGER DISKQ0
      INTEGER MEMOR0
      INTEGER CPUOW0
      INTEGER DISKO0
      INTEGER AVAIL0
      INTEGER MAXME0
      INTEGER * 4 SIMUL0
      INTEGER * 4 SYSTE0
      INTEGER JOBSI0
      INTEGER JOBSC0
      INTEGER * 4 TOTAL0
      INTEGER * 4 TRANS0
      INTEGER * 4 ACCES0
      INTEGER * 4 LASTC0
      INTEGER * 4 LASTD0
      INTEGER * 4 LASTM0
      INTEGER * 4 CPUUT0
      INTEGER * 4 DISKU0
      REAL * 8 MEMOS0
      INTEGER * 4 MEANJ0
      INTEGER EVENU0
      INTEGER MINRE0
      INTEGER MAXRE0
      INTEGER IOMEAN
      INTEGER IOSTD0
      INTEGER CPUME0
      INTEGER CPUST0
      INTEGER * 4 OVERH0
      INTEGER * 4 RELOC0
      COMMON /CBASYS/EVENT0,CPUQU0,DISKQ0,MEMOR0,CPUOW0,DISKO0,AVAIL0,MA
     *XME0,SIMUL0,SYSTE0,JOBSI0,JOBSC0,TOTAL0,TRANS0,ACCES0,LASTC0,LASTD
     *0,LASTM0,CPUUT0,DISKU0,MEMOS0,MEANJ0,EVENU0,MINRE0,MAXRE0,IOMEAN,I
     *OSTD0,CPUME0,CPUST0,OVERH0,RELOC0
      INTEGER JOBPR0(1)
      INTEGER * 4 ARRIV0(1)
      INTEGER RECOR0(1)
      INTEGER IOREQ0(1)
      INTEGER MEMOT0(1)
      INTEGER * 4 AVGIO0(1)
      INTEGER INTER0(1)
      INTEGER * 4 REMAI0(1)
      INTEGER JOBNU0(1)
      INTEGER JOBPO0(1)
      INTEGER * 4 EVENV0(1)
      INTEGER * 4 EVENW0(1)
      INTEGER LINK(1)
      INTEGER * 4 TIMEIN(1)
      INTEGER * 4 QPRIO0(1)
      INTEGER QUEUE0(1)
      INTEGER * 4 MAXWA0(1)
      INTEGER * 4 WAITT0(1)
      INTEGER MAXLE0(1)
      INTEGER QUEUF0(1)
      INTEGER * 4 TIMEL0(1)
      INTEGER * 4 LASTA0(1)
      INTEGER ENTRY0(1)
      INTEGER MEM(8192)
      COMMON /DSMEM$/MEM
      INTEGER P,Q,JOB
      INTEGER NEXTI0
      INTEGER AVAIL
      EQUIVALENCE (MEM(1),JOBPO0(1))
      EQUIVALENCE (MEM(2),EVENV0(1))
      EQUIVALENCE (MEM(4),EVENW0(1))
      EQUIVALENCE (MEM(6),LINK(1))
      EQUIVALENCE (MEM(2),TIMEIN(1))
      EQUIVALENCE (MEM(4),QPRIO0(1))
      EQUIVALENCE (MEM(1),QUEUE0(1))
      EQUIVALENCE (MEM(2),MAXWA0(1))
      EQUIVALENCE (MEM(4),WAITT0(1))
      EQUIVALENCE (MEM(6),MAXLE0(1))
      EQUIVALENCE (MEM(7),QUEUF0(1))
      EQUIVALENCE (MEM(8),TIMEL0(1))
      EQUIVALENCE (MEM(10),LASTA0(1))
      EQUIVALENCE (MEM(12),ENTRY0(1))
      EQUIVALENCE (MEM(1),JOBPR0(1))
      EQUIVALENCE (MEM(2),ARRIV0(1))
      EQUIVALENCE (MEM(4),RECOR0(1))
      EQUIVALENCE (MEM(5),IOREQ0(1))
      EQUIVALENCE (MEM(6),MEMOT0(1))
      EQUIVALENCE (MEM(7),AVGIO0(1))
      EQUIVALENCE (MEM(9),INTER0(1))
      EQUIVALENCE (MEM(10),REMAI0(1))
      EQUIVALENCE (MEM(12),JOBNU0(1))
      P=QUEUE0(MEMOR0)
      AVAIL=AVAIL0
      Q=LINK(P)
      GOTO 10002
10000 Q=LINK(P)
10002 IF((Q.EQ.0))GOTO 10001
        JOB=JOBPO0(Q)
        IF((MEMOT0(JOB).GT.AVAIL))GOTO 10003
          IF((JOB.EQ.NEXTI0(MEMOR0,P)))GOTO 10004
            CALL ERROR('In advance_memory_queue: can''t happen.')
10004     AVAIL=AVAIL-MEMOT0(JOB)
          CALL SCHED0(2,JOB,SYSTE0)
          GOTO 10005
10003     P=Q
10005 GOTO 10000
10001 RETURN
      END
      SUBROUTINE AWAIT(JOB,RESOU0,QDISC0)
      INTEGER JOB,RESOU0
      INTEGER QDISC0
      INTEGER EVENT0
      INTEGER CPUQU0
      INTEGER DISKQ0
      INTEGER MEMOR0
      INTEGER CPUOW0
      INTEGER DISKO0
      INTEGER AVAIL0
      INTEGER MAXME0
      INTEGER * 4 SIMUL0
      INTEGER * 4 SYSTE0
      INTEGER JOBSI0
      INTEGER JOBSC0
      INTEGER * 4 TOTAL0
      INTEGER * 4 TRANS0
      INTEGER * 4 ACCES0
      INTEGER * 4 LASTC0
      INTEGER * 4 LASTD0
      INTEGER * 4 LASTM0
      INTEGER * 4 CPUUT0
      INTEGER * 4 DISKU0
      REAL * 8 MEMOS0
      INTEGER * 4 MEANJ0
      INTEGER EVENU0
      INTEGER MINRE0
      INTEGER MAXRE0
      INTEGER IOMEAN
      INTEGER IOSTD0
      INTEGER CPUME0
      INTEGER CPUST0
      INTEGER * 4 OVERH0
      INTEGER * 4 RELOC0
      COMMON /CBASYS/EVENT0,CPUQU0,DISKQ0,MEMOR0,CPUOW0,DISKO0,AVAIL0,MA
     *XME0,SIMUL0,SYSTE0,JOBSI0,JOBSC0,TOTAL0,TRANS0,ACCES0,LASTC0,LASTD
     *0,LASTM0,CPUUT0,DISKU0,MEMOS0,MEANJ0,EVENU0,MINRE0,MAXRE0,IOMEAN,I
     *OSTD0,CPUME0,CPUST0,OVERH0,RELOC0
      INTEGER JOBPR0(1)
      INTEGER * 4 ARRIV0(1)
      INTEGER RECOR0(1)
      INTEGER IOREQ0(1)
      INTEGER MEMOT0(1)
      INTEGER * 4 AVGIO0(1)
      INTEGER INTER0(1)
      INTEGER * 4 REMAI0(1)
      INTEGER JOBNU0(1)
      INTEGER JOBPO0(1)
      INTEGER * 4 EVENV0(1)
      INTEGER * 4 EVENW0(1)
      INTEGER LINK(1)
      INTEGER * 4 TIMEIN(1)
      INTEGER * 4 QPRIO0(1)
      INTEGER QUEUE0(1)
      INTEGER * 4 MAXWA0(1)
      INTEGER * 4 WAITT0(1)
      INTEGER MAXLE0(1)
      INTEGER QUEUF0(1)
      INTEGER * 4 TIMEL0(1)
      INTEGER * 4 LASTA0(1)
      INTEGER ENTRY0(1)
      INTEGER MEM(8192)
      COMMON /DSMEM$/MEM
      INTEGER ENTRY
      INTEGER ALLOC
      EQUIVALENCE (MEM(1),JOBPO0(1))
      EQUIVALENCE (MEM(2),EVENV0(1))
      EQUIVALENCE (MEM(4),EVENW0(1))
      EQUIVALENCE (MEM(6),LINK(1))
      EQUIVALENCE (MEM(2),TIMEIN(1))
      EQUIVALENCE (MEM(4),QPRIO0(1))
      EQUIVALENCE (MEM(1),QUEUE0(1))
      EQUIVALENCE (MEM(2),MAXWA0(1))
      EQUIVALENCE (MEM(4),WAITT0(1))
      EQUIVALENCE (MEM(6),MAXLE0(1))
      EQUIVALENCE (MEM(7),QUEUF0(1))
      EQUIVALENCE (MEM(8),TIMEL0(1))
      EQUIVALENCE (MEM(10),LASTA0(1))
      EQUIVALENCE (MEM(12),ENTRY0(1))
      EQUIVALENCE (MEM(1),JOBPR0(1))
      EQUIVALENCE (MEM(2),ARRIV0(1))
      EQUIVALENCE (MEM(4),RECOR0(1))
      EQUIVALENCE (MEM(5),IOREQ0(1))
      EQUIVALENCE (MEM(6),MEMOT0(1))
      EQUIVALENCE (MEM(7),AVGIO0(1))
      EQUIVALENCE (MEM(9),INTER0(1))
      EQUIVALENCE (MEM(10),REMAI0(1))
      EQUIVALENCE (MEM(12),JOBNU0(1))
      ENTRY=ALLOC(6)
      JOBPO0(ENTRY)=JOB
      TIMEIN(ENTRY)=SYSTE0
      QPRIO0(ENTRY)=JOBPR0(JOB)
      CALL ENQUE0(ENTRY,QUEUE0(RESOU0),QDISC0)
      TIMEL0(RESOU0)=TIMEL0(RESOU0)+QUEUF0(RESOU0)*(SYSTE0-LASTA0(RESOU0
     *))
      QUEUF0(RESOU0)=QUEUF0(RESOU0)+1
      MAXLE0(RESOU0)=MAX0(QUEUF0(RESOU0),MAXLE0(RESOU0))
      ENTRY0(RESOU0)=ENTRY0(RESOU0)+1
      LASTA0(RESOU0)=SYSTE0
      RETURN
      END
      SUBROUTINE CANCE0(JOB,EVENT,TIME)
      INTEGER JOB
      INTEGER EVENT
      INTEGER * 4 TIME
      INTEGER EVENT0
      INTEGER CPUQU0
      INTEGER DISKQ0
      INTEGER MEMOR0
      INTEGER CPUOW0
      INTEGER DISKO0
      INTEGER AVAIL0
      INTEGER MAXME0
      INTEGER * 4 SIMUL0
      INTEGER * 4 SYSTE0
      INTEGER JOBSI0
      INTEGER JOBSC0
      INTEGER * 4 TOTAL0
      INTEGER * 4 TRANS0
      INTEGER * 4 ACCES0
      INTEGER * 4 LASTC0
      INTEGER * 4 LASTD0
      INTEGER * 4 LASTM0
      INTEGER * 4 CPUUT0
      INTEGER * 4 DISKU0
      REAL * 8 MEMOS0
      INTEGER * 4 MEANJ0
      INTEGER EVENU0
      INTEGER MINRE0
      INTEGER MAXRE0
      INTEGER IOMEAN
      INTEGER IOSTD0
      INTEGER CPUME0
      INTEGER CPUST0
      INTEGER * 4 OVERH0
      INTEGER * 4 RELOC0
      COMMON /CBASYS/EVENT0,CPUQU0,DISKQ0,MEMOR0,CPUOW0,DISKO0,AVAIL0,MA
     *XME0,SIMUL0,SYSTE0,JOBSI0,JOBSC0,TOTAL0,TRANS0,ACCES0,LASTC0,LASTD
     *0,LASTM0,CPUUT0,DISKU0,MEMOS0,MEANJ0,EVENU0,MINRE0,MAXRE0,IOMEAN,I
     *OSTD0,CPUME0,CPUST0,OVERH0,RELOC0
      INTEGER JOBPR0(1)
      INTEGER * 4 ARRIV0(1)
      INTEGER RECOR0(1)
      INTEGER IOREQ0(1)
      INTEGER MEMOT0(1)
      INTEGER * 4 AVGIO0(1)
      INTEGER INTER0(1)
      INTEGER * 4 REMAI0(1)
      INTEGER JOBNU0(1)
      INTEGER JOBPO0(1)
      INTEGER * 4 EVENV0(1)
      INTEGER * 4 EVENW0(1)
      INTEGER LINK(1)
      INTEGER * 4 TIMEIN(1)
      INTEGER * 4 QPRIO0(1)
      INTEGER QUEUE0(1)
      INTEGER * 4 MAXWA0(1)
      INTEGER * 4 WAITT0(1)
      INTEGER MAXLE0(1)
      INTEGER QUEUF0(1)
      INTEGER * 4 TIMEL0(1)
      INTEGER * 4 LASTA0(1)
      INTEGER ENTRY0(1)
      INTEGER MEM(8192)
      COMMON /DSMEM$/MEM
      INTEGER P,Q
      EQUIVALENCE (MEM(1),JOBPO0(1))
      EQUIVALENCE (MEM(2),EVENV0(1))
      EQUIVALENCE (MEM(4),EVENW0(1))
      EQUIVALENCE (MEM(6),LINK(1))
      EQUIVALENCE (MEM(2),TIMEIN(1))
      EQUIVALENCE (MEM(4),QPRIO0(1))
      EQUIVALENCE (MEM(1),QUEUE0(1))
      EQUIVALENCE (MEM(2),MAXWA0(1))
      EQUIVALENCE (MEM(4),WAITT0(1))
      EQUIVALENCE (MEM(6),MAXLE0(1))
      EQUIVALENCE (MEM(7),QUEUF0(1))
      EQUIVALENCE (MEM(8),TIMEL0(1))
      EQUIVALENCE (MEM(10),LASTA0(1))
      EQUIVALENCE (MEM(12),ENTRY0(1))
      EQUIVALENCE (MEM(1),JOBPR0(1))
      EQUIVALENCE (MEM(2),ARRIV0(1))
      EQUIVALENCE (MEM(4),RECOR0(1))
      EQUIVALENCE (MEM(5),IOREQ0(1))
      EQUIVALENCE (MEM(6),MEMOT0(1))
      EQUIVALENCE (MEM(7),AVGIO0(1))
      EQUIVALENCE (MEM(9),INTER0(1))
      EQUIVALENCE (MEM(10),REMAI0(1))
      EQUIVALENCE (MEM(12),JOBNU0(1))
      P=EVENT0
      Q=LINK(P)
      GOTO 10008
10006 Q=LINK(P)
10008 IF((Q.EQ.0))GOTO 10007
        IF((JOBPO0(Q).NE.JOB))GOTO 10009
          EVENT=EVENV0(Q)
          TIME=EVENW0(Q)
          LINK(P)=LINK(Q)
          CALL FREE(Q)
          RETURN
10009     P=Q
      GOTO 10006
10007 CALL PRINT(-15,'In cancel_event: (job *i) .',JOB)
      CALL ERROR('event not found.')
      RETURN
      END
      INTEGER FUNCTION DEQUE0(QUEUE)
      INTEGER QUEUE
      INTEGER EVENT0
      INTEGER CPUQU0
      INTEGER DISKQ0
      INTEGER MEMOR0
      INTEGER CPUOW0
      INTEGER DISKO0
      INTEGER AVAIL0
      INTEGER MAXME0
      INTEGER * 4 SIMUL0
      INTEGER * 4 SYSTE0
      INTEGER JOBSI0
      INTEGER JOBSC0
      INTEGER * 4 TOTAL0
      INTEGER * 4 TRANS0
      INTEGER * 4 ACCES0
      INTEGER * 4 LASTC0
      INTEGER * 4 LASTD0
      INTEGER * 4 LASTM0
      INTEGER * 4 CPUUT0
      INTEGER * 4 DISKU0
      REAL * 8 MEMOS0
      INTEGER * 4 MEANJ0
      INTEGER EVENU0
      INTEGER MINRE0
      INTEGER MAXRE0
      INTEGER IOMEAN
      INTEGER IOSTD0
      INTEGER CPUME0
      INTEGER CPUST0
      INTEGER * 4 OVERH0
      INTEGER * 4 RELOC0
      COMMON /CBASYS/EVENT0,CPUQU0,DISKQ0,MEMOR0,CPUOW0,DISKO0,AVAIL0,MA
     *XME0,SIMUL0,SYSTE0,JOBSI0,JOBSC0,TOTAL0,TRANS0,ACCES0,LASTC0,LASTD
     *0,LASTM0,CPUUT0,DISKU0,MEMOS0,MEANJ0,EVENU0,MINRE0,MAXRE0,IOMEAN,I
     *OSTD0,CPUME0,CPUST0,OVERH0,RELOC0
      INTEGER JOBPR0(1)
      INTEGER * 4 ARRIV0(1)
      INTEGER RECOR0(1)
      INTEGER IOREQ0(1)
      INTEGER MEMOT0(1)
      INTEGER * 4 AVGIO0(1)
      INTEGER INTER0(1)
      INTEGER * 4 REMAI0(1)
      INTEGER JOBNU0(1)
      INTEGER JOBPO0(1)
      INTEGER * 4 EVENV0(1)
      INTEGER * 4 EVENW0(1)
      INTEGER LINK(1)
      INTEGER * 4 TIMEIN(1)
      INTEGER * 4 QPRIO0(1)
      INTEGER QUEUE0(1)
      INTEGER * 4 MAXWA0(1)
      INTEGER * 4 WAITT0(1)
      INTEGER MAXLE0(1)
      INTEGER QUEUF0(1)
      INTEGER * 4 TIMEL0(1)
      INTEGER * 4 LASTA0(1)
      INTEGER ENTRY0(1)
      INTEGER MEM(8192)
      COMMON /DSMEM$/MEM
      EQUIVALENCE (MEM(1),JOBPO0(1))
      EQUIVALENCE (MEM(2),EVENV0(1))
      EQUIVALENCE (MEM(4),EVENW0(1))
      EQUIVALENCE (MEM(6),LINK(1))
      EQUIVALENCE (MEM(2),TIMEIN(1))
      EQUIVALENCE (MEM(4),QPRIO0(1))
      EQUIVALENCE (MEM(1),QUEUE0(1))
      EQUIVALENCE (MEM(2),MAXWA0(1))
      EQUIVALENCE (MEM(4),WAITT0(1))
      EQUIVALENCE (MEM(6),MAXLE0(1))
      EQUIVALENCE (MEM(7),QUEUF0(1))
      EQUIVALENCE (MEM(8),TIMEL0(1))
      EQUIVALENCE (MEM(10),LASTA0(1))
      EQUIVALENCE (MEM(12),ENTRY0(1))
      EQUIVALENCE (MEM(1),JOBPR0(1))
      EQUIVALENCE (MEM(2),ARRIV0(1))
      EQUIVALENCE (MEM(4),RECOR0(1))
      EQUIVALENCE (MEM(5),IOREQ0(1))
      EQUIVALENCE (MEM(6),MEMOT0(1))
      EQUIVALENCE (MEM(7),AVGIO0(1))
      EQUIVALENCE (MEM(9),INTER0(1))
      EQUIVALENCE (MEM(10),REMAI0(1))
      EQUIVALENCE (MEM(12),JOBNU0(1))
      DEQUE0=LINK(QUEUE)
      IF((DEQUE0.EQ.0))GOTO 10010
        LINK(QUEUE)=LINK(DEQUE0)
10010 RETURN
      END
      SUBROUTINE DUMPJ0(JOB)
      INTEGER JOB
      INTEGER EVENT0
      INTEGER CPUQU0
      INTEGER DISKQ0
      INTEGER MEMOR0
      INTEGER CPUOW0
      INTEGER DISKO0
      INTEGER AVAIL0
      INTEGER MAXME0
      INTEGER * 4 SIMUL0
      INTEGER * 4 SYSTE0
      INTEGER JOBSI0
      INTEGER JOBSC0
      INTEGER * 4 TOTAL0
      INTEGER * 4 TRANS0
      INTEGER * 4 ACCES0
      INTEGER * 4 LASTC0
      INTEGER * 4 LASTD0
      INTEGER * 4 LASTM0
      INTEGER * 4 CPUUT0
      INTEGER * 4 DISKU0
      REAL * 8 MEMOS0
      INTEGER * 4 MEANJ0
      INTEGER EVENU0
      INTEGER MINRE0
      INTEGER MAXRE0
      INTEGER IOMEAN
      INTEGER IOSTD0
      INTEGER CPUME0
      INTEGER CPUST0
      INTEGER * 4 OVERH0
      INTEGER * 4 RELOC0
      COMMON /CBASYS/EVENT0,CPUQU0,DISKQ0,MEMOR0,CPUOW0,DISKO0,AVAIL0,MA
     *XME0,SIMUL0,SYSTE0,JOBSI0,JOBSC0,TOTAL0,TRANS0,ACCES0,LASTC0,LASTD
     *0,LASTM0,CPUUT0,DISKU0,MEMOS0,MEANJ0,EVENU0,MINRE0,MAXRE0,IOMEAN,I
     *OSTD0,CPUME0,CPUST0,OVERH0,RELOC0
      INTEGER JOBPR0(1)
      INTEGER * 4 ARRIV0(1)
      INTEGER RECOR0(1)
      INTEGER IOREQ0(1)
      INTEGER MEMOT0(1)
      INTEGER * 4 AVGIO0(1)
      INTEGER INTER0(1)
      INTEGER * 4 REMAI0(1)
      INTEGER JOBNU0(1)
      INTEGER JOBPO0(1)
      INTEGER * 4 EVENV0(1)
      INTEGER * 4 EVENW0(1)
      INTEGER LINK(1)
      INTEGER * 4 TIMEIN(1)
      INTEGER * 4 QPRIO0(1)
      INTEGER QUEUE0(1)
      INTEGER * 4 MAXWA0(1)
      INTEGER * 4 WAITT0(1)
      INTEGER MAXLE0(1)
      INTEGER QUEUF0(1)
      INTEGER * 4 TIMEL0(1)
      INTEGER * 4 LASTA0(1)
      INTEGER ENTRY0(1)
      INTEGER MEM(8192)
      COMMON /DSMEM$/MEM
      EQUIVALENCE (MEM(1),JOBPO0(1))
      EQUIVALENCE (MEM(2),EVENV0(1))
      EQUIVALENCE (MEM(4),EVENW0(1))
      EQUIVALENCE (MEM(6),LINK(1))
      EQUIVALENCE (MEM(2),TIMEIN(1))
      EQUIVALENCE (MEM(4),QPRIO0(1))
      EQUIVALENCE (MEM(1),QUEUE0(1))
      EQUIVALENCE (MEM(2),MAXWA0(1))
      EQUIVALENCE (MEM(4),WAITT0(1))
      EQUIVALENCE (MEM(6),MAXLE0(1))
      EQUIVALENCE (MEM(7),QUEUF0(1))
      EQUIVALENCE (MEM(8),TIMEL0(1))
      EQUIVALENCE (MEM(10),LASTA0(1))
      EQUIVALENCE (MEM(12),ENTRY0(1))
      EQUIVALENCE (MEM(1),JOBPR0(1))
      EQUIVALENCE (MEM(2),ARRIV0(1))
      EQUIVALENCE (MEM(4),RECOR0(1))
      EQUIVALENCE (MEM(5),IOREQ0(1))
      EQUIVALENCE (MEM(6),MEMOT0(1))
      EQUIVALENCE (MEM(7),AVGIO0(1))
      EQUIVALENCE (MEM(9),INTER0(1))
      EQUIVALENCE (MEM(10),REMAI0(1))
      EQUIVALENCE (MEM(12),JOBNU0(1))
      CALL PRINT(-11,'*3i  *7,3f       *2i      *2i     *4i       *4i   
     *    *7,3f*n.',JOBNU0(JOB),ARRIV0(JOB)/1D6,JOBPR0(JOB),MEMOT0(JOB),
     *RECOR0(JOB),IOREQ0(JOB),AVGIO0(JOB)/1D3)
      RETURN
      END
      SUBROUTINE ENDJOB(JOB)
      INTEGER JOB
      INTEGER EVENT0
      INTEGER CPUQU0
      INTEGER DISKQ0
      INTEGER MEMOR0
      INTEGER CPUOW0
      INTEGER DISKO0
      INTEGER AVAIL0
      INTEGER MAXME0
      INTEGER * 4 SIMUL0
      INTEGER * 4 SYSTE0
      INTEGER JOBSI0
      INTEGER JOBSC0
      INTEGER * 4 TOTAL0
      INTEGER * 4 TRANS0
      INTEGER * 4 ACCES0
      INTEGER * 4 LASTC0
      INTEGER * 4 LASTD0
      INTEGER * 4 LASTM0
      INTEGER * 4 CPUUT0
      INTEGER * 4 DISKU0
      REAL * 8 MEMOS0
      INTEGER * 4 MEANJ0
      INTEGER EVENU0
      INTEGER MINRE0
      INTEGER MAXRE0
      INTEGER IOMEAN
      INTEGER IOSTD0
      INTEGER CPUME0
      INTEGER CPUST0
      INTEGER * 4 OVERH0
      INTEGER * 4 RELOC0
      COMMON /CBASYS/EVENT0,CPUQU0,DISKQ0,MEMOR0,CPUOW0,DISKO0,AVAIL0,MA
     *XME0,SIMUL0,SYSTE0,JOBSI0,JOBSC0,TOTAL0,TRANS0,ACCES0,LASTC0,LASTD
     *0,LASTM0,CPUUT0,DISKU0,MEMOS0,MEANJ0,EVENU0,MINRE0,MAXRE0,IOMEAN,I
     *OSTD0,CPUME0,CPUST0,OVERH0,RELOC0
      INTEGER JOBPR0(1)
      INTEGER * 4 ARRIV0(1)
      INTEGER RECOR0(1)
      INTEGER IOREQ0(1)
      INTEGER MEMOT0(1)
      INTEGER * 4 AVGIO0(1)
      INTEGER INTER0(1)
      INTEGER * 4 REMAI0(1)
      INTEGER JOBNU0(1)
      INTEGER JOBPO0(1)
      INTEGER * 4 EVENV0(1)
      INTEGER * 4 EVENW0(1)
      INTEGER LINK(1)
      INTEGER * 4 TIMEIN(1)
      INTEGER * 4 QPRIO0(1)
      INTEGER QUEUE0(1)
      INTEGER * 4 MAXWA0(1)
      INTEGER * 4 WAITT0(1)
      INTEGER MAXLE0(1)
      INTEGER QUEUF0(1)
      INTEGER * 4 TIMEL0(1)
      INTEGER * 4 LASTA0(1)
      INTEGER ENTRY0(1)
      INTEGER MEM(8192)
      COMMON /DSMEM$/MEM
      INTEGER NEXTJ0
      INTEGER NEXTI0
      EQUIVALENCE (MEM(1),JOBPO0(1))
      EQUIVALENCE (MEM(2),EVENV0(1))
      EQUIVALENCE (MEM(4),EVENW0(1))
      EQUIVALENCE (MEM(6),LINK(1))
      EQUIVALENCE (MEM(2),TIMEIN(1))
      EQUIVALENCE (MEM(4),QPRIO0(1))
      EQUIVALENCE (MEM(1),QUEUE0(1))
      EQUIVALENCE (MEM(2),MAXWA0(1))
      EQUIVALENCE (MEM(4),WAITT0(1))
      EQUIVALENCE (MEM(6),MAXLE0(1))
      EQUIVALENCE (MEM(7),QUEUF0(1))
      EQUIVALENCE (MEM(8),TIMEL0(1))
      EQUIVALENCE (MEM(10),LASTA0(1))
      EQUIVALENCE (MEM(12),ENTRY0(1))
      EQUIVALENCE (MEM(1),JOBPR0(1))
      EQUIVALENCE (MEM(2),ARRIV0(1))
      EQUIVALENCE (MEM(4),RECOR0(1))
      EQUIVALENCE (MEM(5),IOREQ0(1))
      EQUIVALENCE (MEM(6),MEMOT0(1))
      EQUIVALENCE (MEM(7),AVGIO0(1))
      EQUIVALENCE (MEM(9),INTER0(1))
      EQUIVALENCE (MEM(10),REMAI0(1))
      EQUIVALENCE (MEM(12),JOBNU0(1))
      JOBSC0=JOBSC0+1
      IF((CPUOW0.EQ.JOB))GOTO 10011
        CALL ERROR('In end: can''t happen.')
10011 IF((EVENU0.NE.1))GOTO 10012
        CALL PRINT(-13,'Job *3i   terminating    at *7,3f sec*n.',JOBNU0
     *(JOB),SYSTE0/1D6)
10012 CALL UPDAT0
      CPUOW0=0
      NEXTJ0=NEXTI0(CPUQU0,QUEUE0(CPUQU0))
      IF((NEXTJ0.EQ.0))GOTO 10013
        CALL SCHED0(3,NEXTJ0,SYSTE0)
10013 CALL UPDAU0
      AVAIL0=AVAIL0+MEMOT0(JOB)
      LASTM0=SYSTE0
      CALL ADVAN0
      CALL SUMMB0(JOB)
      CALL FREE(JOB)
      RETURN
      END
      SUBROUTINE ENQUE0(ENTRY,QUEUE,QDISC0)
      INTEGER ENTRY,QUEUE
      INTEGER QDISC0
      INTEGER EVENT0
      INTEGER CPUQU0
      INTEGER DISKQ0
      INTEGER MEMOR0
      INTEGER CPUOW0
      INTEGER DISKO0
      INTEGER AVAIL0
      INTEGER MAXME0
      INTEGER * 4 SIMUL0
      INTEGER * 4 SYSTE0
      INTEGER JOBSI0
      INTEGER JOBSC0
      INTEGER * 4 TOTAL0
      INTEGER * 4 TRANS0
      INTEGER * 4 ACCES0
      INTEGER * 4 LASTC0
      INTEGER * 4 LASTD0
      INTEGER * 4 LASTM0
      INTEGER * 4 CPUUT0
      INTEGER * 4 DISKU0
      REAL * 8 MEMOS0
      INTEGER * 4 MEANJ0
      INTEGER EVENU0
      INTEGER MINRE0
      INTEGER MAXRE0
      INTEGER IOMEAN
      INTEGER IOSTD0
      INTEGER CPUME0
      INTEGER CPUST0
      INTEGER * 4 OVERH0
      INTEGER * 4 RELOC0
      COMMON /CBASYS/EVENT0,CPUQU0,DISKQ0,MEMOR0,CPUOW0,DISKO0,AVAIL0,MA
     *XME0,SIMUL0,SYSTE0,JOBSI0,JOBSC0,TOTAL0,TRANS0,ACCES0,LASTC0,LASTD
     *0,LASTM0,CPUUT0,DISKU0,MEMOS0,MEANJ0,EVENU0,MINRE0,MAXRE0,IOMEAN,I
     *OSTD0,CPUME0,CPUST0,OVERH0,RELOC0
      INTEGER JOBPR0(1)
      INTEGER * 4 ARRIV0(1)
      INTEGER RECOR0(1)
      INTEGER IOREQ0(1)
      INTEGER MEMOT0(1)
      INTEGER * 4 AVGIO0(1)
      INTEGER INTER0(1)
      INTEGER * 4 REMAI0(1)
      INTEGER JOBNU0(1)
      INTEGER JOBPO0(1)
      INTEGER * 4 EVENV0(1)
      INTEGER * 4 EVENW0(1)
      INTEGER LINK(1)
      INTEGER * 4 TIMEIN(1)
      INTEGER * 4 QPRIO0(1)
      INTEGER QUEUE0(1)
      INTEGER * 4 MAXWA0(1)
      INTEGER * 4 WAITT0(1)
      INTEGER MAXLE0(1)
      INTEGER QUEUF0(1)
      INTEGER * 4 TIMEL0(1)
      INTEGER * 4 LASTA0(1)
      INTEGER ENTRY0(1)
      INTEGER MEM(8192)
      COMMON /DSMEM$/MEM
      INTEGER P,Q
      INTEGER * 4 PRIO
      EQUIVALENCE (MEM(1),JOBPO0(1))
      EQUIVALENCE (MEM(2),EVENV0(1))
      EQUIVALENCE (MEM(4),EVENW0(1))
      EQUIVALENCE (MEM(6),LINK(1))
      EQUIVALENCE (MEM(2),TIMEIN(1))
      EQUIVALENCE (MEM(4),QPRIO0(1))
      EQUIVALENCE (MEM(1),QUEUE0(1))
      EQUIVALENCE (MEM(2),MAXWA0(1))
      EQUIVALENCE (MEM(4),WAITT0(1))
      EQUIVALENCE (MEM(6),MAXLE0(1))
      EQUIVALENCE (MEM(7),QUEUF0(1))
      EQUIVALENCE (MEM(8),TIMEL0(1))
      EQUIVALENCE (MEM(10),LASTA0(1))
      EQUIVALENCE (MEM(12),ENTRY0(1))
      EQUIVALENCE (MEM(1),JOBPR0(1))
      EQUIVALENCE (MEM(2),ARRIV0(1))
      EQUIVALENCE (MEM(4),RECOR0(1))
      EQUIVALENCE (MEM(5),IOREQ0(1))
      EQUIVALENCE (MEM(6),MEMOT0(1))
      EQUIVALENCE (MEM(7),AVGIO0(1))
      EQUIVALENCE (MEM(9),INTER0(1))
      EQUIVALENCE (MEM(10),REMAI0(1))
      EQUIVALENCE (MEM(12),JOBNU0(1))
      PRIO=QPRIO0(ENTRY)
      IF((QDISC0.NE.0))GOTO 10014
        PRIO=PRIO+1
10014 P=QUEUE
      Q=LINK(P)
      GOTO 10017
10015 Q=LINK(P)
10017 IF((Q.EQ.0))GOTO 10016
        IF((PRIO.GT.QPRIO0(Q)))GOTO 10018
          GOTO 10016
10018     P=Q
      GOTO 10015
10016 LINK(ENTRY)=Q
      LINK(P)=ENTRY
      RETURN
      END
      INTEGER * 4 FUNCTION EXPON0(MEAN)
      INTEGER * 4 MEAN
      EXPON0=-MEAN*ALOG(RND(0))
      RETURN
      END
      SUBROUTINE INITI0
      INTEGER EVENT0
      INTEGER CPUQU0
      INTEGER DISKQ0
      INTEGER MEMOR0
      INTEGER CPUOW0
      INTEGER DISKO0
      INTEGER AVAIL0
      INTEGER MAXME0
      INTEGER * 4 SIMUL0
      INTEGER * 4 SYSTE0
      INTEGER JOBSI0
      INTEGER JOBSC0
      INTEGER * 4 TOTAL0
      INTEGER * 4 TRANS0
      INTEGER * 4 ACCES0
      INTEGER * 4 LASTC0
      INTEGER * 4 LASTD0
      INTEGER * 4 LASTM0
      INTEGER * 4 CPUUT0
      INTEGER * 4 DISKU0
      REAL * 8 MEMOS0
      INTEGER * 4 MEANJ0
      INTEGER EVENU0
      INTEGER MINRE0
      INTEGER MAXRE0
      INTEGER IOMEAN
      INTEGER IOSTD0
      INTEGER CPUME0
      INTEGER CPUST0
      INTEGER * 4 OVERH0
      INTEGER * 4 RELOC0
      COMMON /CBASYS/EVENT0,CPUQU0,DISKQ0,MEMOR0,CPUOW0,DISKO0,AVAIL0,MA
     *XME0,SIMUL0,SYSTE0,JOBSI0,JOBSC0,TOTAL0,TRANS0,ACCES0,LASTC0,LASTD
     *0,LASTM0,CPUUT0,DISKU0,MEMOS0,MEANJ0,EVENU0,MINRE0,MAXRE0,IOMEAN,I
     *OSTD0,CPUME0,CPUST0,OVERH0,RELOC0
      INTEGER JOBPR0(1)
      INTEGER * 4 ARRIV0(1)
      INTEGER RECOR0(1)
      INTEGER IOREQ0(1)
      INTEGER MEMOT0(1)
      INTEGER * 4 AVGIO0(1)
      INTEGER INTER0(1)
      INTEGER * 4 REMAI0(1)
      INTEGER JOBNU0(1)
      INTEGER JOBPO0(1)
      INTEGER * 4 EVENV0(1)
      INTEGER * 4 EVENW0(1)
      INTEGER LINK(1)
      INTEGER * 4 TIMEIN(1)
      INTEGER * 4 QPRIO0(1)
      INTEGER QUEUE0(1)
      INTEGER * 4 MAXWA0(1)
      INTEGER * 4 WAITT0(1)
      INTEGER MAXLE0(1)
      INTEGER QUEUF0(1)
      INTEGER * 4 TIMEL0(1)
      INTEGER * 4 LASTA0(1)
      INTEGER ENTRY0(1)
      INTEGER MEM(8192)
      COMMON /DSMEM$/MEM
      INTEGER PTR
      INTEGER ALLOC
      INTEGER STR(102)
      EQUIVALENCE (MEM(1),JOBPO0(1))
      EQUIVALENCE (MEM(2),EVENV0(1))
      EQUIVALENCE (MEM(4),EVENW0(1))
      EQUIVALENCE (MEM(6),LINK(1))
      EQUIVALENCE (MEM(2),TIMEIN(1))
      EQUIVALENCE (MEM(4),QPRIO0(1))
      EQUIVALENCE (MEM(1),QUEUE0(1))
      EQUIVALENCE (MEM(2),MAXWA0(1))
      EQUIVALENCE (MEM(4),WAITT0(1))
      EQUIVALENCE (MEM(6),MAXLE0(1))
      EQUIVALENCE (MEM(7),QUEUF0(1))
      EQUIVALENCE (MEM(8),TIMEL0(1))
      EQUIVALENCE (MEM(10),LASTA0(1))
      EQUIVALENCE (MEM(12),ENTRY0(1))
      EQUIVALENCE (MEM(1),JOBPR0(1))
      EQUIVALENCE (MEM(2),ARRIV0(1))
      EQUIVALENCE (MEM(4),RECOR0(1))
      EQUIVALENCE (MEM(5),IOREQ0(1))
      EQUIVALENCE (MEM(6),MEMOT0(1))
      EQUIVALENCE (MEM(7),AVGIO0(1))
      EQUIVALENCE (MEM(9),INTER0(1))
      EQUIVALENCE (MEM(10),REMAI0(1))
      EQUIVALENCE (MEM(12),JOBNU0(1))
      CALL DSINIT(8192)
      EVENT0=ALLOC(6)
      LINK(EVENT0)=0
      CPUOW0=0
      DISKO0=0
      CPUQU0=ALLOC(12)
      PTR=ALLOC(6)
      QUEUE0(CPUQU0)=PTR
      LINK(PTR)=0
      MAXWA0(CPUQU0)=0
      WAITT0(CPUQU0)=0
      MAXLE0(CPUQU0)=0
      QUEUF0(CPUQU0)=0
      TIMEL0(CPUQU0)=0
      LASTA0(CPUQU0)=0
      ENTRY0(CPUQU0)=0
      DISKQ0=ALLOC(12)
      PTR=ALLOC(6)
      QUEUE0(DISKQ0)=PTR
      LINK(PTR)=0
      MAXWA0(DISKQ0)=0
      WAITT0(DISKQ0)=0
      MAXLE0(DISKQ0)=0
      QUEUF0(DISKQ0)=0
      TIMEL0(DISKQ0)=0
      LASTA0(DISKQ0)=0
      ENTRY0(DISKQ0)=0
      MEMOR0=ALLOC(12)
      PTR=ALLOC(6)
      QUEUE0(MEMOR0)=PTR
      LINK(PTR)=0
      MAXWA0(MEMOR0)=0
      WAITT0(MEMOR0)=0
      MAXLE0(MEMOR0)=0
      QUEUF0(MEMOR0)=0
      TIMEL0(MEMOR0)=0
      LASTA0(MEMOR0)=0
      ENTRY0(MEMOR0)=0
      CALL INPUT(-10,'Simulation length (sec)? *l.',SIMUL0)
      SIMUL0=SIMUL0*1000000
      CALL INPUT(-10,'Memory size (K-words)? *i.',MAXME0)
      CALL INPUT(-10,'Time required to compress memory (usec)? *l.',RELO
     *C0)
      CALL INPUT(-10,'Disk transfer time per word (usec)? *l.',TRANS0)
      CALL INPUT(-10,'Disk access time (msec)? *l.',ACCES0)
      ACCES0=ACCES0*1000
      CALL INPUT(-10,'I/O overhead time (usec)? *l.',OVERH0)
      CALL INPUT(-10,'Mean job interarrival time (msec)? *l.',MEANJ0)
      MEANJ0=MEANJ0*1000
      CALL INPUT(-10,'Mean cpu time per job (msec)? *i.',CPUME0)
      CALL INPUT(-10,'Standard deviation? *i.',CPUST0)
      CALL INPUT(-10,'Mean number of i/o requests per job? *i.',IOMEAN)
      CALL INPUT(-10,'Standard deviation? *i.',IOSTD0)
      CALL INPUT(-10,'Minimum i/o record size (words)? *i.',MINRE0)
      CALL INPUT(-10,'Maximum i/o record size (words)? *i.',MAXRE0)
      CALL INPUT(-10,'Do you want an event trace? *s.',STR)
      IF(((STR(1).NE.249).AND.(STR(1).NE.217)))GOTO 10019
        EVENU0=1
        GOTO 10020
10019   EVENU0=0
10020 AVAIL0=MAXME0
      MEMOS0=0.
      CPUUT0=0
      DISKU0=0
      JOBSI0=0
      JOBSC0=0
      TOTAL0=0
      SYSTE0=0
      LASTD0=SYSTE0
      LASTC0=SYSTE0
      LASTM0=SYSTE0
      CALL RND(779)
      CALL PRINT(-11,'*n*nSystem Parameters:*n*n.')
      CALL PRINT(-11,'   Simulation length:              *5l sec*n.',SIM
     *UL0/1000000)
      CALL PRINT(-11,'   Memory size:                    *5i K words*n.'
     *,MAXME0)
      CALL PRINT(-11,'   Time to compress memory:        *5l usec*n.',RE
     *LOC0)
      CALL PRINT(-11,'   Disk transfer rate:             *5,3f Mhz*n.',1
     *D0/TRANS0)
      CALL PRINT(-11,'   Disk access time:               *5l msec*n.',AC
     *CES0/INTL(1000))
      CALL PRINT(-11,'   I/O overhead time:              *5l usec*n.',OV
     *ERH0)
      CALL PRINT(-11,'   Mean job interarrival time:     *5,3f sec*n.',M
     *EANJ0/1D6)
      CALL PRINT(-11,'   Mean cpu time per job:          *5,3f sec*n.',C
     *PUME0/1D3)
      CALL PRINT(-11,'   Cpu time standard deviation:    *5,3f sec*n.',C
     *PUST0/1D3)
      CALL PRINT(-11,'   Mean i/o requests per job:      *5i requests*n.
     *',IOMEAN)
      CALL PRINT(-11,'   I/O standard deviation:         *5i requests*n.
     *',IOSTD0)
      CALL PRINT(-11,'   Minimum i/o record size:        *5i words*n.',M
     *INRE0)
      CALL PRINT(-11,'   Maximum i/o record size:        *5i words*n*n*n
     **n.',MAXRE0)
      CALL PRINT(-11,'Job  Arrived  Priority  Memory  Rec size  Requests
     *  Avg Interval*n.')
      CALL PRINT(-11,'      (sec)             (Kwds)  (words)           
     *     (msec)*n.')
      CALL PRINT(-11,'===  =======  ========  ======  ========  ========
     *  ============*n.')
      RETURN
      END
      SUBROUTINE JOBAR0(JOB)
      INTEGER JOB
      INTEGER EVENT0
      INTEGER CPUQU0
      INTEGER DISKQ0
      INTEGER MEMOR0
      INTEGER CPUOW0
      INTEGER DISKO0
      INTEGER AVAIL0
      INTEGER MAXME0
      INTEGER * 4 SIMUL0
      INTEGER * 4 SYSTE0
      INTEGER JOBSI0
      INTEGER JOBSC0
      INTEGER * 4 TOTAL0
      INTEGER * 4 TRANS0
      INTEGER * 4 ACCES0
      INTEGER * 4 LASTC0
      INTEGER * 4 LASTD0
      INTEGER * 4 LASTM0
      INTEGER * 4 CPUUT0
      INTEGER * 4 DISKU0
      REAL * 8 MEMOS0
      INTEGER * 4 MEANJ0
      INTEGER EVENU0
      INTEGER MINRE0
      INTEGER MAXRE0
      INTEGER IOMEAN
      INTEGER IOSTD0
      INTEGER CPUME0
      INTEGER CPUST0
      INTEGER * 4 OVERH0
      INTEGER * 4 RELOC0
      COMMON /CBASYS/EVENT0,CPUQU0,DISKQ0,MEMOR0,CPUOW0,DISKO0,AVAIL0,MA
     *XME0,SIMUL0,SYSTE0,JOBSI0,JOBSC0,TOTAL0,TRANS0,ACCES0,LASTC0,LASTD
     *0,LASTM0,CPUUT0,DISKU0,MEMOS0,MEANJ0,EVENU0,MINRE0,MAXRE0,IOMEAN,I
     *OSTD0,CPUME0,CPUST0,OVERH0,RELOC0
      INTEGER JOBPR0(1)
      INTEGER * 4 ARRIV0(1)
      INTEGER RECOR0(1)
      INTEGER IOREQ0(1)
      INTEGER MEMOT0(1)
      INTEGER * 4 AVGIO0(1)
      INTEGER INTER0(1)
      INTEGER * 4 REMAI0(1)
      INTEGER JOBNU0(1)
      INTEGER JOBPO0(1)
      INTEGER * 4 EVENV0(1)
      INTEGER * 4 EVENW0(1)
      INTEGER LINK(1)
      INTEGER * 4 TIMEIN(1)
      INTEGER * 4 QPRIO0(1)
      INTEGER QUEUE0(1)
      INTEGER * 4 MAXWA0(1)
      INTEGER * 4 WAITT0(1)
      INTEGER MAXLE0(1)
      INTEGER QUEUF0(1)
      INTEGER * 4 TIMEL0(1)
      INTEGER * 4 LASTA0(1)
      INTEGER ENTRY0(1)
      INTEGER MEM(8192)
      COMMON /DSMEM$/MEM
      INTEGER NEXTJ0
      INTEGER ALLOC
      INTEGER * 4 TIME
      INTEGER * 4 EXPON0
      EQUIVALENCE (MEM(1),JOBPO0(1))
      EQUIVALENCE (MEM(2),EVENV0(1))
      EQUIVALENCE (MEM(4),EVENW0(1))
      EQUIVALENCE (MEM(6),LINK(1))
      EQUIVALENCE (MEM(2),TIMEIN(1))
      EQUIVALENCE (MEM(4),QPRIO0(1))
      EQUIVALENCE (MEM(1),QUEUE0(1))
      EQUIVALENCE (MEM(2),MAXWA0(1))
      EQUIVALENCE (MEM(4),WAITT0(1))
      EQUIVALENCE (MEM(6),MAXLE0(1))
      EQUIVALENCE (MEM(7),QUEUF0(1))
      EQUIVALENCE (MEM(8),TIMEL0(1))
      EQUIVALENCE (MEM(10),LASTA0(1))
      EQUIVALENCE (MEM(12),ENTRY0(1))
      EQUIVALENCE (MEM(1),JOBPR0(1))
      EQUIVALENCE (MEM(2),ARRIV0(1))
      EQUIVALENCE (MEM(4),RECOR0(1))
      EQUIVALENCE (MEM(5),IOREQ0(1))
      EQUIVALENCE (MEM(6),MEMOT0(1))
      EQUIVALENCE (MEM(7),AVGIO0(1))
      EQUIVALENCE (MEM(9),INTER0(1))
      EQUIVALENCE (MEM(10),REMAI0(1))
      EQUIVALENCE (MEM(12),JOBNU0(1))
      ARRIV0(JOB)=SYSTE0
      CALL DUMPJ0(JOB)
      JOBSI0=JOBSI0+1
      CALL SCHED0(2,JOB,SYSTE0)
      NEXTJ0=ALLOC(12)
      CALL SETJO0(NEXTJ0)
      TIME=SYSTE0+EXPON0(MEANJ0)
      CALL SCHED0(1,NEXTJ0,TIME)
      RETURN
      END
      SUBROUTINE NEXTE0(EVENT,JOB,TIME)
      INTEGER EVENT
      INTEGER JOB
      INTEGER * 4 TIME
      INTEGER EVENT0
      INTEGER CPUQU0
      INTEGER DISKQ0
      INTEGER MEMOR0
      INTEGER CPUOW0
      INTEGER DISKO0
      INTEGER AVAIL0
      INTEGER MAXME0
      INTEGER * 4 SIMUL0
      INTEGER * 4 SYSTE0
      INTEGER JOBSI0
      INTEGER JOBSC0
      INTEGER * 4 TOTAL0
      INTEGER * 4 TRANS0
      INTEGER * 4 ACCES0
      INTEGER * 4 LASTC0
      INTEGER * 4 LASTD0
      INTEGER * 4 LASTM0
      INTEGER * 4 CPUUT0
      INTEGER * 4 DISKU0
      REAL * 8 MEMOS0
      INTEGER * 4 MEANJ0
      INTEGER EVENU0
      INTEGER MINRE0
      INTEGER MAXRE0
      INTEGER IOMEAN
      INTEGER IOSTD0
      INTEGER CPUME0
      INTEGER CPUST0
      INTEGER * 4 OVERH0
      INTEGER * 4 RELOC0
      COMMON /CBASYS/EVENT0,CPUQU0,DISKQ0,MEMOR0,CPUOW0,DISKO0,AVAIL0,MA
     *XME0,SIMUL0,SYSTE0,JOBSI0,JOBSC0,TOTAL0,TRANS0,ACCES0,LASTC0,LASTD
     *0,LASTM0,CPUUT0,DISKU0,MEMOS0,MEANJ0,EVENU0,MINRE0,MAXRE0,IOMEAN,I
     *OSTD0,CPUME0,CPUST0,OVERH0,RELOC0
      INTEGER JOBPR0(1)
      INTEGER * 4 ARRIV0(1)
      INTEGER RECOR0(1)
      INTEGER IOREQ0(1)
      INTEGER MEMOT0(1)
      INTEGER * 4 AVGIO0(1)
      INTEGER INTER0(1)
      INTEGER * 4 REMAI0(1)
      INTEGER JOBNU0(1)
      INTEGER JOBPO0(1)
      INTEGER * 4 EVENV0(1)
      INTEGER * 4 EVENW0(1)
      INTEGER LINK(1)
      INTEGER * 4 TIMEIN(1)
      INTEGER * 4 QPRIO0(1)
      INTEGER QUEUE0(1)
      INTEGER * 4 MAXWA0(1)
      INTEGER * 4 WAITT0(1)
      INTEGER MAXLE0(1)
      INTEGER QUEUF0(1)
      INTEGER * 4 TIMEL0(1)
      INTEGER * 4 LASTA0(1)
      INTEGER ENTRY0(1)
      INTEGER MEM(8192)
      COMMON /DSMEM$/MEM
      INTEGER ENTRY
      INTEGER DEQUE0
      EQUIVALENCE (MEM(1),JOBPO0(1))
      EQUIVALENCE (MEM(2),EVENV0(1))
      EQUIVALENCE (MEM(4),EVENW0(1))
      EQUIVALENCE (MEM(6),LINK(1))
      EQUIVALENCE (MEM(2),TIMEIN(1))
      EQUIVALENCE (MEM(4),QPRIO0(1))
      EQUIVALENCE (MEM(1),QUEUE0(1))
      EQUIVALENCE (MEM(2),MAXWA0(1))
      EQUIVALENCE (MEM(4),WAITT0(1))
      EQUIVALENCE (MEM(6),MAXLE0(1))
      EQUIVALENCE (MEM(7),QUEUF0(1))
      EQUIVALENCE (MEM(8),TIMEL0(1))
      EQUIVALENCE (MEM(10),LASTA0(1))
      EQUIVALENCE (MEM(12),ENTRY0(1))
      EQUIVALENCE (MEM(1),JOBPR0(1))
      EQUIVALENCE (MEM(2),ARRIV0(1))
      EQUIVALENCE (MEM(4),RECOR0(1))
      EQUIVALENCE (MEM(5),IOREQ0(1))
      EQUIVALENCE (MEM(6),MEMOT0(1))
      EQUIVALENCE (MEM(7),AVGIO0(1))
      EQUIVALENCE (MEM(9),INTER0(1))
      EQUIVALENCE (MEM(10),REMAI0(1))
      EQUIVALENCE (MEM(12),JOBNU0(1))
      ENTRY=DEQUE0(EVENT0)
      IF((ENTRY.NE.0))GOTO 10021
        CALL ERROR('In next_event: can''t happen.')
10021 EVENT=EVENV0(ENTRY)
      JOB=JOBPO0(ENTRY)
      TIME=EVENW0(ENTRY)
      CALL FREE(ENTRY)
      RETURN
      END
      INTEGER FUNCTION NEXTI0(RESOU0,QUEUE)
      INTEGER RESOU0,QUEUE
      INTEGER EVENT0
      INTEGER CPUQU0
      INTEGER DISKQ0
      INTEGER MEMOR0
      INTEGER CPUOW0
      INTEGER DISKO0
      INTEGER AVAIL0
      INTEGER MAXME0
      INTEGER * 4 SIMUL0
      INTEGER * 4 SYSTE0
      INTEGER JOBSI0
      INTEGER JOBSC0
      INTEGER * 4 TOTAL0
      INTEGER * 4 TRANS0
      INTEGER * 4 ACCES0
      INTEGER * 4 LASTC0
      INTEGER * 4 LASTD0
      INTEGER * 4 LASTM0
      INTEGER * 4 CPUUT0
      INTEGER * 4 DISKU0
      REAL * 8 MEMOS0
      INTEGER * 4 MEANJ0
      INTEGER EVENU0
      INTEGER MINRE0
      INTEGER MAXRE0
      INTEGER IOMEAN
      INTEGER IOSTD0
      INTEGER CPUME0
      INTEGER CPUST0
      INTEGER * 4 OVERH0
      INTEGER * 4 RELOC0
      COMMON /CBASYS/EVENT0,CPUQU0,DISKQ0,MEMOR0,CPUOW0,DISKO0,AVAIL0,MA
     *XME0,SIMUL0,SYSTE0,JOBSI0,JOBSC0,TOTAL0,TRANS0,ACCES0,LASTC0,LASTD
     *0,LASTM0,CPUUT0,DISKU0,MEMOS0,MEANJ0,EVENU0,MINRE0,MAXRE0,IOMEAN,I
     *OSTD0,CPUME0,CPUST0,OVERH0,RELOC0
      INTEGER JOBPR0(1)
      INTEGER * 4 ARRIV0(1)
      INTEGER RECOR0(1)
      INTEGER IOREQ0(1)
      INTEGER MEMOT0(1)
      INTEGER * 4 AVGIO0(1)
      INTEGER INTER0(1)
      INTEGER * 4 REMAI0(1)
      INTEGER JOBNU0(1)
      INTEGER JOBPO0(1)
      INTEGER * 4 EVENV0(1)
      INTEGER * 4 EVENW0(1)
      INTEGER LINK(1)
      INTEGER * 4 TIMEIN(1)
      INTEGER * 4 QPRIO0(1)
      INTEGER QUEUE0(1)
      INTEGER * 4 MAXWA0(1)
      INTEGER * 4 WAITT0(1)
      INTEGER MAXLE0(1)
      INTEGER QUEUF0(1)
      INTEGER * 4 TIMEL0(1)
      INTEGER * 4 LASTA0(1)
      INTEGER ENTRY0(1)
      INTEGER MEM(8192)
      COMMON /DSMEM$/MEM
      INTEGER * 4 ENTRZ0
      INTEGER ENTRY
      INTEGER DEQUE0
      EQUIVALENCE (MEM(1),JOBPO0(1))
      EQUIVALENCE (MEM(2),EVENV0(1))
      EQUIVALENCE (MEM(4),EVENW0(1))
      EQUIVALENCE (MEM(6),LINK(1))
      EQUIVALENCE (MEM(2),TIMEIN(1))
      EQUIVALENCE (MEM(4),QPRIO0(1))
      EQUIVALENCE (MEM(1),QUEUE0(1))
      EQUIVALENCE (MEM(2),MAXWA0(1))
      EQUIVALENCE (MEM(4),WAITT0(1))
      EQUIVALENCE (MEM(6),MAXLE0(1))
      EQUIVALENCE (MEM(7),QUEUF0(1))
      EQUIVALENCE (MEM(8),TIMEL0(1))
      EQUIVALENCE (MEM(10),LASTA0(1))
      EQUIVALENCE (MEM(12),ENTRY0(1))
      EQUIVALENCE (MEM(1),JOBPR0(1))
      EQUIVALENCE (MEM(2),ARRIV0(1))
      EQUIVALENCE (MEM(4),RECOR0(1))
      EQUIVALENCE (MEM(5),IOREQ0(1))
      EQUIVALENCE (MEM(6),MEMOT0(1))
      EQUIVALENCE (MEM(7),AVGIO0(1))
      EQUIVALENCE (MEM(9),INTER0(1))
      EQUIVALENCE (MEM(10),REMAI0(1))
      EQUIVALENCE (MEM(12),JOBNU0(1))
      ENTRY=DEQUE0(QUEUE)
      IF((ENTRY.NE.0))GOTO 10022
        NEXTI0=0
        RETURN
10022 NEXTI0=JOBPO0(ENTRY)
      TIMEL0(RESOU0)=TIMEL0(RESOU0)+QUEUF0(RESOU0)*(SYSTE0-LASTA0(RESOU0
     *))
      QUEUF0(RESOU0)=QUEUF0(RESOU0)-1
      ENTRZ0=SYSTE0-TIMEIN(ENTRY)
      WAITT0(RESOU0)=WAITT0(RESOU0)+ENTRZ0
      MAXWA0(RESOU0)=MAX0(ENTRZ0,MAXWA0(RESOU0))
      LASTA0(RESOU0)=SYSTE0
      CALL FREE(ENTRY)
      RETURN
      END
      INTEGER FUNCTION NORMAL(MEAN,STDDEV)
      INTEGER MEAN,STDDEV
      INTEGER I
      REAL SUM
10023   SUM=0.0
        DO 10024 I=1,12
          SUM=SUM+RND(0)
10024   CONTINUE
10025   NORMAL=MEAN+(SUM-6.0)*STDDEV
      IF((NORMAL.LE.0))GOTO 10023
      RETURN
      END
      SUBROUTINE RELEA0(JOB)
      INTEGER JOB
      INTEGER EVENT0
      INTEGER CPUQU0
      INTEGER DISKQ0
      INTEGER MEMOR0
      INTEGER CPUOW0
      INTEGER DISKO0
      INTEGER AVAIL0
      INTEGER MAXME0
      INTEGER * 4 SIMUL0
      INTEGER * 4 SYSTE0
      INTEGER JOBSI0
      INTEGER JOBSC0
      INTEGER * 4 TOTAL0
      INTEGER * 4 TRANS0
      INTEGER * 4 ACCES0
      INTEGER * 4 LASTC0
      INTEGER * 4 LASTD0
      INTEGER * 4 LASTM0
      INTEGER * 4 CPUUT0
      INTEGER * 4 DISKU0
      REAL * 8 MEMOS0
      INTEGER * 4 MEANJ0
      INTEGER EVENU0
      INTEGER MINRE0
      INTEGER MAXRE0
      INTEGER IOMEAN
      INTEGER IOSTD0
      INTEGER CPUME0
      INTEGER CPUST0
      INTEGER * 4 OVERH0
      INTEGER * 4 RELOC0
      COMMON /CBASYS/EVENT0,CPUQU0,DISKQ0,MEMOR0,CPUOW0,DISKO0,AVAIL0,MA
     *XME0,SIMUL0,SYSTE0,JOBSI0,JOBSC0,TOTAL0,TRANS0,ACCES0,LASTC0,LASTD
     *0,LASTM0,CPUUT0,DISKU0,MEMOS0,MEANJ0,EVENU0,MINRE0,MAXRE0,IOMEAN,I
     *OSTD0,CPUME0,CPUST0,OVERH0,RELOC0
      INTEGER JOBPR0(1)
      INTEGER * 4 ARRIV0(1)
      INTEGER RECOR0(1)
      INTEGER IOREQ0(1)
      INTEGER MEMOT0(1)
      INTEGER * 4 AVGIO0(1)
      INTEGER INTER0(1)
      INTEGER * 4 REMAI0(1)
      INTEGER JOBNU0(1)
      INTEGER JOBPO0(1)
      INTEGER * 4 EVENV0(1)
      INTEGER * 4 EVENW0(1)
      INTEGER LINK(1)
      INTEGER * 4 TIMEIN(1)
      INTEGER * 4 QPRIO0(1)
      INTEGER QUEUE0(1)
      INTEGER * 4 MAXWA0(1)
      INTEGER * 4 WAITT0(1)
      INTEGER MAXLE0(1)
      INTEGER QUEUF0(1)
      INTEGER * 4 TIMEL0(1)
      INTEGER * 4 LASTA0(1)
      INTEGER ENTRY0(1)
      INTEGER MEM(8192)
      COMMON /DSMEM$/MEM
      INTEGER NEXTJ0
      INTEGER NEXTI0
      EQUIVALENCE (MEM(1),JOBPO0(1))
      EQUIVALENCE (MEM(2),EVENV0(1))
      EQUIVALENCE (MEM(4),EVENW0(1))
      EQUIVALENCE (MEM(6),LINK(1))
      EQUIVALENCE (MEM(2),TIMEIN(1))
      EQUIVALENCE (MEM(4),QPRIO0(1))
      EQUIVALENCE (MEM(1),QUEUE0(1))
      EQUIVALENCE (MEM(2),MAXWA0(1))
      EQUIVALENCE (MEM(4),WAITT0(1))
      EQUIVALENCE (MEM(6),MAXLE0(1))
      EQUIVALENCE (MEM(7),QUEUF0(1))
      EQUIVALENCE (MEM(8),TIMEL0(1))
      EQUIVALENCE (MEM(10),LASTA0(1))
      EQUIVALENCE (MEM(12),ENTRY0(1))
      EQUIVALENCE (MEM(1),JOBPR0(1))
      EQUIVALENCE (MEM(2),ARRIV0(1))
      EQUIVALENCE (MEM(4),RECOR0(1))
      EQUIVALENCE (MEM(5),IOREQ0(1))
      EQUIVALENCE (MEM(6),MEMOT0(1))
      EQUIVALENCE (MEM(7),AVGIO0(1))
      EQUIVALENCE (MEM(9),INTER0(1))
      EQUIVALENCE (MEM(10),REMAI0(1))
      EQUIVALENCE (MEM(12),JOBNU0(1))
      IF((CPUOW0.EQ.JOB))GOTO 10026
        CALL ERROR('In release_cpu: can''t happen.')
10026 IF((EVENU0.NE.1))GOTO 10027
        CALL PRINT(-13,'Job *3i releasing cpu    at *7,3f sec*n.',JOBNU0
     *(JOB),SYSTE0/1D6)
10027 CPUOW0=0
      CALL UPDAT0
      NEXTJ0=NEXTI0(CPUQU0,QUEUE0(CPUQU0))
      IF((NEXTJ0.EQ.0))GOTO 10028
        CALL SCHED0(3,NEXTJ0,SYSTE0)
10028 CALL SCHED0(5,JOB,SYSTE0+OVERH0)
      RETURN
      END
      SUBROUTINE RELEB0(JOB)
      INTEGER JOB
      INTEGER EVENT0
      INTEGER CPUQU0
      INTEGER DISKQ0
      INTEGER MEMOR0
      INTEGER CPUOW0
      INTEGER DISKO0
      INTEGER AVAIL0
      INTEGER MAXME0
      INTEGER * 4 SIMUL0
      INTEGER * 4 SYSTE0
      INTEGER JOBSI0
      INTEGER JOBSC0
      INTEGER * 4 TOTAL0
      INTEGER * 4 TRANS0
      INTEGER * 4 ACCES0
      INTEGER * 4 LASTC0
      INTEGER * 4 LASTD0
      INTEGER * 4 LASTM0
      INTEGER * 4 CPUUT0
      INTEGER * 4 DISKU0
      REAL * 8 MEMOS0
      INTEGER * 4 MEANJ0
      INTEGER EVENU0
      INTEGER MINRE0
      INTEGER MAXRE0
      INTEGER IOMEAN
      INTEGER IOSTD0
      INTEGER CPUME0
      INTEGER CPUST0
      INTEGER * 4 OVERH0
      INTEGER * 4 RELOC0
      COMMON /CBASYS/EVENT0,CPUQU0,DISKQ0,MEMOR0,CPUOW0,DISKO0,AVAIL0,MA
     *XME0,SIMUL0,SYSTE0,JOBSI0,JOBSC0,TOTAL0,TRANS0,ACCES0,LASTC0,LASTD
     *0,LASTM0,CPUUT0,DISKU0,MEMOS0,MEANJ0,EVENU0,MINRE0,MAXRE0,IOMEAN,I
     *OSTD0,CPUME0,CPUST0,OVERH0,RELOC0
      INTEGER JOBPR0(1)
      INTEGER * 4 ARRIV0(1)
      INTEGER RECOR0(1)
      INTEGER IOREQ0(1)
      INTEGER MEMOT0(1)
      INTEGER * 4 AVGIO0(1)
      INTEGER INTER0(1)
      INTEGER * 4 REMAI0(1)
      INTEGER JOBNU0(1)
      INTEGER JOBPO0(1)
      INTEGER * 4 EVENV0(1)
      INTEGER * 4 EVENW0(1)
      INTEGER LINK(1)
      INTEGER * 4 TIMEIN(1)
      INTEGER * 4 QPRIO0(1)
      INTEGER QUEUE0(1)
      INTEGER * 4 MAXWA0(1)
      INTEGER * 4 WAITT0(1)
      INTEGER MAXLE0(1)
      INTEGER QUEUF0(1)
      INTEGER * 4 TIMEL0(1)
      INTEGER * 4 LASTA0(1)
      INTEGER ENTRY0(1)
      INTEGER MEM(8192)
      COMMON /DSMEM$/MEM
      INTEGER NEXTJ0
      INTEGER NEXTI0
      EQUIVALENCE (MEM(1),JOBPO0(1))
      EQUIVALENCE (MEM(2),EVENV0(1))
      EQUIVALENCE (MEM(4),EVENW0(1))
      EQUIVALENCE (MEM(6),LINK(1))
      EQUIVALENCE (MEM(2),TIMEIN(1))
      EQUIVALENCE (MEM(4),QPRIO0(1))
      EQUIVALENCE (MEM(1),QUEUE0(1))
      EQUIVALENCE (MEM(2),MAXWA0(1))
      EQUIVALENCE (MEM(4),WAITT0(1))
      EQUIVALENCE (MEM(6),MAXLE0(1))
      EQUIVALENCE (MEM(7),QUEUF0(1))
      EQUIVALENCE (MEM(8),TIMEL0(1))
      EQUIVALENCE (MEM(10),LASTA0(1))
      EQUIVALENCE (MEM(12),ENTRY0(1))
      EQUIVALENCE (MEM(1),JOBPR0(1))
      EQUIVALENCE (MEM(2),ARRIV0(1))
      EQUIVALENCE (MEM(4),RECOR0(1))
      EQUIVALENCE (MEM(5),IOREQ0(1))
      EQUIVALENCE (MEM(6),MEMOT0(1))
      EQUIVALENCE (MEM(7),AVGIO0(1))
      EQUIVALENCE (MEM(9),INTER0(1))
      EQUIVALENCE (MEM(10),REMAI0(1))
      EQUIVALENCE (MEM(12),JOBNU0(1))
      IF((DISKO0.EQ.JOB))GOTO 10029
        CALL ERROR('In release_disk: can''t happen.')
10029 IF((EVENU0.NE.1))GOTO 10030
        CALL PRINT(-13,'Job *3i releasing disk   at *7,3f sec*n.',JOBNU0
     *(JOB),SYSTE0/1D6)
10030 DISKO0=0
      CALL UPDAV0
      NEXTJ0=NEXTI0(DISKQ0,QUEUE0(DISKQ0))
      IF((NEXTJ0.EQ.0))GOTO 10031
        CALL SCHED0(5,NEXTJ0,SYSTE0)
10031 CALL SCHED0(3,JOB,SYSTE0+OVERH0)
      RETURN
      END
      SUBROUTINE REQUE0(JOB)
      INTEGER JOB
      INTEGER EVENT0
      INTEGER CPUQU0
      INTEGER DISKQ0
      INTEGER MEMOR0
      INTEGER CPUOW0
      INTEGER DISKO0
      INTEGER AVAIL0
      INTEGER MAXME0
      INTEGER * 4 SIMUL0
      INTEGER * 4 SYSTE0
      INTEGER JOBSI0
      INTEGER JOBSC0
      INTEGER * 4 TOTAL0
      INTEGER * 4 TRANS0
      INTEGER * 4 ACCES0
      INTEGER * 4 LASTC0
      INTEGER * 4 LASTD0
      INTEGER * 4 LASTM0
      INTEGER * 4 CPUUT0
      INTEGER * 4 DISKU0
      REAL * 8 MEMOS0
      INTEGER * 4 MEANJ0
      INTEGER EVENU0
      INTEGER MINRE0
      INTEGER MAXRE0
      INTEGER IOMEAN
      INTEGER IOSTD0
      INTEGER CPUME0
      INTEGER CPUST0
      INTEGER * 4 OVERH0
      INTEGER * 4 RELOC0
      COMMON /CBASYS/EVENT0,CPUQU0,DISKQ0,MEMOR0,CPUOW0,DISKO0,AVAIL0,MA
     *XME0,SIMUL0,SYSTE0,JOBSI0,JOBSC0,TOTAL0,TRANS0,ACCES0,LASTC0,LASTD
     *0,LASTM0,CPUUT0,DISKU0,MEMOS0,MEANJ0,EVENU0,MINRE0,MAXRE0,IOMEAN,I
     *OSTD0,CPUME0,CPUST0,OVERH0,RELOC0
      INTEGER JOBPR0(1)
      INTEGER * 4 ARRIV0(1)
      INTEGER RECOR0(1)
      INTEGER IOREQ0(1)
      INTEGER MEMOT0(1)
      INTEGER * 4 AVGIO0(1)
      INTEGER INTER0(1)
      INTEGER * 4 REMAI0(1)
      INTEGER JOBNU0(1)
      INTEGER JOBPO0(1)
      INTEGER * 4 EVENV0(1)
      INTEGER * 4 EVENW0(1)
      INTEGER LINK(1)
      INTEGER * 4 TIMEIN(1)
      INTEGER * 4 QPRIO0(1)
      INTEGER QUEUE0(1)
      INTEGER * 4 MAXWA0(1)
      INTEGER * 4 WAITT0(1)
      INTEGER MAXLE0(1)
      INTEGER QUEUF0(1)
      INTEGER * 4 TIMEL0(1)
      INTEGER * 4 LASTA0(1)
      INTEGER ENTRY0(1)
      INTEGER MEM(8192)
      COMMON /DSMEM$/MEM
      INTEGER EVENT
      INTEGER * 4 TIME
      INTEGER * 4 EXPON0
      REAL * 8 TEMP
      EQUIVALENCE (MEM(1),JOBPO0(1))
      EQUIVALENCE (MEM(2),EVENV0(1))
      EQUIVALENCE (MEM(4),EVENW0(1))
      EQUIVALENCE (MEM(6),LINK(1))
      EQUIVALENCE (MEM(2),TIMEIN(1))
      EQUIVALENCE (MEM(4),QPRIO0(1))
      EQUIVALENCE (MEM(1),QUEUE0(1))
      EQUIVALENCE (MEM(2),MAXWA0(1))
      EQUIVALENCE (MEM(4),WAITT0(1))
      EQUIVALENCE (MEM(6),MAXLE0(1))
      EQUIVALENCE (MEM(7),QUEUF0(1))
      EQUIVALENCE (MEM(8),TIMEL0(1))
      EQUIVALENCE (MEM(10),LASTA0(1))
      EQUIVALENCE (MEM(12),ENTRY0(1))
      EQUIVALENCE (MEM(1),JOBPR0(1))
      EQUIVALENCE (MEM(2),ARRIV0(1))
      EQUIVALENCE (MEM(4),RECOR0(1))
      EQUIVALENCE (MEM(5),IOREQ0(1))
      EQUIVALENCE (MEM(6),MEMOT0(1))
      EQUIVALENCE (MEM(7),AVGIO0(1))
      EQUIVALENCE (MEM(9),INTER0(1))
      EQUIVALENCE (MEM(10),REMAI0(1))
      EQUIVALENCE (MEM(12),JOBNU0(1))
      TEMP=SYSTE0/1D6
      IF((CPUOW0.EQ.0))GOTO 10032
        IF((JOBPR0(CPUOW0).GT.JOBPR0(JOB)))GOTO 10033
          CALL AWAIT(JOB,CPUQU0,0)
          IF((EVENU0.NE.1))GOTO 10034
            CALL PRINT(-13,'Job *3i in  cpu   queue  at *7,3f sec*n.',JO
     *BNU0(JOB),TEMP)
10034     RETURN
10033     CALL CANCE0(CPUOW0,EVENT,TIME)
          INTER0(CPUOW0)=EVENT
          REMAI0(CPUOW0)=TIME-SYSTE0
          CALL AWAIT(CPUOW0,CPUQU0,1)
          IF((EVENU0.NE.1))GOTO 10035
            CALL PRINT(-13,'Job *3i  --interrupted-- at *7,3f sec*n.',JO
     *BNU0(CPUOW0),TEMP)
            CALL PRINT(-11,'Job *3i in  cpu   queue  at *7,3f sec*n.',JO
     *BNU0(CPUOW0),TEMP)
10035   CONTINUE
        GOTO 10036
10032   LASTC0=SYSTE0
10036 IF((EVENU0.NE.1))GOTO 10037
        CALL PRINT(-13,'Job *3i allocated cpu    at *7,3f sec*n.',JOBNU0
     *(JOB),TEMP)
10037 CPUOW0=JOB
      IF((INTER0(JOB).EQ.0))GOTO 10038
        EVENT=INTER0(JOB)
        TIME=SYSTE0+REMAI0(JOB)
        CALL SCHED0(EVENT,JOB,TIME)
        INTER0(JOB)=0
        GOTO 10039
10038   IF((IOREQ0(JOB).GT.0))GOTO 10040
          CALL SCHED0(7,JOB,SYSTE0)
          GOTO 10041
10040     IOREQ0(JOB)=IOREQ0(JOB)-1
          TIME=EXPON0(AVGIO0(JOB))
          CALL SCHED0(4,JOB,SYSTE0+TIME)
10041 CONTINUE
10039 RETURN
      END
      SUBROUTINE REQUF0(JOB)
      INTEGER JOB
      INTEGER EVENT0
      INTEGER CPUQU0
      INTEGER DISKQ0
      INTEGER MEMOR0
      INTEGER CPUOW0
      INTEGER DISKO0
      INTEGER AVAIL0
      INTEGER MAXME0
      INTEGER * 4 SIMUL0
      INTEGER * 4 SYSTE0
      INTEGER JOBSI0
      INTEGER JOBSC0
      INTEGER * 4 TOTAL0
      INTEGER * 4 TRANS0
      INTEGER * 4 ACCES0
      INTEGER * 4 LASTC0
      INTEGER * 4 LASTD0
      INTEGER * 4 LASTM0
      INTEGER * 4 CPUUT0
      INTEGER * 4 DISKU0
      REAL * 8 MEMOS0
      INTEGER * 4 MEANJ0
      INTEGER EVENU0
      INTEGER MINRE0
      INTEGER MAXRE0
      INTEGER IOMEAN
      INTEGER IOSTD0
      INTEGER CPUME0
      INTEGER CPUST0
      INTEGER * 4 OVERH0
      INTEGER * 4 RELOC0
      COMMON /CBASYS/EVENT0,CPUQU0,DISKQ0,MEMOR0,CPUOW0,DISKO0,AVAIL0,MA
     *XME0,SIMUL0,SYSTE0,JOBSI0,JOBSC0,TOTAL0,TRANS0,ACCES0,LASTC0,LASTD
     *0,LASTM0,CPUUT0,DISKU0,MEMOS0,MEANJ0,EVENU0,MINRE0,MAXRE0,IOMEAN,I
     *OSTD0,CPUME0,CPUST0,OVERH0,RELOC0
      INTEGER JOBPR0(1)
      INTEGER * 4 ARRIV0(1)
      INTEGER RECOR0(1)
      INTEGER IOREQ0(1)
      INTEGER MEMOT0(1)
      INTEGER * 4 AVGIO0(1)
      INTEGER INTER0(1)
      INTEGER * 4 REMAI0(1)
      INTEGER JOBNU0(1)
      INTEGER JOBPO0(1)
      INTEGER * 4 EVENV0(1)
      INTEGER * 4 EVENW0(1)
      INTEGER LINK(1)
      INTEGER * 4 TIMEIN(1)
      INTEGER * 4 QPRIO0(1)
      INTEGER QUEUE0(1)
      INTEGER * 4 MAXWA0(1)
      INTEGER * 4 WAITT0(1)
      INTEGER MAXLE0(1)
      INTEGER QUEUF0(1)
      INTEGER * 4 TIMEL0(1)
      INTEGER * 4 LASTA0(1)
      INTEGER ENTRY0(1)
      INTEGER MEM(8192)
      COMMON /DSMEM$/MEM
      INTEGER * 4 TIME
      EQUIVALENCE (MEM(1),JOBPO0(1))
      EQUIVALENCE (MEM(2),EVENV0(1))
      EQUIVALENCE (MEM(4),EVENW0(1))
      EQUIVALENCE (MEM(6),LINK(1))
      EQUIVALENCE (MEM(2),TIMEIN(1))
      EQUIVALENCE (MEM(4),QPRIO0(1))
      EQUIVALENCE (MEM(1),QUEUE0(1))
      EQUIVALENCE (MEM(2),MAXWA0(1))
      EQUIVALENCE (MEM(4),WAITT0(1))
      EQUIVALENCE (MEM(6),MAXLE0(1))
      EQUIVALENCE (MEM(7),QUEUF0(1))
      EQUIVALENCE (MEM(8),TIMEL0(1))
      EQUIVALENCE (MEM(10),LASTA0(1))
      EQUIVALENCE (MEM(12),ENTRY0(1))
      EQUIVALENCE (MEM(1),JOBPR0(1))
      EQUIVALENCE (MEM(2),ARRIV0(1))
      EQUIVALENCE (MEM(4),RECOR0(1))
      EQUIVALENCE (MEM(5),IOREQ0(1))
      EQUIVALENCE (MEM(6),MEMOT0(1))
      EQUIVALENCE (MEM(7),AVGIO0(1))
      EQUIVALENCE (MEM(9),INTER0(1))
      EQUIVALENCE (MEM(10),REMAI0(1))
      EQUIVALENCE (MEM(12),JOBNU0(1))
      IF((DISKO0.EQ.0))GOTO 10042
        CALL AWAIT(JOB,DISKQ0,0)
        IF((EVENU0.NE.1))GOTO 10043
          CALL PRINT(-13,'Job *3i in  disk  queue  at *7,3f sec*n.',JOBN
     *U0(JOB),SYSTE0/1D6)
10043   GOTO 10044
10042   IF((EVENU0.NE.1))GOTO 10045
          CALL PRINT(-13,'Job *3i allocated  disk  at *7,3f sec*n.',JOBN
     *U0(JOB),SYSTE0/1D6)
10045   LASTD0=SYSTE0
        DISKO0=JOB
        TIME=ACCES0+RECOR0(JOB)*TRANS0
        CALL SCHED0(6,JOB,SYSTE0+TIME)
10044 RETURN
      END
      SUBROUTINE REQUG0(JOB)
      INTEGER JOB
      INTEGER EVENT0
      INTEGER CPUQU0
      INTEGER DISKQ0
      INTEGER MEMOR0
      INTEGER CPUOW0
      INTEGER DISKO0
      INTEGER AVAIL0
      INTEGER MAXME0
      INTEGER * 4 SIMUL0
      INTEGER * 4 SYSTE0
      INTEGER JOBSI0
      INTEGER JOBSC0
      INTEGER * 4 TOTAL0
      INTEGER * 4 TRANS0
      INTEGER * 4 ACCES0
      INTEGER * 4 LASTC0
      INTEGER * 4 LASTD0
      INTEGER * 4 LASTM0
      INTEGER * 4 CPUUT0
      INTEGER * 4 DISKU0
      REAL * 8 MEMOS0
      INTEGER * 4 MEANJ0
      INTEGER EVENU0
      INTEGER MINRE0
      INTEGER MAXRE0
      INTEGER IOMEAN
      INTEGER IOSTD0
      INTEGER CPUME0
      INTEGER CPUST0
      INTEGER * 4 OVERH0
      INTEGER * 4 RELOC0
      COMMON /CBASYS/EVENT0,CPUQU0,DISKQ0,MEMOR0,CPUOW0,DISKO0,AVAIL0,MA
     *XME0,SIMUL0,SYSTE0,JOBSI0,JOBSC0,TOTAL0,TRANS0,ACCES0,LASTC0,LASTD
     *0,LASTM0,CPUUT0,DISKU0,MEMOS0,MEANJ0,EVENU0,MINRE0,MAXRE0,IOMEAN,I
     *OSTD0,CPUME0,CPUST0,OVERH0,RELOC0
      INTEGER JOBPR0(1)
      INTEGER * 4 ARRIV0(1)
      INTEGER RECOR0(1)
      INTEGER IOREQ0(1)
      INTEGER MEMOT0(1)
      INTEGER * 4 AVGIO0(1)
      INTEGER INTER0(1)
      INTEGER * 4 REMAI0(1)
      INTEGER JOBNU0(1)
      INTEGER JOBPO0(1)
      INTEGER * 4 EVENV0(1)
      INTEGER * 4 EVENW0(1)
      INTEGER LINK(1)
      INTEGER * 4 TIMEIN(1)
      INTEGER * 4 QPRIO0(1)
      INTEGER QUEUE0(1)
      INTEGER * 4 MAXWA0(1)
      INTEGER * 4 WAITT0(1)
      INTEGER MAXLE0(1)
      INTEGER QUEUF0(1)
      INTEGER * 4 TIMEL0(1)
      INTEGER * 4 LASTA0(1)
      INTEGER ENTRY0(1)
      INTEGER MEM(8192)
      COMMON /DSMEM$/MEM
      INTEGER * 4 TIME
      EQUIVALENCE (MEM(1),JOBPO0(1))
      EQUIVALENCE (MEM(2),EVENV0(1))
      EQUIVALENCE (MEM(4),EVENW0(1))
      EQUIVALENCE (MEM(6),LINK(1))
      EQUIVALENCE (MEM(2),TIMEIN(1))
      EQUIVALENCE (MEM(4),QPRIO0(1))
      EQUIVALENCE (MEM(1),QUEUE0(1))
      EQUIVALENCE (MEM(2),MAXWA0(1))
      EQUIVALENCE (MEM(4),WAITT0(1))
      EQUIVALENCE (MEM(6),MAXLE0(1))
      EQUIVALENCE (MEM(7),QUEUF0(1))
      EQUIVALENCE (MEM(8),TIMEL0(1))
      EQUIVALENCE (MEM(10),LASTA0(1))
      EQUIVALENCE (MEM(12),ENTRY0(1))
      EQUIVALENCE (MEM(1),JOBPR0(1))
      EQUIVALENCE (MEM(2),ARRIV0(1))
      EQUIVALENCE (MEM(4),RECOR0(1))
      EQUIVALENCE (MEM(5),IOREQ0(1))
      EQUIVALENCE (MEM(6),MEMOT0(1))
      EQUIVALENCE (MEM(7),AVGIO0(1))
      EQUIVALENCE (MEM(9),INTER0(1))
      EQUIVALENCE (MEM(10),REMAI0(1))
      EQUIVALENCE (MEM(12),JOBNU0(1))
      IF((MEMOT0(JOB).LE.AVAIL0))GOTO 10046
        CALL AWAIT(JOB,MEMOR0,0)
        IF((EVENU0.NE.1))GOTO 10047
          CALL PRINT(-13,'Job *3i in memory queue  at *7,3f sec*n.',JOBN
     *U0(JOB),SYSTE0/1D6)
10047   GOTO 10048
10046   IF((EVENU0.NE.1))GOTO 10049
          CALL PRINT(-13,'Job *3i allocated memory at *7,3f sec*n.',JOBN
     *U0(JOB),SYSTE0/1D6)
10049   CALL UPDAU0
        AVAIL0=AVAIL0-MEMOT0(JOB)
        LASTM0=SYSTE0
        TIME=SYSTE0+RELOC0
        CALL SCHED0(3,JOB,TIME)
10048 RETURN
      END
      SUBROUTINE SCHED0(EVENT,JOB,TIME)
      INTEGER EVENT
      INTEGER JOB
      INTEGER * 4 TIME
      INTEGER EVENT0
      INTEGER CPUQU0
      INTEGER DISKQ0
      INTEGER MEMOR0
      INTEGER CPUOW0
      INTEGER DISKO0
      INTEGER AVAIL0
      INTEGER MAXME0
      INTEGER * 4 SIMUL0
      INTEGER * 4 SYSTE0
      INTEGER JOBSI0
      INTEGER JOBSC0
      INTEGER * 4 TOTAL0
      INTEGER * 4 TRANS0
      INTEGER * 4 ACCES0
      INTEGER * 4 LASTC0
      INTEGER * 4 LASTD0
      INTEGER * 4 LASTM0
      INTEGER * 4 CPUUT0
      INTEGER * 4 DISKU0
      REAL * 8 MEMOS0
      INTEGER * 4 MEANJ0
      INTEGER EVENU0
      INTEGER MINRE0
      INTEGER MAXRE0
      INTEGER IOMEAN
      INTEGER IOSTD0
      INTEGER CPUME0
      INTEGER CPUST0
      INTEGER * 4 OVERH0
      INTEGER * 4 RELOC0
      COMMON /CBASYS/EVENT0,CPUQU0,DISKQ0,MEMOR0,CPUOW0,DISKO0,AVAIL0,MA
     *XME0,SIMUL0,SYSTE0,JOBSI0,JOBSC0,TOTAL0,TRANS0,ACCES0,LASTC0,LASTD
     *0,LASTM0,CPUUT0,DISKU0,MEMOS0,MEANJ0,EVENU0,MINRE0,MAXRE0,IOMEAN,I
     *OSTD0,CPUME0,CPUST0,OVERH0,RELOC0
      INTEGER JOBPR0(1)
      INTEGER * 4 ARRIV0(1)
      INTEGER RECOR0(1)
      INTEGER IOREQ0(1)
      INTEGER MEMOT0(1)
      INTEGER * 4 AVGIO0(1)
      INTEGER INTER0(1)
      INTEGER * 4 REMAI0(1)
      INTEGER JOBNU0(1)
      INTEGER JOBPO0(1)
      INTEGER * 4 EVENV0(1)
      INTEGER * 4 EVENW0(1)
      INTEGER LINK(1)
      INTEGER * 4 TIMEIN(1)
      INTEGER * 4 QPRIO0(1)
      INTEGER QUEUE0(1)
      INTEGER * 4 MAXWA0(1)
      INTEGER * 4 WAITT0(1)
      INTEGER MAXLE0(1)
      INTEGER QUEUF0(1)
      INTEGER * 4 TIMEL0(1)
      INTEGER * 4 LASTA0(1)
      INTEGER ENTRY0(1)
      INTEGER MEM(8192)
      COMMON /DSMEM$/MEM
      INTEGER ENTRY
      INTEGER ALLOC
      EQUIVALENCE (MEM(1),JOBPO0(1))
      EQUIVALENCE (MEM(2),EVENV0(1))
      EQUIVALENCE (MEM(4),EVENW0(1))
      EQUIVALENCE (MEM(6),LINK(1))
      EQUIVALENCE (MEM(2),TIMEIN(1))
      EQUIVALENCE (MEM(4),QPRIO0(1))
      EQUIVALENCE (MEM(1),QUEUE0(1))
      EQUIVALENCE (MEM(2),MAXWA0(1))
      EQUIVALENCE (MEM(4),WAITT0(1))
      EQUIVALENCE (MEM(6),MAXLE0(1))
      EQUIVALENCE (MEM(7),QUEUF0(1))
      EQUIVALENCE (MEM(8),TIMEL0(1))
      EQUIVALENCE (MEM(10),LASTA0(1))
      EQUIVALENCE (MEM(12),ENTRY0(1))
      EQUIVALENCE (MEM(1),JOBPR0(1))
      EQUIVALENCE (MEM(2),ARRIV0(1))
      EQUIVALENCE (MEM(4),RECOR0(1))
      EQUIVALENCE (MEM(5),IOREQ0(1))
      EQUIVALENCE (MEM(6),MEMOT0(1))
      EQUIVALENCE (MEM(7),AVGIO0(1))
      EQUIVALENCE (MEM(9),INTER0(1))
      EQUIVALENCE (MEM(10),REMAI0(1))
      EQUIVALENCE (MEM(12),JOBNU0(1))
      ENTRY=ALLOC(6)
      JOBPO0(ENTRY)=JOB
      EVENV0(ENTRY)=EVENT
      EVENW0(ENTRY)=TIME
      CALL ENQUE0(ENTRY,EVENT0,0)
      IF((EVENU0.NE.1))GOTO 10050
        GOTO 10051
10053     CALL PRINT(-13,'       arrival .')
          GOTO 10052
10054     CALL PRINT(-13,'memory request .')
          GOTO 10052
10055     CALL PRINT(-13,'   cpu request .')
          GOTO 10052
10056     CALL PRINT(-13,'   cpu release .')
          GOTO 10052
10057     CALL PRINT(-13,'  disk request .')
          GOTO 10052
10058     CALL PRINT(-13,'  disk release .')
          GOTO 10052
10059     CALL PRINT(-13,'   termination .')
          GOTO 10052
10060   CONTINUE
10051   GOTO(10053,10054,10055,10056,10057,10058,10059),EVENT
          CALL PRINT(-13,' unknown event .')
10052   CALL PRINT(-13,'of job *3i scheduled for *10l*n.',JOBNU0(JOB),TI
     *ME)
10050 RETURN
      END
      SUBROUTINE SCHEE0
      INTEGER EVENT0
      INTEGER CPUQU0
      INTEGER DISKQ0
      INTEGER MEMOR0
      INTEGER CPUOW0
      INTEGER DISKO0
      INTEGER AVAIL0
      INTEGER MAXME0
      INTEGER * 4 SIMUL0
      INTEGER * 4 SYSTE0
      INTEGER JOBSI0
      INTEGER JOBSC0
      INTEGER * 4 TOTAL0
      INTEGER * 4 TRANS0
      INTEGER * 4 ACCES0
      INTEGER * 4 LASTC0
      INTEGER * 4 LASTD0
      INTEGER * 4 LASTM0
      INTEGER * 4 CPUUT0
      INTEGER * 4 DISKU0
      REAL * 8 MEMOS0
      INTEGER * 4 MEANJ0
      INTEGER EVENU0
      INTEGER MINRE0
      INTEGER MAXRE0
      INTEGER IOMEAN
      INTEGER IOSTD0
      INTEGER CPUME0
      INTEGER CPUST0
      INTEGER * 4 OVERH0
      INTEGER * 4 RELOC0
      COMMON /CBASYS/EVENT0,CPUQU0,DISKQ0,MEMOR0,CPUOW0,DISKO0,AVAIL0,MA
     *XME0,SIMUL0,SYSTE0,JOBSI0,JOBSC0,TOTAL0,TRANS0,ACCES0,LASTC0,LASTD
     *0,LASTM0,CPUUT0,DISKU0,MEMOS0,MEANJ0,EVENU0,MINRE0,MAXRE0,IOMEAN,I
     *OSTD0,CPUME0,CPUST0,OVERH0,RELOC0
      INTEGER JOBPR0(1)
      INTEGER * 4 ARRIV0(1)
      INTEGER RECOR0(1)
      INTEGER IOREQ0(1)
      INTEGER MEMOT0(1)
      INTEGER * 4 AVGIO0(1)
      INTEGER INTER0(1)
      INTEGER * 4 REMAI0(1)
      INTEGER JOBNU0(1)
      INTEGER JOBPO0(1)
      INTEGER * 4 EVENV0(1)
      INTEGER * 4 EVENW0(1)
      INTEGER LINK(1)
      INTEGER * 4 TIMEIN(1)
      INTEGER * 4 QPRIO0(1)
      INTEGER QUEUE0(1)
      INTEGER * 4 MAXWA0(1)
      INTEGER * 4 WAITT0(1)
      INTEGER MAXLE0(1)
      INTEGER QUEUF0(1)
      INTEGER * 4 TIMEL0(1)
      INTEGER * 4 LASTA0(1)
      INTEGER ENTRY0(1)
      INTEGER MEM(8192)
      COMMON /DSMEM$/MEM
      INTEGER EVENT
      INTEGER * 4 TIME
      INTEGER JOB
      EQUIVALENCE (MEM(1),JOBPO0(1))
      EQUIVALENCE (MEM(2),EVENV0(1))
      EQUIVALENCE (MEM(4),EVENW0(1))
      EQUIVALENCE (MEM(6),LINK(1))
      EQUIVALENCE (MEM(2),TIMEIN(1))
      EQUIVALENCE (MEM(4),QPRIO0(1))
      EQUIVALENCE (MEM(1),QUEUE0(1))
      EQUIVALENCE (MEM(2),MAXWA0(1))
      EQUIVALENCE (MEM(4),WAITT0(1))
      EQUIVALENCE (MEM(6),MAXLE0(1))
      EQUIVALENCE (MEM(7),QUEUF0(1))
      EQUIVALENCE (MEM(8),TIMEL0(1))
      EQUIVALENCE (MEM(10),LASTA0(1))
      EQUIVALENCE (MEM(12),ENTRY0(1))
      EQUIVALENCE (MEM(1),JOBPR0(1))
      EQUIVALENCE (MEM(2),ARRIV0(1))
      EQUIVALENCE (MEM(4),RECOR0(1))
      EQUIVALENCE (MEM(5),IOREQ0(1))
      EQUIVALENCE (MEM(6),MEMOT0(1))
      EQUIVALENCE (MEM(7),AVGIO0(1))
      EQUIVALENCE (MEM(9),INTER0(1))
      EQUIVALENCE (MEM(10),REMAI0(1))
      EQUIVALENCE (MEM(12),JOBNU0(1))
10153   CALL NEXTE0(EVENT,JOB,TIME)
        SYSTE0=TIME
        IF((SYSTE0.LT.SIMUL0))GOTO 10154
          GOTO 10155
10154   GOTO 10156
10158     CALL JOBAR0(JOB)
          GOTO 10157
10159     CALL REQUG0(JOB)
          GOTO 10157
10160     CALL REQUE0(JOB)
          GOTO 10157
10161     CALL RELEA0(JOB)
          GOTO 10157
10162     CALL REQUF0(JOB)
          GOTO 10157
10163     CALL RELEB0(JOB)
          GOTO 10157
10164     CALL ENDJOB(JOB)
          GOTO 10157
10165   CONTINUE
10156   GOTO(10158,10159,10160,10161,10162,10163,10164),EVENT
          CALL ERROR('In scheduler: can''t happen.')
10157 CONTINUE
      GOTO 10153
10155 RETURN
      END
      SUBROUTINE SETJO0(JOB)
      INTEGER JOB
      INTEGER EVENT0
      INTEGER CPUQU0
      INTEGER DISKQ0
      INTEGER MEMOR0
      INTEGER CPUOW0
      INTEGER DISKO0
      INTEGER AVAIL0
      INTEGER MAXME0
      INTEGER * 4 SIMUL0
      INTEGER * 4 SYSTE0
      INTEGER JOBSI0
      INTEGER JOBSC0
      INTEGER * 4 TOTAL0
      INTEGER * 4 TRANS0
      INTEGER * 4 ACCES0
      INTEGER * 4 LASTC0
      INTEGER * 4 LASTD0
      INTEGER * 4 LASTM0
      INTEGER * 4 CPUUT0
      INTEGER * 4 DISKU0
      REAL * 8 MEMOS0
      INTEGER * 4 MEANJ0
      INTEGER EVENU0
      INTEGER MINRE0
      INTEGER MAXRE0
      INTEGER IOMEAN
      INTEGER IOSTD0
      INTEGER CPUME0
      INTEGER CPUST0
      INTEGER * 4 OVERH0
      INTEGER * 4 RELOC0
      COMMON /CBASYS/EVENT0,CPUQU0,DISKQ0,MEMOR0,CPUOW0,DISKO0,AVAIL0,MA
     *XME0,SIMUL0,SYSTE0,JOBSI0,JOBSC0,TOTAL0,TRANS0,ACCES0,LASTC0,LASTD
     *0,LASTM0,CPUUT0,DISKU0,MEMOS0,MEANJ0,EVENU0,MINRE0,MAXRE0,IOMEAN,I
     *OSTD0,CPUME0,CPUST0,OVERH0,RELOC0
      INTEGER JOBPR0(1)
      INTEGER * 4 ARRIV0(1)
      INTEGER RECOR0(1)
      INTEGER IOREQ0(1)
      INTEGER MEMOT0(1)
      INTEGER * 4 AVGIO0(1)
      INTEGER INTER0(1)
      INTEGER * 4 REMAI0(1)
      INTEGER JOBNU0(1)
      INTEGER JOBPO0(1)
      INTEGER * 4 EVENV0(1)
      INTEGER * 4 EVENW0(1)
      INTEGER LINK(1)
      INTEGER * 4 TIMEIN(1)
      INTEGER * 4 QPRIO0(1)
      INTEGER QUEUE0(1)
      INTEGER * 4 MAXWA0(1)
      INTEGER * 4 WAITT0(1)
      INTEGER MAXLE0(1)
      INTEGER QUEUF0(1)
      INTEGER * 4 TIMEL0(1)
      INTEGER * 4 LASTA0(1)
      INTEGER ENTRY0(1)
      INTEGER MEM(8192)
      COMMON /DSMEM$/MEM
      INTEGER UNIFO0,NORMAL
      INTEGER * 4 CPUTI0
      INTEGER MEMOU0(102)
      EQUIVALENCE (MEM(1),JOBPO0(1))
      EQUIVALENCE (MEM(2),EVENV0(1))
      EQUIVALENCE (MEM(4),EVENW0(1))
      EQUIVALENCE (MEM(6),LINK(1))
      EQUIVALENCE (MEM(2),TIMEIN(1))
      EQUIVALENCE (MEM(4),QPRIO0(1))
      EQUIVALENCE (MEM(1),QUEUE0(1))
      EQUIVALENCE (MEM(2),MAXWA0(1))
      EQUIVALENCE (MEM(4),WAITT0(1))
      EQUIVALENCE (MEM(6),MAXLE0(1))
      EQUIVALENCE (MEM(7),QUEUF0(1))
      EQUIVALENCE (MEM(8),TIMEL0(1))
      EQUIVALENCE (MEM(10),LASTA0(1))
      EQUIVALENCE (MEM(12),ENTRY0(1))
      EQUIVALENCE (MEM(1),JOBPR0(1))
      EQUIVALENCE (MEM(2),ARRIV0(1))
      EQUIVALENCE (MEM(4),RECOR0(1))
      EQUIVALENCE (MEM(5),IOREQ0(1))
      EQUIVALENCE (MEM(6),MEMOT0(1))
      EQUIVALENCE (MEM(7),AVGIO0(1))
      EQUIVALENCE (MEM(9),INTER0(1))
      EQUIVALENCE (MEM(10),REMAI0(1))
      EQUIVALENCE (MEM(12),JOBNU0(1))
      DATA MEMOU0/2*2,1*4,1*6,1*8,1*10,1*12,1*14,1*16,1*18,1*20,4*22,4*2
     *4,4*26,4*28,4*30,8*32,8*34,8*36,8*38,8*40,4*42,4*44,4*46,4*48,4*50
     *,1*52,1*54,1*56,1*58,1*60,1*62,1*64,1*66,1*68,2*70/
      JOBNU0(JOB)=JOBSI0
      JOBPR0(JOB)=UNIFO0(0,15)
      RECOR0(JOB)=UNIFO0(MINRE0,MAXRE0)
      IOREQ0(JOB)=NORMAL(IOMEAN,IOSTD0)
      MEMOT0(JOB)=MEMOU0(UNIFO0(1,102))
      CPUTI0=NORMAL(CPUME0,CPUST0)*INTL(1000)
      AVGIO0(JOB)=CPUTI0/IOREQ0(JOB)
      INTER0(JOB)=0
      RETURN
      END
      SUBROUTINE SUMMB0(JOB)
      INTEGER EVENT0
      INTEGER CPUQU0
      INTEGER DISKQ0
      INTEGER MEMOR0
      INTEGER CPUOW0
      INTEGER DISKO0
      INTEGER AVAIL0
      INTEGER MAXME0
      INTEGER * 4 SIMUL0
      INTEGER * 4 SYSTE0
      INTEGER JOBSI0
      INTEGER JOBSC0
      INTEGER * 4 TOTAL0
      INTEGER * 4 TRANS0
      INTEGER * 4 ACCES0
      INTEGER * 4 LASTC0
      INTEGER * 4 LASTD0
      INTEGER * 4 LASTM0
      INTEGER * 4 CPUUT0
      INTEGER * 4 DISKU0
      REAL * 8 MEMOS0
      INTEGER * 4 MEANJ0
      INTEGER EVENU0
      INTEGER MINRE0
      INTEGER MAXRE0
      INTEGER IOMEAN
      INTEGER IOSTD0
      INTEGER CPUME0
      INTEGER CPUST0
      INTEGER * 4 OVERH0
      INTEGER * 4 RELOC0
      COMMON /CBASYS/EVENT0,CPUQU0,DISKQ0,MEMOR0,CPUOW0,DISKO0,AVAIL0,MA
     *XME0,SIMUL0,SYSTE0,JOBSI0,JOBSC0,TOTAL0,TRANS0,ACCES0,LASTC0,LASTD
     *0,LASTM0,CPUUT0,DISKU0,MEMOS0,MEANJ0,EVENU0,MINRE0,MAXRE0,IOMEAN,I
     *OSTD0,CPUME0,CPUST0,OVERH0,RELOC0
      INTEGER JOBPR0(1)
      INTEGER * 4 ARRIV0(1)
      INTEGER RECOR0(1)
      INTEGER IOREQ0(1)
      INTEGER MEMOT0(1)
      INTEGER * 4 AVGIO0(1)
      INTEGER INTER0(1)
      INTEGER * 4 REMAI0(1)
      INTEGER JOBNU0(1)
      INTEGER JOBPO0(1)
      INTEGER * 4 EVENV0(1)
      INTEGER * 4 EVENW0(1)
      INTEGER LINK(1)
      INTEGER * 4 TIMEIN(1)
      INTEGER * 4 QPRIO0(1)
      INTEGER QUEUE0(1)
      INTEGER * 4 MAXWA0(1)
      INTEGER * 4 WAITT0(1)
      INTEGER MAXLE0(1)
      INTEGER QUEUF0(1)
      INTEGER * 4 TIMEL0(1)
      INTEGER * 4 LASTA0(1)
      INTEGER ENTRY0(1)
      INTEGER MEM(8192)
      COMMON /DSMEM$/MEM
      EQUIVALENCE (MEM(1),JOBPO0(1))
      EQUIVALENCE (MEM(2),EVENV0(1))
      EQUIVALENCE (MEM(4),EVENW0(1))
      EQUIVALENCE (MEM(6),LINK(1))
      EQUIVALENCE (MEM(2),TIMEIN(1))
      EQUIVALENCE (MEM(4),QPRIO0(1))
      EQUIVALENCE (MEM(1),QUEUE0(1))
      EQUIVALENCE (MEM(2),MAXWA0(1))
      EQUIVALENCE (MEM(4),WAITT0(1))
      EQUIVALENCE (MEM(6),MAXLE0(1))
      EQUIVALENCE (MEM(7),QUEUF0(1))
      EQUIVALENCE (MEM(8),TIMEL0(1))
      EQUIVALENCE (MEM(10),LASTA0(1))
      EQUIVALENCE (MEM(12),ENTRY0(1))
      EQUIVALENCE (MEM(1),JOBPR0(1))
      EQUIVALENCE (MEM(2),ARRIV0(1))
      EQUIVALENCE (MEM(4),RECOR0(1))
      EQUIVALENCE (MEM(5),IOREQ0(1))
      EQUIVALENCE (MEM(6),MEMOT0(1))
      EQUIVALENCE (MEM(7),AVGIO0(1))
      EQUIVALENCE (MEM(9),INTER0(1))
      EQUIVALENCE (MEM(10),REMAI0(1))
      EQUIVALENCE (MEM(12),JOBNU0(1))
      TOTAL0=TOTAL0+(SYSTE0-ARRIV0(JOB))
      RETURN
      END
      SUBROUTINE SUMMA0
      INTEGER EVENT0
      INTEGER CPUQU0
      INTEGER DISKQ0
      INTEGER MEMOR0
      INTEGER CPUOW0
      INTEGER DISKO0
      INTEGER AVAIL0
      INTEGER MAXME0
      INTEGER * 4 SIMUL0
      INTEGER * 4 SYSTE0
      INTEGER JOBSI0
      INTEGER JOBSC0
      INTEGER * 4 TOTAL0
      INTEGER * 4 TRANS0
      INTEGER * 4 ACCES0
      INTEGER * 4 LASTC0
      INTEGER * 4 LASTD0
      INTEGER * 4 LASTM0
      INTEGER * 4 CPUUT0
      INTEGER * 4 DISKU0
      REAL * 8 MEMOS0
      INTEGER * 4 MEANJ0
      INTEGER EVENU0
      INTEGER MINRE0
      INTEGER MAXRE0
      INTEGER IOMEAN
      INTEGER IOSTD0
      INTEGER CPUME0
      INTEGER CPUST0
      INTEGER * 4 OVERH0
      INTEGER * 4 RELOC0
      COMMON /CBASYS/EVENT0,CPUQU0,DISKQ0,MEMOR0,CPUOW0,DISKO0,AVAIL0,MA
     *XME0,SIMUL0,SYSTE0,JOBSI0,JOBSC0,TOTAL0,TRANS0,ACCES0,LASTC0,LASTD
     *0,LASTM0,CPUUT0,DISKU0,MEMOS0,MEANJ0,EVENU0,MINRE0,MAXRE0,IOMEAN,I
     *OSTD0,CPUME0,CPUST0,OVERH0,RELOC0
      INTEGER JOBPR0(1)
      INTEGER * 4 ARRIV0(1)
      INTEGER RECOR0(1)
      INTEGER IOREQ0(1)
      INTEGER MEMOT0(1)
      INTEGER * 4 AVGIO0(1)
      INTEGER INTER0(1)
      INTEGER * 4 REMAI0(1)
      INTEGER JOBNU0(1)
      INTEGER JOBPO0(1)
      INTEGER * 4 EVENV0(1)
      INTEGER * 4 EVENW0(1)
      INTEGER LINK(1)
      INTEGER * 4 TIMEIN(1)
      INTEGER * 4 QPRIO0(1)
      INTEGER QUEUE0(1)
      INTEGER * 4 MAXWA0(1)
      INTEGER * 4 WAITT0(1)
      INTEGER MAXLE0(1)
      INTEGER QUEUF0(1)
      INTEGER * 4 TIMEL0(1)
      INTEGER * 4 LASTA0(1)
      INTEGER ENTRY0(1)
      INTEGER MEM(8192)
      COMMON /DSMEM$/MEM
      REAL * 8 TEMP
      EQUIVALENCE (MEM(1),JOBPO0(1))
      EQUIVALENCE (MEM(2),EVENV0(1))
      EQUIVALENCE (MEM(4),EVENW0(1))
      EQUIVALENCE (MEM(6),LINK(1))
      EQUIVALENCE (MEM(2),TIMEIN(1))
      EQUIVALENCE (MEM(4),QPRIO0(1))
      EQUIVALENCE (MEM(1),QUEUE0(1))
      EQUIVALENCE (MEM(2),MAXWA0(1))
      EQUIVALENCE (MEM(4),WAITT0(1))
      EQUIVALENCE (MEM(6),MAXLE0(1))
      EQUIVALENCE (MEM(7),QUEUF0(1))
      EQUIVALENCE (MEM(8),TIMEL0(1))
      EQUIVALENCE (MEM(10),LASTA0(1))
      EQUIVALENCE (MEM(12),ENTRY0(1))
      EQUIVALENCE (MEM(1),JOBPR0(1))
      EQUIVALENCE (MEM(2),ARRIV0(1))
      EQUIVALENCE (MEM(4),RECOR0(1))
      EQUIVALENCE (MEM(5),IOREQ0(1))
      EQUIVALENCE (MEM(6),MEMOT0(1))
      EQUIVALENCE (MEM(7),AVGIO0(1))
      EQUIVALENCE (MEM(9),INTER0(1))
      EQUIVALENCE (MEM(10),REMAI0(1))
      EQUIVALENCE (MEM(12),JOBNU0(1))
      IF((SYSTE0.GT.0))GOTO 10258
        RETURN
10258 CALL UPDAT0
      CALL UPDAV0
      CALL UPDAU0
      TEMP=SYSTE0
      CALL PRINT(-11,'*n*n*nActual simulation length: *7,3f sec*n*n.',TE
     *MP/1D6)
      CALL PRINT(-11,'*i jobs initiated, *i jobs completed*n.',JOBSI0,JO
     *BSC0)
      IF((JOBSC0.LE.0))GOTO 10259
        CALL PRINT(-11,'Average time per job: *7,3f sec*n*n.',(TOTAL0/1D
     *6)/JOBSC0)
10259 CALL PRINT(-11,'*6,2f% cpu utilization*n.',(CPUUT0/TEMP)*1D2)
      CALL PRINT(-11,'*6,2f% disk utilization*n.',(DISKU0/TEMP)*1D2)
      CALL PRINT(-11,'*6,2f% memory utilization*n.',(MEMOS0/(TEMP*MAXME0
     *))*1D2)
      CALL UPDAW0(MEMOR0)
      IF((ENTRY0(MEMOR0).LE.0))GOTO 10260
        CALL PRINT(-11,'*nMemory queue statistics (based on *i entries):
     **n.',ENTRY0(MEMOR0))
        CALL PRINT(-11,'   maximum wait time:    *7,3f sec*n.',MAXWA0(ME
     *MOR0)/1D6)
        CALL PRINT(-11,'   mean wait time:       *7,3f sec*n.',(WAITT0(M
     *EMOR0)/1D6)/ENTRY0(MEMOR0))
        CALL PRINT(-11,'   maximum queue length: *7i*n.',MAXLE0(MEMOR0))
        CALL PRINT(-11,'   mean queue length:    *7,3f*n.',TIMEL0(MEMOR0
     *)/TEMP)
        GOTO 10261
10260   CALL PRINT(-11,'*nMemory queue not used*n.')
10261 CALL FREE(QUEUE0(MEMOR0))
      CALL FREE(MEMOR0)
      CALL UPDAW0(CPUQU0)
      IF((ENTRY0(CPUQU0).LE.0))GOTO 10262
        CALL PRINT(-11,'*nCPU queue statistics (based on *i entries):*n.
     *',ENTRY0(CPUQU0))
        CALL PRINT(-11,'   maximum wait time:    *7,3f sec*n.',MAXWA0(CP
     *UQU0)/1D6)
        CALL PRINT(-11,'   mean wait time:       *7,3f sec*n.',(WAITT0(C
     *PUQU0)/1D6)/ENTRY0(CPUQU0))
        CALL PRINT(-11,'   maximum queue length: *7i*n.',MAXLE0(CPUQU0))
        CALL PRINT(-11,'   mean queue length:    *7,3f*n.',TIMEL0(CPUQU0
     *)/TEMP)
        GOTO 10263
10262   CALL PRINT(-11,'*nCPU queue not used*n.')
10263 CALL FREE(QUEUE0(CPUQU0))
      CALL FREE(CPUQU0)
      CALL UPDAW0(DISKQ0)
      IF((ENTRY0(DISKQ0).LE.0))GOTO 10264
        CALL PRINT(-11,'*nDisk queue statistics (based on *i entries):*n
     *.',ENTRY0(DISKQ0))
        CALL PRINT(-11,'   maximum wait time:    *7,3f sec*n.',MAXWA0(DI
     *SKQ0)/1D6)
        CALL PRINT(-11,'   mean wait time:       *7,3f sec*n.',(WAITT0(D
     *ISKQ0)/1D6)/ENTRY0(DISKQ0))
        CALL PRINT(-11,'   maximum queue length: *7i*n.',MAXLE0(DISKQ0))
        CALL PRINT(-11,'   mean queue length:    *7,3f*n.',TIMEL0(DISKQ0
     *)/TEMP)
        GOTO 10265
10264   CALL PRINT(-11,'*nDisk queue not used*n.')
10265 CALL FREE(QUEUE0(DISKQ0))
      CALL FREE(DISKQ0)
      RETURN
      END
      INTEGER FUNCTION UNIFO0(LWB,UPB)
      INTEGER LWB,UPB
      UNIFO0=LWB+(UPB-LWB)*RND(0)
      RETURN
      END
      SUBROUTINE UPDAT0
      INTEGER EVENT0
      INTEGER CPUQU0
      INTEGER DISKQ0
      INTEGER MEMOR0
      INTEGER CPUOW0
      INTEGER DISKO0
      INTEGER AVAIL0
      INTEGER MAXME0
      INTEGER * 4 SIMUL0
      INTEGER * 4 SYSTE0
      INTEGER JOBSI0
      INTEGER JOBSC0
      INTEGER * 4 TOTAL0
      INTEGER * 4 TRANS0
      INTEGER * 4 ACCES0
      INTEGER * 4 LASTC0
      INTEGER * 4 LASTD0
      INTEGER * 4 LASTM0
      INTEGER * 4 CPUUT0
      INTEGER * 4 DISKU0
      REAL * 8 MEMOS0
      INTEGER * 4 MEANJ0
      INTEGER EVENU0
      INTEGER MINRE0
      INTEGER MAXRE0
      INTEGER IOMEAN
      INTEGER IOSTD0
      INTEGER CPUME0
      INTEGER CPUST0
      INTEGER * 4 OVERH0
      INTEGER * 4 RELOC0
      COMMON /CBASYS/EVENT0,CPUQU0,DISKQ0,MEMOR0,CPUOW0,DISKO0,AVAIL0,MA
     *XME0,SIMUL0,SYSTE0,JOBSI0,JOBSC0,TOTAL0,TRANS0,ACCES0,LASTC0,LASTD
     *0,LASTM0,CPUUT0,DISKU0,MEMOS0,MEANJ0,EVENU0,MINRE0,MAXRE0,IOMEAN,I
     *OSTD0,CPUME0,CPUST0,OVERH0,RELOC0
      INTEGER JOBPR0(1)
      INTEGER * 4 ARRIV0(1)
      INTEGER RECOR0(1)
      INTEGER IOREQ0(1)
      INTEGER MEMOT0(1)
      INTEGER * 4 AVGIO0(1)
      INTEGER INTER0(1)
      INTEGER * 4 REMAI0(1)
      INTEGER JOBNU0(1)
      INTEGER JOBPO0(1)
      INTEGER * 4 EVENV0(1)
      INTEGER * 4 EVENW0(1)
      INTEGER LINK(1)
      INTEGER * 4 TIMEIN(1)
      INTEGER * 4 QPRIO0(1)
      INTEGER QUEUE0(1)
      INTEGER * 4 MAXWA0(1)
      INTEGER * 4 WAITT0(1)
      INTEGER MAXLE0(1)
      INTEGER QUEUF0(1)
      INTEGER * 4 TIMEL0(1)
      INTEGER * 4 LASTA0(1)
      INTEGER ENTRY0(1)
      INTEGER MEM(8192)
      COMMON /DSMEM$/MEM
      EQUIVALENCE (MEM(1),JOBPO0(1))
      EQUIVALENCE (MEM(2),EVENV0(1))
      EQUIVALENCE (MEM(4),EVENW0(1))
      EQUIVALENCE (MEM(6),LINK(1))
      EQUIVALENCE (MEM(2),TIMEIN(1))
      EQUIVALENCE (MEM(4),QPRIO0(1))
      EQUIVALENCE (MEM(1),QUEUE0(1))
      EQUIVALENCE (MEM(2),MAXWA0(1))
      EQUIVALENCE (MEM(4),WAITT0(1))
      EQUIVALENCE (MEM(6),MAXLE0(1))
      EQUIVALENCE (MEM(7),QUEUF0(1))
      EQUIVALENCE (MEM(8),TIMEL0(1))
      EQUIVALENCE (MEM(10),LASTA0(1))
      EQUIVALENCE (MEM(12),ENTRY0(1))
      EQUIVALENCE (MEM(1),JOBPR0(1))
      EQUIVALENCE (MEM(2),ARRIV0(1))
      EQUIVALENCE (MEM(4),RECOR0(1))
      EQUIVALENCE (MEM(5),IOREQ0(1))
      EQUIVALENCE (MEM(6),MEMOT0(1))
      EQUIVALENCE (MEM(7),AVGIO0(1))
      EQUIVALENCE (MEM(9),INTER0(1))
      EQUIVALENCE (MEM(10),REMAI0(1))
      EQUIVALENCE (MEM(12),JOBNU0(1))
      CPUUT0=CPUUT0+(SYSTE0-LASTC0)
      RETURN
      END
      SUBROUTINE UPDAV0
      INTEGER EVENT0
      INTEGER CPUQU0
      INTEGER DISKQ0
      INTEGER MEMOR0
      INTEGER CPUOW0
      INTEGER DISKO0
      INTEGER AVAIL0
      INTEGER MAXME0
      INTEGER * 4 SIMUL0
      INTEGER * 4 SYSTE0
      INTEGER JOBSI0
      INTEGER JOBSC0
      INTEGER * 4 TOTAL0
      INTEGER * 4 TRANS0
      INTEGER * 4 ACCES0
      INTEGER * 4 LASTC0
      INTEGER * 4 LASTD0
      INTEGER * 4 LASTM0
      INTEGER * 4 CPUUT0
      INTEGER * 4 DISKU0
      REAL * 8 MEMOS0
      INTEGER * 4 MEANJ0
      INTEGER EVENU0
      INTEGER MINRE0
      INTEGER MAXRE0
      INTEGER IOMEAN
      INTEGER IOSTD0
      INTEGER CPUME0
      INTEGER CPUST0
      INTEGER * 4 OVERH0
      INTEGER * 4 RELOC0
      COMMON /CBASYS/EVENT0,CPUQU0,DISKQ0,MEMOR0,CPUOW0,DISKO0,AVAIL0,MA
     *XME0,SIMUL0,SYSTE0,JOBSI0,JOBSC0,TOTAL0,TRANS0,ACCES0,LASTC0,LASTD
     *0,LASTM0,CPUUT0,DISKU0,MEMOS0,MEANJ0,EVENU0,MINRE0,MAXRE0,IOMEAN,I
     *OSTD0,CPUME0,CPUST0,OVERH0,RELOC0
      INTEGER JOBPR0(1)
      INTEGER * 4 ARRIV0(1)
      INTEGER RECOR0(1)
      INTEGER IOREQ0(1)
      INTEGER MEMOT0(1)
      INTEGER * 4 AVGIO0(1)
      INTEGER INTER0(1)
      INTEGER * 4 REMAI0(1)
      INTEGER JOBNU0(1)
      INTEGER JOBPO0(1)
      INTEGER * 4 EVENV0(1)
      INTEGER * 4 EVENW0(1)
      INTEGER LINK(1)
      INTEGER * 4 TIMEIN(1)
      INTEGER * 4 QPRIO0(1)
      INTEGER QUEUE0(1)
      INTEGER * 4 MAXWA0(1)
      INTEGER * 4 WAITT0(1)
      INTEGER MAXLE0(1)
      INTEGER QUEUF0(1)
      INTEGER * 4 TIMEL0(1)
      INTEGER * 4 LASTA0(1)
      INTEGER ENTRY0(1)
      INTEGER MEM(8192)
      COMMON /DSMEM$/MEM
      EQUIVALENCE (MEM(1),JOBPO0(1))
      EQUIVALENCE (MEM(2),EVENV0(1))
      EQUIVALENCE (MEM(4),EVENW0(1))
      EQUIVALENCE (MEM(6),LINK(1))
      EQUIVALENCE (MEM(2),TIMEIN(1))
      EQUIVALENCE (MEM(4),QPRIO0(1))
      EQUIVALENCE (MEM(1),QUEUE0(1))
      EQUIVALENCE (MEM(2),MAXWA0(1))
      EQUIVALENCE (MEM(4),WAITT0(1))
      EQUIVALENCE (MEM(6),MAXLE0(1))
      EQUIVALENCE (MEM(7),QUEUF0(1))
      EQUIVALENCE (MEM(8),TIMEL0(1))
      EQUIVALENCE (MEM(10),LASTA0(1))
      EQUIVALENCE (MEM(12),ENTRY0(1))
      EQUIVALENCE (MEM(1),JOBPR0(1))
      EQUIVALENCE (MEM(2),ARRIV0(1))
      EQUIVALENCE (MEM(4),RECOR0(1))
      EQUIVALENCE (MEM(5),IOREQ0(1))
      EQUIVALENCE (MEM(6),MEMOT0(1))
      EQUIVALENCE (MEM(7),AVGIO0(1))
      EQUIVALENCE (MEM(9),INTER0(1))
      EQUIVALENCE (MEM(10),REMAI0(1))
      EQUIVALENCE (MEM(12),JOBNU0(1))
      DISKU0=DISKU0+(SYSTE0-LASTD0)
      RETURN
      END
      SUBROUTINE UPDAU0
      INTEGER EVENT0
      INTEGER CPUQU0
      INTEGER DISKQ0
      INTEGER MEMOR0
      INTEGER CPUOW0
      INTEGER DISKO0
      INTEGER AVAIL0
      INTEGER MAXME0
      INTEGER * 4 SIMUL0
      INTEGER * 4 SYSTE0
      INTEGER JOBSI0
      INTEGER JOBSC0
      INTEGER * 4 TOTAL0
      INTEGER * 4 TRANS0
      INTEGER * 4 ACCES0
      INTEGER * 4 LASTC0
      INTEGER * 4 LASTD0
      INTEGER * 4 LASTM0
      INTEGER * 4 CPUUT0
      INTEGER * 4 DISKU0
      REAL * 8 MEMOS0
      INTEGER * 4 MEANJ0
      INTEGER EVENU0
      INTEGER MINRE0
      INTEGER MAXRE0
      INTEGER IOMEAN
      INTEGER IOSTD0
      INTEGER CPUME0
      INTEGER CPUST0
      INTEGER * 4 OVERH0
      INTEGER * 4 RELOC0
      COMMON /CBASYS/EVENT0,CPUQU0,DISKQ0,MEMOR0,CPUOW0,DISKO0,AVAIL0,MA
     *XME0,SIMUL0,SYSTE0,JOBSI0,JOBSC0,TOTAL0,TRANS0,ACCES0,LASTC0,LASTD
     *0,LASTM0,CPUUT0,DISKU0,MEMOS0,MEANJ0,EVENU0,MINRE0,MAXRE0,IOMEAN,I
     *OSTD0,CPUME0,CPUST0,OVERH0,RELOC0
      INTEGER JOBPR0(1)
      INTEGER * 4 ARRIV0(1)
      INTEGER RECOR0(1)
      INTEGER IOREQ0(1)
      INTEGER MEMOT0(1)
      INTEGER * 4 AVGIO0(1)
      INTEGER INTER0(1)
      INTEGER * 4 REMAI0(1)
      INTEGER JOBNU0(1)
      INTEGER JOBPO0(1)
      INTEGER * 4 EVENV0(1)
      INTEGER * 4 EVENW0(1)
      INTEGER LINK(1)
      INTEGER * 4 TIMEIN(1)
      INTEGER * 4 QPRIO0(1)
      INTEGER QUEUE0(1)
      INTEGER * 4 MAXWA0(1)
      INTEGER * 4 WAITT0(1)
      INTEGER MAXLE0(1)
      INTEGER QUEUF0(1)
      INTEGER * 4 TIMEL0(1)
      INTEGER * 4 LASTA0(1)
      INTEGER ENTRY0(1)
      INTEGER MEM(8192)
      COMMON /DSMEM$/MEM
      REAL * 8 TEMP
      EQUIVALENCE (MEM(1),JOBPO0(1))
      EQUIVALENCE (MEM(2),EVENV0(1))
      EQUIVALENCE (MEM(4),EVENW0(1))
      EQUIVALENCE (MEM(6),LINK(1))
      EQUIVALENCE (MEM(2),TIMEIN(1))
      EQUIVALENCE (MEM(4),QPRIO0(1))
      EQUIVALENCE (MEM(1),QUEUE0(1))
      EQUIVALENCE (MEM(2),MAXWA0(1))
      EQUIVALENCE (MEM(4),WAITT0(1))
      EQUIVALENCE (MEM(6),MAXLE0(1))
      EQUIVALENCE (MEM(7),QUEUF0(1))
      EQUIVALENCE (MEM(8),TIMEL0(1))
      EQUIVALENCE (MEM(10),LASTA0(1))
      EQUIVALENCE (MEM(12),ENTRY0(1))
      EQUIVALENCE (MEM(1),JOBPR0(1))
      EQUIVALENCE (MEM(2),ARRIV0(1))
      EQUIVALENCE (MEM(4),RECOR0(1))
      EQUIVALENCE (MEM(5),IOREQ0(1))
      EQUIVALENCE (MEM(6),MEMOT0(1))
      EQUIVALENCE (MEM(7),AVGIO0(1))
      EQUIVALENCE (MEM(9),INTER0(1))
      EQUIVALENCE (MEM(10),REMAI0(1))
      EQUIVALENCE (MEM(12),JOBNU0(1))
      TEMP=SYSTE0
      MEMOS0=MEMOS0+(MAXME0-AVAIL0)*(TEMP-LASTM0)
      RETURN
      END
      SUBROUTINE UPDAW0(QUEUE)
      INTEGER QUEUE
      INTEGER EVENT0
      INTEGER CPUQU0
      INTEGER DISKQ0
      INTEGER MEMOR0
      INTEGER CPUOW0
      INTEGER DISKO0
      INTEGER AVAIL0
      INTEGER MAXME0
      INTEGER * 4 SIMUL0
      INTEGER * 4 SYSTE0
      INTEGER JOBSI0
      INTEGER JOBSC0
      INTEGER * 4 TOTAL0
      INTEGER * 4 TRANS0
      INTEGER * 4 ACCES0
      INTEGER * 4 LASTC0
      INTEGER * 4 LASTD0
      INTEGER * 4 LASTM0
      INTEGER * 4 CPUUT0
      INTEGER * 4 DISKU0
      REAL * 8 MEMOS0
      INTEGER * 4 MEANJ0
      INTEGER EVENU0
      INTEGER MINRE0
      INTEGER MAXRE0
      INTEGER IOMEAN
      INTEGER IOSTD0
      INTEGER CPUME0
      INTEGER CPUST0
      INTEGER * 4 OVERH0
      INTEGER * 4 RELOC0
      COMMON /CBASYS/EVENT0,CPUQU0,DISKQ0,MEMOR0,CPUOW0,DISKO0,AVAIL0,MA
     *XME0,SIMUL0,SYSTE0,JOBSI0,JOBSC0,TOTAL0,TRANS0,ACCES0,LASTC0,LASTD
     *0,LASTM0,CPUUT0,DISKU0,MEMOS0,MEANJ0,EVENU0,MINRE0,MAXRE0,IOMEAN,I
     *OSTD0,CPUME0,CPUST0,OVERH0,RELOC0
      INTEGER JOBPR0(1)
      INTEGER * 4 ARRIV0(1)
      INTEGER RECOR0(1)
      INTEGER IOREQ0(1)
      INTEGER MEMOT0(1)
      INTEGER * 4 AVGIO0(1)
      INTEGER INTER0(1)
      INTEGER * 4 REMAI0(1)
      INTEGER JOBNU0(1)
      INTEGER JOBPO0(1)
      INTEGER * 4 EVENV0(1)
      INTEGER * 4 EVENW0(1)
      INTEGER LINK(1)
      INTEGER * 4 TIMEIN(1)
      INTEGER * 4 QPRIO0(1)
      INTEGER QUEUE0(1)
      INTEGER * 4 MAXWA0(1)
      INTEGER * 4 WAITT0(1)
      INTEGER MAXLE0(1)
      INTEGER QUEUF0(1)
      INTEGER * 4 TIMEL0(1)
      INTEGER * 4 LASTA0(1)
      INTEGER ENTRY0(1)
      INTEGER MEM(8192)
      COMMON /DSMEM$/MEM
      INTEGER * 4 ENTRZ0
      INTEGER ENTRY
      INTEGER DEQUE0
      EQUIVALENCE (MEM(1),JOBPO0(1))
      EQUIVALENCE (MEM(2),EVENV0(1))
      EQUIVALENCE (MEM(4),EVENW0(1))
      EQUIVALENCE (MEM(6),LINK(1))
      EQUIVALENCE (MEM(2),TIMEIN(1))
      EQUIVALENCE (MEM(4),QPRIO0(1))
      EQUIVALENCE (MEM(1),QUEUE0(1))
      EQUIVALENCE (MEM(2),MAXWA0(1))
      EQUIVALENCE (MEM(4),WAITT0(1))
      EQUIVALENCE (MEM(6),MAXLE0(1))
      EQUIVALENCE (MEM(7),QUEUF0(1))
      EQUIVALENCE (MEM(8),TIMEL0(1))
      EQUIVALENCE (MEM(10),LASTA0(1))
      EQUIVALENCE (MEM(12),ENTRY0(1))
      EQUIVALENCE (MEM(1),JOBPR0(1))
      EQUIVALENCE (MEM(2),ARRIV0(1))
      EQUIVALENCE (MEM(4),RECOR0(1))
      EQUIVALENCE (MEM(5),IOREQ0(1))
      EQUIVALENCE (MEM(6),MEMOT0(1))
      EQUIVALENCE (MEM(7),AVGIO0(1))
      EQUIVALENCE (MEM(9),INTER0(1))
      EQUIVALENCE (MEM(10),REMAI0(1))
      EQUIVALENCE (MEM(12),JOBNU0(1))
      TIMEL0(QUEUE)=TIMEL0(QUEUE)+QUEUF0(QUEUE)+(SYSTE0-LASTA0(QUEUE))
      ENTRY=DEQUE0(QUEUE0(QUEUE))
      GOTO 10268
10266 ENTRY=DEQUE0(QUEUE0(QUEUE))
10268 IF((ENTRY.EQ.0))GOTO 10267
        ENTRZ0=SYSTE0-TIMEIN(ENTRY)
        WAITT0(QUEUE)=WAITT0(QUEUE)+ENTRZ0
        MAXWA0(QUEUE)=MAX0(MAXWA0(QUEUE),ENTRZ0)
        CALL FREE(ENTRY)
      GOTO 10266
10267 RETURN
      END
C ---- Long Name Map ----
C waittime                       waitt0
C nextinline                     nexti0
C qdiscipline                    qdisc0
C updatememoryutilization        updau0
C scheduler                      schee0
C resource                       resou0
C simulationtime                 simul0
C cpumean                        cpume0
C cpuqueue                       cpuqu0
C lastdisktransition             lastd0
C jobnumber                      jobnu0
C eventqueue                     event0
C requestmemory                  requg0
C memoryutilization              memos0
C lastactivity                   lasta0
C arrivaltime                    arriv0
C dequeue                        deque0
C qpriority                      qprio0
C maxlength                      maxle0
C updatecpuutilization           updat0
C memorytable                    memou0
C avgiointerval                  avgio0
C cpuowner                       cpuow0
C accesstime                     acces0
C dumpjob                        dumpj0
C interruptedevent               inter0
C queuepointer                   queue0
C overheadtime                   overh0
C queuelength                    queuf0
C exponential                    expon0
C requestcpu                     reque0
C diskqueue                      diskq0
C cpuutilization                 cpuut0
C cputime                        cputi0
C eventtime                      evenw0
C enqueue                        enque0
C cpustddev                      cpust0
C iorequests                     ioreq0
C memorysize                     memot0
C schedevent                     sched0
C releasecpu                     relea0
C totaltime                      total0
C nextjob                        nextj0
C maxwait                        maxwa0
C updatediskutilization          updav0
C initializerun                  initi0
C advancememoryqueue             advan0
C jobarrival                     jobar0
C diskowner                      disko0
C relocationtime                 reloc0
C summarizerun                   summa0
C entrywaited                    entrz0
C systemclock                    syste0
C lastmemorytransition           lastm0
C entrycount                     entry0
C setjobparameters               setjo0
C uniform                        unifo0
C availablememory                avail0
C meanjobinterarrivaltime        meanj0
C eventtrace                     evenu0
C timelength                     timel0
C cancelevent                    cance0
C requestdisk                    requf0
C diskutilization                disku0
C summarize                      summb0
C updatequeuestatistics          updaw0
C releasedisk                    releb0
C maxmemory                      maxme0
C nextevent                      nexte0
C jobsinitiated                  jobsi0
C minrecsize                     minre0
C remainingtime                  remai0
C lastcputransition              lastc0
C recordsize                     recor0
C jobscompleted                  jobsc0
C transfertime                   trans0
C maxrecsize                     maxre0
C iostddev                       iostd0
C jobpriority                    jobpr0
C eventtype                      evenv0
C memoryqueue                    memor0
C jobpointer                     jobpo0
C firstjob                       first0
