C REFLECT EXTENDED CELL ADDRESSES BACK TO PRIME WORK AREA.
	SUBROUTINE REFLEC(ID1,ID2,ID)
C FORM ID OUT OF ID1,ID2 BUT USING REFLECTED VALUES SO THAT
C RESULT ID IS ALWAYS IN PRIME AREA.
	INCLUDE 'VKLUGPRM.FTN'
C ABOVE DEFINES LOGICALS USED
	INTEGER*2 ICREF,IRREF,ID,ID1,ID2,IDD1,IDD2
	COMMON/MIRROR/ICREF,IRREF
C DON'T MESS UP ARGUMENTS; USE INTERNAL COPY. ALSO MAY
C BE FASTER ON SOME ARCHITECTURES.
	IDD1=MAX0(ID1,1)
	IDD2=ID2
	IF(ID1.LT.1)GOTO 2000
C ALLOW TRICK ENTRIES WITH ID1=0 TO MEAN ID2 IS THE COMPLETE INDEX
C GMSUBS, MTXEQU AND MDET USE THESE CALLS
C TRICKERY HERE FIXES UP XVBLGT AND XVBLST
4000	CONTINUE
	IF(IDD2.LE.RRW)GOTO 1000
	IDD2=IDD2-RRW
	IDD1=IDD1+IRREF
	GOTO 4000
1000	CONTINUE
	IF(IDD1.LE.RCL)GOTO 2000
	IDD1=IDD1-RCL+1
	IDD2=IDD2+ICREF
	GOTO 4000
2000	CONTINUE
	ID=(IDD1-1)*RRW+IDD2
	RETURN
	END
