C LAST UPDATE: 
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C
C**************************
C**     LRL_GET_INT     **
C**************************
C
CD-Routine: Return Integrated Intensity of a Spot - LRL_GET_INT
C This routine will return the integrated intensity of a spot in the
C Laue Reflection List if this has been measured and stored (LRL_SET_INT).
CD-end
CD-Fortran:
      SUBROUTINE LRL_GET_INT (ISPOT, AI, SIGI, MEASURED, BAD,
     +                        OVERLOAD, ICODE, ICODE_TYPE, IERR)
CD-end
      INCLUDE 'implicit_none.finc'
C
C Purpose: Return integrated intensity data for a spot
C
C Author:  John W. Campbell, July 1993
C
C Arguments:
C
      INTEGER ISPOT
      REAL    AI
      REAL    SIGI
      LOGICAL MEASURED
      LOGICAL BAD
      LOGICAL OVERLOAD
      INTEGER ICODE
      INTEGER ICODE_TYPE
      INTEGER IERR
CD-Parameters:
C ISPOT      i  (R)   Spot index number (in current sort order)
C AI         r  (W)   The integrated intensity
C SIG I      r  (W)   sig(I)
C MEASURED   l  (W)   Spot has been integrated flag .TRUE. yes, .FALSE. no
C BAD        l  (W)   Bad spot flagged .TRUE. bad, .FALSE. good
C OVERLOAD   l  (W)   Overload flag .TRUE. yes, .FALSE. no
C ICODE      i  (W)   Status code fom integration program
C                     For ICODE_TYPE=1   bit 0 no non-overlapped peak pixels
C                                        bit 1 < 20% of peak pixels are
C                                              non-overlapped.
C                                        bit 2 <3 non-overlapped background
C                                              pixels
C                                        bit 4 < 20% of background pixels are
C                                              non-overlapped.
C ICODE_TYPE i  (W)   Integration code type; should be 0 if of a type 
C                     unknown to the 'LRL' routines
C                     = 1 Integration using Q. Hao's routines LFN_SAINT
C                         as used in INTLDM and LAUEGEN
C IERR       i  (W)   Error flag =  0,  OK
C                                =  1,  Invalid spot number
C                                =  2,  No integration done
CD-end
C
C
C====== GLOBALS:
C
      INCLUDE 'lrl_data.finc'
C
C====== FUNCTION TYPES:
C
      INTEGER NBITST
      EXTERNAL LRL_BDAT
C
C====== LOCALS:
C   
      INTEGER I
      INTEGER IFLAG
C
C     INTEGER I        !Index to spot
C     INTEGER IFLAG    !Spot flags word
C
C-------------------------------------------------------------------------------
C
      IERR = 0
      AI = 0.0
      SIGI = 0.0
      MEASURED = .FALSE.
      IF (ISPOT.LT.1.OR.ISPOT.GT.NUM_SPOTS) THEN
         IERR = 1
         RETURN
      END IF
      IF (.NOT.INTEGRATED) THEN
         IERR = 2
         RETURN
      END IF
      I = INDX(ISPOT)
      AI = AII(I)
      SIGI = SIGII(I)
      IFLAG = FLAGS(I)
      IF (NBITST(IFLAG,8,1).NE.0) MEASURED =.TRUE.
      BAD = .FALSE.
      IF (NBITST(IFLAG,9,1).NE.0) BAD = .TRUE.
      OVERLOAD = .FALSE.
      IF (NBITST(IFLAG,10,1).NE.0) OVERLOAD = .TRUE.
      ICODE = NBITST(IFLAG,12,8)
      ICODE_TYPE = INTCODE_TYPE
      RETURN
      END
