
C LAST UPDATE:
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C
C******************************
C**     LFN_GET_PROFPIX      **
C******************************
C
CD-Routine: Get Profile Pixel Details - LFN_GET_PROFPIX
C This routine is used to return the details of a pixel from a spot profile
C calculated by a profile determining pass of the routine LFN_SAINT.
CD-end
CD-Fortran:
      SUBROUTINE LFN_GET_PROFPIX (IPROF, IX, IY, IMASK, PRF, 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 IPROF
      INTEGER IX
      INTEGER IY
      INTEGER IMASK
      REAL PRF
      INTEGER IERR
CD-Parameters:
C   IPROF               i  (R) Profile no. (must be in range of those 
C   IX                  i  (R) Pixel offset in 'x' from profile centre
C   IY                  i  (R) Pixel offset in 'y' from profile centre
C   IMASK               i  (W) Pixel use 0/1 background, -1 omitted 1 pixel
C                              border round peak,  -2 = omitted pixel from
C                              spot overlap, -3 = omitted pixel from
C                              overloaded pixel, >=10 peak pixel
C                              (Returned as -100 if outside profile box or
C                               pixel not used in profile determination)
C   PRF                 r  (W) Profile value for the pixel
C   IERR                i  (W) Error flag =0 OK
C                                =1 Requested bin out of range
C                                =2 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 = -100
      PRF = 0.0
C
C====== Error checks
C
      IF (IPROF.LT.1.OR.IPROF.GT.NPROF_BIN) THEN
         IERR = 1
         RETURN
      END IF
C
C====== Return data
C
      IF (IABS(IX).GT.NPR_HALF.OR.IABS(IY).GT.NPR_HALF) THEN
         IERR = 2
         RETURN
      END IF
      I = INDXPR(IX,IY)
      IF (I.EQ.0) RETURN
      IMASK = SHAPE_PROF(I)
      PRF = PROF(I,IPROF)
      RETURN
      END
