      SUBROUTINE SSGHTP(ORDER,Z,LZ)
C*****
C  SPECIAL IN-PLACE PARTITIONING ROUTINE USED ONLY BY SSGHT MODULE.
C*****
      INTEGER ORDER(LZ), Z(LZ), SAVE1, SAVE2, PTR
      I = 1
      ISAVE = 1
C
C     CHECK TO SEE THAT POINTER TO NEXT SLOT HAS NOT BEEN USED YET.
C
   10 PTR = ORDER(I)
      IF( PTR .GT. 1000000 ) GO TO 40
      ORDER(I) = PTR + 1000000
C
C     IF THE MOVE-TO LOCATION IS THE SAME, THEN DO NOTHING.
C
      IF( PTR .EQ. I ) GO TO 40
C
C     SAVE VALUE CURRENTLY IN SLOT WE ARE MOVING TO.
C
      SAVE1 = Z(PTR)
C
C     MOVE ITEM INTO SLOT
C
      Z(PTR) = Z(I)
C
C     SET POINTER TO WHERE -SAVE1- IS TO BE MOVED.
C
   20 JPTR = ORDER(PTR)
      IF( JPTR .GT. 1000000 ) GO TO 30
      ORDER(PTR) = JPTR + 1000000
      SAVE2 = Z(JPTR)
      Z(JPTR) = SAVE1
      SAVE1 = SAVE2
      PTR = JPTR
      GO TO 20
C
C     END OF CHAIN.  GO BACK AND LOOK FOR ANOTHER.
C
   30 I = ISAVE + 1
      GO TO 50
   40 I = I + 1
   50 ISAVE = I
      IF( I .LE. LZ ) GO TO 10
C
C     CLEAR OUT FLAGS AND RETURN.
C
      DO 60 I = 1,LZ
      ORDER(I) = ORDER(I) - 1000000
   60 CONTINUE
      RETURN
      END
