C LAST UPDATE: 
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C
C**************************
C**     LFN_INT_TAB1     **
C**************************
C
CD-Routine: Integration Statistics Table 1 - LFN_INT_TAB1
C This routine is used used to produce a table of Laue statistics data 
C using the statistics returned by the routine LFN_INT_STATS1. 
CD-end
CD-Fortran:
      SUBROUTINE LFN_INT_TAB1 (IUN, ITERM, KEY, NS, NG, NO, NN, NB, 
     +                         AIM, AIS, N3, N10)
CD-end
      INCLUDE 'implicit_none.finc'
C
C Purpose: Print table of counts statistics from LFN_INT_STATS1
CC
C Author:  John W. Campbell, January 1996
C
C Arguments:
C
      INTEGER IUN
      INTEGER ITERM
      INTEGER  KEY
      INTEGER NS(5)
      INTEGER NG(5)
      INTEGER NO(5)
      INTEGER NN(5)
      INTEGER NB(5)
      REAL AIM(5)
      REAL AIS(5)
      INTEGER N3(5)
      INTEGER N10(5)
CD-Parameters:
C IUN       i (R)  Unit no. for listing (0 if none)
C ITERM     i (R)  =1, o/p to terminal, =0 o/p to file
C KEY       i (R)  = 0 no key, =1 o/p key, =2 o/p key only key
C NS(5)     i (R)  No. of spots present for the 5 spot categories
C NG(5)     i (R)  No. of spots integrated & good  for the 5 spot categories
C NO(5)     i (R)  No. of overload spots flagged for the 5 spot categories
C NN(5)     i (R)  No. of OK negative intensities for the 5 spot categories
C NB(5)     i (R)  No. of bad spots spots flagged for the 5 spot categories
C AIM(5)    r (R)  Mean I value for the 5 spot categories (for OK positive
C                    intensities only)
C AIS(5)    r (R)  Mean I/sig(I) values for the 5 spot categories (for
C                    OK positive intensities only)
C N3(5)     i (R)  No. OK spots with I>3*sig(I) for the 5 spot categories
C N10(5)    i (R)  No. OK spots wit I>10*sig(I) for the 5 spot categories
C
C        AIM, AIS, N3 and N10 values include overloads but not bad spots
C
C        Good = measured (integrated) and not bad/overload
C        OK   = measured (integrated) and not bad (i.e. may include overloads)
CD-end
C
C====== Parameter statements
C 

C
C====== GLOBALS:
C

C
C====== FUNCTION TYPES:
C
      INTEGER LENSTR
C
C====== LOCALS:
C
      INTEGER I
      CHARACTER*80 STR
      CHARACTER*15 SPOTSTR(5)

C     INTEGER I               !Loop counter
C     CHARACTER*80 STR        !Output string
C     CHARACTER*15 SPOTSTR(5) !Spot category strings
C
      DATA SPOTSTR/'All Spots',
     +             'Singles (sep)',
     +             'Multiples (sep)',
     +             'SpOv. Singles',
     +             'SpOv. Multiples'/
C
C-------------------------------------------------------------------------------
C
C
C====== Check unit OK
C
      IF (IUN.LE.0) RETURN
C
C====== Output headings
C
      IF (KEY.LT.2) THEN
         STR = 'Table of Intensity Statistics'
         IF (ITERM.EQ.1) THEN
             CALL TTSEND (IUN,STR(1:LENSTR(STR)),1)
         ELSE
             WRITE(IUN,1000) STR(1:LENSTR(STR))
         END IF
         STR = '-----------------------------'
         IF (ITERM.EQ.1) THEN
             CALL TTSEND (IUN,STR(1:LENSTR(STR)),1)
         ELSE
             WRITE(IUN,1000) STR(1:LENSTR(STR))
         END IF
         IF (ITERM.EQ.1) THEN
            CALL TTSEND (IUN,' ',1)
         ELSE
            WRITE(IUN,1000) ' '
         END IF
         STR = 'Spot type'
         CALL STR_ADDS (STR, '  Total   Good Ovld.  Neg.   Bad', 6)
         CALL STR_ADDS (STR, '     Mean   Mean  Number  Number', 0)
         IF (ITERM.EQ.1) THEN
             CALL TTSEND (IUN,STR(1:LENSTR(STR)),1)
         ELSE
             WRITE(IUN,1000) STR(1:LENSTR(STR))
         END IF
         STR = '---------'
         CALL STR_ADDS (STR, '  Spots  Spots Spots Spots Spots', 
     +                  6)
         CALL STR_ADDS (STR, '        I I/sigI  >3sigI >10sigI', 0)
         IF (ITERM.EQ.1) THEN
            CALL TTSEND (IUN,STR(1:LENSTR(STR)),1)
         ELSE
             WRITE(IUN,1000) STR(1:LENSTR(STR))
         END IF
         IF (ITERM.EQ.1) THEN
             CALL TTSEND (IUN,' ',1)
         ELSE
             WRITE(IUN,1000) ' '
         END IF
C
C====== Output bins data
C
         DO 100 I = 1, 5
            STR = SPOTSTR(I)
            WRITE (STR(16:),'(2I7,3I6,F9.1,F7.1,I8,I8)') NS(I), NG(I),  
     +         NO(I), NN(I), NB(I), AIM(I), AIS(I), N3(I), N10(I)
            IF (ITERM.EQ.1) THEN
                CALL TTSEND (IUN,STR(1:LENSTR(STR)),1)
            ELSE
                WRITE(IUN,1000) STR(1:LENSTR(STR))
            END IF
100      CONTINUE
      END IF
C
C====== Output key if required
C
      IF (KEY.GT.0) THEN
         IF (ITERM.EQ.1) THEN
             CALL TTSEND (IUN,' ',1)
         ELSE
             WRITE(IUN,1000) ' '
         END IF
         STR = 'Key: Good  = Good spot, measured and not bad/overload'
         IF (ITERM.EQ.1) THEN
            CALL TTSEND (IUN,STR(1:LENSTR(STR)),1)
         ELSE
            WRITE(IUN,1000) STR(1:LENSTR(STR))
         END IF
         STR = '     (sep) = Spatially separated'
         IF (ITERM.EQ.1) THEN
            CALL TTSEND (IUN,STR(1:LENSTR(STR)),1)
         ELSE
            WRITE(IUN,1000) STR(1:LENSTR(STR))
         END IF
         STR = '     Ovld. = Intensity overload'
         IF (ITERM.EQ.1) THEN
            CALL TTSEND (IUN,STR(1:LENSTR(STR)),1)
         ELSE
            WRITE(IUN,1000) STR(1:LENSTR(STR))
         END IF
         STR = '     SpOv. = Spatially overlapped'
         IF (ITERM.EQ.1) THEN
            CALL TTSEND (IUN,STR(1:LENSTR(STR)),1)
        ELSE
            WRITE(IUN,1000) STR(1:LENSTR(STR))
         END IF
      END IF
      RETURN
C
C====== Format statements
C
1000  FORMAT(A)
      END
