C LAST UPDATE: 
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C
C**************************
C**     LFN_UNQ_HKL      **
C**************************
C
CD-Routine: Get Indices of a Unique Reflection - LFN_UNQ_HKL
C This routine returns the indices of a reflection from a unique
C reflections list as genertated by the routine LFN_UNQ_GEN
CD-end
CD-Fortran:
      SUBROUTINE LFN_UNQ_HKL (IREF, IH, IK, IL)
CD-end
      INCLUDE 'implicit_none.finc'
C
C Purpose: Get indices for a reflection in the unique reflections list
C
C Author:  John W. Campbell, September 1993
C
C Arguments:
C
      INTEGER IREF
      INTEGER IH
      INTEGER IK
      INTEGER IL
CD-Parameters:
C  IREF      i (R)   Reflection number in the list
C  IH        i (W)   'h' index
C  IK        i (W)   'k' index
C  IL        i (W)   'l' index
C                   
C            h, k, l returned as 0,  0,  0, if invalid IREF given
CD-end
C
C====== Parameter statements
C 

C
C====== GLOBALS:
C
      EXTERNAL LFN_UNQ_BDAT
      INCLUDE 'lfn_unq.finc'
C
C====== FUNCTION TYPES:
C

C
C====== LOCALS:
C
      INTEGER I
      INTEGER NTWO20
      INTEGER NTWO10

C     INTEGER I           !Temp. integer value
C     INTEGER NTWO20      !2**20
C     INTEGER NTWO10      !2**10

      DATA NTWO20/1048576/
      DATA NTWO10/1024/

C
C-------------------------------------------------------------------------------
C
      IF (IREF.LT.1.OR.IREF.GT.NUM_UNQ) THEN
         IH = 0
         IK = 0
         IL = 0
         RETURN
      ELSE
         I = HKL_UNQ(INDX_UNQ(IREF))
         IH = I/NTWO20
         I = I - NTWO20*IH
         IH = IH - 512
         IK = I/NTWO10
         IL = I - NTWO10*IK - 512
         IK = IK - 512
      END IF
      RETURN
      END
