

C LAST UPDATE: 
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C
C**************************
C**  LSC_SCALESTAT_OUT   **
C**************************
C
CD-Routine: Refines reference set scale factors - LSC_SCALESTAT_OUT
C This subroutine refines the reference scale factor if a reference
C set is present and if the scale factors haven't been refined at that point.
C It calls LSC_REFSET_ANALYSES to output statistical tables of the
C scaling results to the log-file
CD-end
CD-Fortran:
      SUBROUTINE LSC_SCALESTAT_OUT (MINDX, EXOUT, CUTOFF, IRFTYP, 
     +                         TUNE, IUN)
CD-end
C
      INCLUDE 'implicit_none.finc'
C
C Purpose: logfile output of scaling results
C
C Author:  S. Arzt, September 1997
C
C Arguments:
C
      INTEGER MINDX
      INTEGER IRFTYP
      INTEGER IUN
      REAL TUNE(3)
      REAL CUTOFF      
      LOGICAL EXOUT
CD-Parameters:
C MINDX      i (R)    The index of the Laue Integrated Reflections List     
C CUTOFF     r (R)    Outlier cutoff
C EXOUT      l (R)    Outlier exclusion flag 
C                     .true.  = exclude outliers
C                     .false. = include outliers
C IRFTYP     i (R)    Refinement routine type =1 Use LSQMIN
C                                             =2 Use LSQMQL
C TUNE()     r (R)    Tuning parameters specific to the refinement type
C                           If LSQMQL   TUNE(1) = tolerance (ACC)
C                                       TUNE(2) = step size (H)
C IUN        i (R)    Output number for log-file
CD-end

C
C====== PARAMETERS
C 
      INCLUDE 'limits.finc'
C
C====== GLOBALS:
C
      INCLUDE 'view_handles.finc'
      INCLUDE 'get_soft.finc'
      INCLUDE 'screen_params.finc'
      INCLUDE 'scp.finc'
      INCLUDE 'scps_counters.finc'
C
C====== FUNCTION TYPES:
C

C
C====== LOCALS:
C
      INTEGER IERR
      REAL FMIN
      CHARACTER*120 MESSAGE
      CHARACTER*80 ERRSTR
      
      CALL LSM_SELECT_SCREFS_LSP (IERR, .TRUE., ERRSTR)
      CALL LSM_SET_RFLAGS ( -1, -1,-1, .FALSE., .FALSE.,
     +                     .FALSE., .TRUE., .TRUE.)
      CALL LSM_REFINE (MINDX, .TRUE., IRFTYP, 
     +                TUNE, FMIN, IERR, MESSAGE) 
      CALL LSM_KDMCOPY(2, IERR, ERRSTR)
      CALL LSC_ANALYSES(MINDX, .TRUE., 0, 0, EXOUT, CUTOFF)

      CALL LSC_REFSET_ANALYSES (MINDX,.TRUE., IUN)

      RETURN

      END
