C LAST UPDATE:
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C
C******************************
C**     LFN_GET_SPOTPIX      **
C******************************
C
CD-Routine: Get Spot Pixel Details - LFN_GET_SPOTPIX
C This routine is used to return the details of a pixel from the last 
C integrated spot calculated using the diagnostic option of the routine 
C LFN_SAINT to integrate an individual profile-fitted spot.
CD-end
CD-Fortran:
      SUBROUTINE LFN_GET_SPOTPIX (IPIX, IXP_S, IYP_S, IMASK_S, PIXV_S, 
     +                            PROF_S, SUBPR_S, IREJ_S, IERR)
CD-end
      INCLUDE 'implicit_none.finc'
C
C PURPOSE: Get profile details from a profile calculated by LFN_SAINT
C 
C AUTHOR: J.W. Campbell 
C
C ARGUMENTS:
C
      INTEGER IPIX
      INTEGER IXP_S
      INTEGER IYP_S
      INTEGER IMASK_S
      REAL PIXV_S
      REAL PROF_S
      REAL SUBPR_S
      INTEGER IREJ_S
      INTEGER IERR
CD-Parameters:
C   IPIX                i  (R) Pixel number in spot pixels list
C   IXP_S               i  (W) Pixel 'x' offset from spot centre
C   IYP_S               i  (W) Pixel 'y' offset from spot centre
C   IMASK_S             i  (W) Mask 0,1 = background; 
C                              -1 omitted border pixel;
C                              -2 omitted pixel from overlapped spot;
C                              -3 saturated pixel (omitted)
C                              >=10 peak pixel
C                              (return as -100 if pixel no. out of range)
C   PIXV_S              r  (W) Pixel OD value
C   PROF_S              r  (W) Profile value
C   SUBPR_S             r  (W) Background subtracted spot profile pixel value
C   IREJ_S              i  (W) Reject pixel flag 0=Ok, 1=rejected
C   IERR                i  (W) Error flag =0 OK
C                                         =1 Requested pixel out of range
CD-end
C
C====== Parameter statements
C 
      INCLUDE 'saint_limits.finc'
C
C====== GLOBALS:
C
      INCLUDE 'lfn_saint.finc'
C
C====== LOCALS:
C
      INTEGER I

C     INTEGER I    !Index in profile arrays
C
C------------------------------------------------------------------------------- 
C
      IERR = 0
      IMASK_S = -100
C
C====== Error checks
C
      IF (IPIX.LT.1.OR.IPIX.GT.NUM_IN_SPOT) THEN
         IERR = 1
         RETURN
      END IF
C
C====== Return data
C
      IXP_S = IXP(IPIX)
      IYP_S = IYP(IPIX)
      IMASK_S = SHAPE(IPIX)
      PIXV_S = PIXV(IPIX)
      PROF_S = PROF_IND(IPIX)
      SUBPR_S = SUBPR(IPIX)
      IREJ_S = 0
      DO 10 I = 1, NREJ
         IF (IREJ(I).EQ.IPIX) IREJ_S = 1
 10   CONTINUE
      RETURN
      END
