
C LAST UPDATE:
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C
C******************************
C**     LFN_SPOTS_ANA_LIS    **
C******************************
C
CD-Routine: List Spot Size Analysis Results - LFN_SPOTS_ANA_LIS
C This routine is used to list the results from the spot size analysis
C routine LFN_SPOTS_ANALYSE. Output may be to a terminal or a file.
CD-end
CD-Fortran:
      SUBROUTINE LFN_SPOTS_ANA_LIS (IUN, ITERM, IOPT, N_BIN, BIN_START,
     +                              BIN_END, SUM_GOOD, N_GOOD, N_REJECT, 
     +                              SEL_SIZE,RAST_MM, THRESHFAC, CUT,
     +                              SIZE_FAC, IPACK, IPLATE)
CD-end
      INCLUDE 'implicit_none.finc'
C
C Purpose: List soft limits determination results
C
C Author:  Don Nguti / John Campbell, August 1995
C
C Arguments:
C
      INTEGER IUN
      INTEGER ITERM
      INTEGER IOPT
      INTEGER N_BIN
      REAL BIN_START(*)
      REAL BIN_END(*)
      REAL SUM_GOOD(*)
      INTEGER N_GOOD(*)
      INTEGER N_REJECT(*)
      REAL SEL_SIZE
      REAL SIZE_FAC
      REAL RAST_MM
      REAL THRESHFAC
      REAL CUT
      INTEGER IPACK
      INTEGER IPLATE
CD-Parameters:
C   IUN           i (R)  Unit number for listing.
C   ITERM         i (R)  =1 output to a terminal, =0 output to a file
C   IOPT          i (R)  Flag = 1 spot length analysis results,
C                             = 2 spot width analysis results.
C   N_BIN         i (R)  Data divided into N_BIN angular bins for analysis.
C                        (value as passed to LFN_SPOTS_ANALYSE)
C   BIN_START(*)  r (R)  Start angle for each bin (as returned from
C                        LFN_SPOTS_ANALYSE).
C   BIN_END(*)    r (R)  End angle for each bin (as returned from
C                        LFN_SPOTS_ANALYSE).
C   SUM_GOOD(*)   r (R)  Sum of spot lengths/widths for each bin after
C                        rejection on standard deviation cutoff (as
C                        returned from LFN_SPOTS_ANALYSE).
C   N_GOOD(*)     i (R)  No. of spots for each bin after rejection on
C                        standard deviation cutoff (as returned from
C                        LFN_SPOTS_ANALYSE).
C   N_REJECT(*)   i (R)  No. of spots rejected for each bin based of 
C                        standard deviation cutoff (as returned from
C                        LFN_SPOTS_ANALYSE).
C   SEL_SIZE      r (R)  Spot length or width selected by LFN_SPOTS_ANALYSE
C   RAST_MM       r (R)  Conversion factor (rasters to mm).
C   THRESHFAC     r (R)  Threshold factor for picking spots as used in
C                        call to LFN_FINDSPOTS.
C   CUT           r (R)  Standard deviation cutoff factor for rejecting 
C                        spots as used in LFN_SPOTS_ANALYSE.
C   IPACK         i (R)  Pack no. for which spot size is being determined.
C   IPLATE        i (R)  Plate no. in pack for which spot size is being 
C                        determined.
CD-end
C
C====== Parameter statements
C
 
C
C====== GLOBALS:
C
 
C
C====== FUNCTION TYPES:
C
      INTEGER LENSTR
C
C====== LOCALS:
C
      INTEGER I
      REAL SIZE
      CHARACTER*120 STR
 
C     INTEGER I              !Temp/loop variable
C     REAL SIZE              !Spot length/width for the current bin
C     CHARACTER*120 STR      !Output string
C
C-------------------------------------------------------------------------------
C
      IF (N_BIN.LE.0) THEN
         RETURN
      END IF
C
C====== Output headings for table
C
      IF (IOPT.EQ.1) THEN
         STR = 'Spot length analysis for pack'
         CALL STR_ADDI(STR,IPACK,1)
         CALL STR_ADDS(STR,', plate',0)
         CALL STR_ADDI(STR,IPLATE,1)
      ELSE
         STR = 'Spot width analysis for pack'
         CALL STR_ADDI(STR,IPACK,1)
         CALL STR_ADDS(STR,', plate',0)
         CALL STR_ADDI(STR,IPLATE,1)
      END IF
      IF (ITERM.EQ.1) THEN
         CALL TTSEND(IUN,STR(1:LENSTR(STR)),1)
         CALL TTSEND(IUN,' ',1)
      ELSE
         WRITE (IUN,6010) STR(1:LENSTR(STR))
         WRITE (IUN,6020)
      END IF
      STR = 'Threshold factor for picking spots ='
      CALL STR_ADDF(STR,THRESHFAC,1,1)
      IF (ITERM.EQ.1) THEN
         CALL TTSEND (IUN,STR(1:LENSTR(STR)),1)
         CALL TTSEND (IUN,' ',1)
      ELSE
         WRITE(IUN,6010) STR(1:LENSTR(STR))
         WRITE(IUN,6020)
      END IF
C
      STR = 'Standard deviation cutoff for rejecting spots ='
      CALL STR_ADDF(STR,CUT,1,1)
      IF (ITERM.EQ.1) THEN
         CALL TTSEND (IUN,STR(1:LENSTR(STR)),1)
         CALL TTSEND (IUN,' ',1)
      ELSE
         WRITE(IUN,6010) STR(1:LENSTR(STR))
         WRITE(IUN,6020)
      END IF
C
      STR = 'Size compensation factor ='
      CALL STR_ADDF(STR,SIZE_FAC,1,1)
      IF (ITERM.EQ.1) THEN
         CALL TTSEND (IUN,STR(1:LENSTR(STR)),1)
         CALL TTSEND (IUN,' ',1)
      ELSE
         WRITE(IUN,6010) STR(1:LENSTR(STR))
         WRITE(IUN,6020)
      END IF


 
      STR = 'Bin   Start    End    No. Good   No. bad'
      CALL STR_ADDS(STR,'  Spot',0)
      IF (ITERM.EQ.1) THEN
         CALL TTSEND(IUN,STR(1:LENSTR(STR)),1)
      ELSE
         WRITE (IUN,6010) STR(1:LENSTR(STR))
      END IF
      IF (IOPT.EQ.1) THEN
         STR = 'No.   Angle    Angle   Spots     Spots'
         CALL STR_ADDS(STR,'   Length',0)
      ELSE
         STR = 'No.   Angle    Angle   Spots     Spots'
         CALL STR_ADDS(STR,'   Width',0)
      END IF
      IF (ITERM.EQ.1) THEN
         CALL TTSEND(IUN,STR(1:LENSTR(STR)),1)
         CALL TTSEND(IUN,' ',1)
      ELSE
         WRITE (IUN,6010) STR(1:LENSTR(STR))
         WRITE (IUN,6020)
      END IF
C
C====== Output table
C
      DO 20 I = 1 , N_BIN
         SIZE = 0.0
         IF (N_GOOD(I).GT.0) SIZE = SUM_GOOD(I)/N_GOOD(I)
         WRITE (STR,6030) I , BIN_START(I) , BIN_END(I) , N_GOOD(I) , 
     +                    N_REJECT(I), SIZE*RAST_MM
         IF (ITERM.EQ.1) THEN
            CALL TTSEND(IUN,STR(1:LENSTR(STR)),1)
         ELSE
            WRITE (IUN,6010) STR(1:LENSTR(STR))
         END IF
 20   CONTINUE
      IF (ITERM.EQ.1) THEN
         CALL TTSEND(IUN,' ',1)
      ELSE
         WRITE (IUN,6020)
      END IF
C
C====== Output selected length/width
C
      IF (IOPT.EQ.1) THEN
         STR = 'Average observed spot length'
      ELSE
         STR = 'Average observed spot  width'
      END IF
      CALL STR_ADDF(STR,SEL_SIZE*RAST_MM,3,1)
      CALL STR_ADDS(STR,'mm',1)
C
      IF (ITERM.EQ.1) THEN
         CALL TTSEND(IUN,STR(1:LENSTR(STR)),1)
         CALL TTSEND(IUN,' ',1)
      ELSE
         WRITE (IUN,6010) STR(1:LENSTR(STR))
         WRITE (IUN,6020)
      END IF
C      
      IF (IOPT.EQ.1) THEN
         STR = 'Proposed spot length = '
      ELSE
         STR = 'Proposed spot  width = '
      END IF
      CALL STR_ADDF(STR,SIZE_FAC*SEL_SIZE*RAST_MM,3,1)
      CALL STR_ADDS(STR,'mm',1)
C
      IF (ITERM.EQ.1) THEN
         CALL TTSEND(IUN,STR(1:LENSTR(STR)),1)
         CALL TTSEND(IUN,' ',1)
      ELSE
         WRITE (IUN,6010) STR(1:LENSTR(STR))
         WRITE (IUN,6020)
      END IF


      RETURN
C
C====== Format statements
C
 6010 FORMAT (A)
 6020 FORMAT (' ')
 6030 FORMAT (I3,2F8.1,2I9,F9.2)
      END
