C
C     ==============================
      SUBROUTINE TURN3(M1,M2,M3,MOST)
C     ===============================
C
C  Reduces indices to correct form for Trigonal FFT
C  Asymmetric unit:  h.ge.k.ge.0  for all l but when h=k then l.ge.0
C  (ie max value of h with k.ge.0)
C  Note that ISYM does not contain the identity matrix.
C  Modified form of code written by David Blow on the Nova at IC
C                       Peter Brick     20 Feb 1984
C
C
C
C     .. Parameters ..
      INTEGER LPACK,LHPACK
      PARAMETER (LPACK=1024,LHPACK=LPACK/2)
      INTEGER MPACK
      PARAMETER (MPACK= ((LPACK*LHPACK+LHPACK)*LPACK+LHPACK))
C     ..
C     .. Scalar Arguments ..
      INTEGER M1,M2,M3,MOST
C     ..
C     .. Scalars in Common ..
      INTEGER NISYM
      CHARACTER PGNAME*10
C     ..
C     .. Arrays in Common ..
      INTEGER ISYM
C     ..
C     .. Local Scalars ..
      INTEGER I,IBEST,ITEST,J,K,M,MA,MB
C     ..
C     .. Local Arrays ..
      INTEGER ITABLE(3)
C     ..
C     .. Common blocks ..
      COMMON /SYMM/NISYM,ISYM(9,47)
      COMMON /SYMM1/PGNAME
C     ..
C
C
      MOST = 0
      IBEST = -MPACK
      IF (NISYM.GT.0) THEN
        I = M1
        J = M2
        K = M3
C
        IF (J.GE.0) THEN
          MOST = 1
C
C---- For identity matrix
C
          IBEST = (M1*LPACK+M2)*LPACK + M3
        END IF
C
C
        DO 20 M = 1,NISYM
          MB = 0
C
C
          DO 10 MA = 1,3
            ITABLE(MA) = ISYM(MB+1,M)*I + ISYM(MB+2,M)*J +
     +                   ISYM(MB+3,M)*K
            MB = MB + 3
   10     CONTINUE
C
C---- Gives correct segment
C     namely M1.gt.M2 and M2.ge.0
C
          IF (ITABLE(2).GE.0) THEN
            ITEST = (ITABLE(1)*LPACK+ITABLE(2))*LPACK + ITABLE(3)
            IF (ITEST.GT.IBEST) THEN
              M1 = ITABLE(1)
              M2 = ITABLE(2)
              M3 = ITABLE(3)
              IBEST = ITEST
              MOST = M + 1
            END IF
          END IF
   20   CONTINUE
C
C
        IF (MOST.EQ.0) THEN
                    CALL CCPERR(1,
     +  ' ** ERROR IN TURN3 - MOST = 0 **')
        ELSE
C
        END IF
      END IF
C
C
      END
