	PROGRAM VTEST2
C
C	THIS PROGRAM SHELL SORTS A DUPLICATE VIRTUAL AND CORE
C	ARRAY OF DOUBLE PRECISION RANDOM NUMBERS AND THEN
C	COMPARES FOR IDENTICAL RESULTS.
C
	DOUBLE PRECISION  X,Y,T
	DIMENSION Y(4000)
	VIRTUAL   X(4000)
C
	COMMON /VCOUNT/  IACCS0,IACCS1,IFALT0,IFALT1
C
	IACCS0=0
	IACCS1=0
	IFALT0=0
	IFALT1=0
	TYPE 10
10	FORMAT ('$HOW MANY? ')
	ACCEPT 15, NUMBER
15	FORMAT (I5)
C
C
	DO 30 L=1,NUMBER
	T=RAN(0,0)*RAN(0,0)
	X(L)=T
	Y(L)=T
30	CONTINUE
C
C
C	SHELL SORT THE VIRTUAL ARRAY
C
	IM1=NUMBER
32	IM1=IM1/2
	IF (IM1.EQ.0) GO TO 40
	K=NUMBER-IM1
	J=1
34	I=J
36	IF (X(I).LE.X(I+IM1)) GO TO 38
	T=X(I)
	X(I)=X(I+IM1)
	X(I+IM1)=T
	I=I-IM1
	IF (I.GT.0) GO TO 36
38	J=J+1
	IF (J.GT.K) GO TO 32
	GO TO 34
C
C
C
C	SHELL SORT THE CORE ARRAY
C
40	IM1=NUMBER
42	IM1=IM1/2
	IF (IM1.EQ.0) GOTO 50
	K=NUMBER-IM1
	J=1
44	I=J
46	IF (Y(I).LE.Y(I+IM1)) GOTO 48
	T=Y(I)
	Y(I)=Y(I+IM1)
	Y(I+IM1)=T
	I=I-IM1
	IF (I .GT. 0) GOTO 46
48	J=J+1
	IF (J.GT.K) GOTO 42
	GOTO 44
C
50	DO 52 L=1,NUMBER
	IF (X(L) .NE. Y(L))  TYPE 53, L,X(L),Y(L)
52	CONTINUE
53	FORMAT(I5,D12.8,D12.8)
C
	ACCESS=FLOAT(IACCS0)
	IF (ACCESS .LT. 0.0) ACCESS=ACCESS+65536.0
	ACCESS=ACCESS+FLOAT(IACCS1)*65536.0
	FAULT=FLOAT(IFALT0)
	IF (FAULT .LT. 0.0) FAULT=FAULT+65536.0
	FAULT=FAULT+FLOAT(IFALT1)*65536.0
	RATE=100.0*(1.0-FAULT/ACCESS)
	TYPE 55, ACCESS, FAULT
55	FORMAT(' ACCESSES = ',F10.0,'           FAULTS = ',F10.0/)
	TYPE 58, RATE
58	FORMAT(' HIT RATE = ',F5.2,'%'/)
C
	END
