C
C**************************
C**     LFN_SOFT_DF      **
C**************************

C
CD-Routine: Soft Limits Determination Defaults - LFN_SOFT_DF
C This routine returns a suggested set of default values for use with the 
C automatic  soft limit determination procedure LFN_AUTO_SOFT. Note that 
C the number of bins and bin width values are based on the current value of 
C the requested soft limit (for the key pack i.e. the first pack) and the 
C profile intensity cutoff depends on the current image type. The profile
C fitting parameters are obtained internally via the LFN_SAINT_DF routine.
CD-end
CD-Fortran:
      SUBROUTINE LFN_SOFT_DF (IOPT, MAXBINS, NPROF, PROMIN, PROF_ROT, 
     +                        FRAC, SIGTEST, FRTEST, NBINS, BINW)
CD-end
      INCLUDE 'implicit_none.finc'
C
C Purpose: Return default parameters for automatic soft limit determination
C
C Author:  John W. Campbell, November 1994
C
C Arguments:
C
      INTEGER IOPT
      INTEGER MAXBINS
      INTEGER NPROF
      REAL PROMIN
      LOGICAL PROF_ROT
      REAL FRAC
      REAL SIGTEST
      REAL FRTEST
      INTEGER NBINS
      REAL BINW
C
CD-Parameters:
C IOPT        i  (R)  Soft limit type 1=dmin, 2=lambda-min
C MAXBINS     i  (R)  Maximum number of bins allowed
C NPROF       i  (W)  No. of bins for determining intensity profiles (8)
C PROMIN      r  (W)  Minimum intensity of spot for inclusion in profiles
C                     100.0 for film, otherwise 600.0
C PROF_ROT    l  (W)  Rotate elliptical profiles flag (.TRUE.)
C FRAC        r  (W)  Fraction of current dmin or lambda-min defining low
C                     end of range for the analysis (0.8)
C SIGTEST     r  (W)  No. of sigmas used to define significant intensity
C                     (5.0)
C FRTEST      r  (W)  Significant/measured ratio test for soft limit (0.15)
C NBINS       i  (W)  Number of bins to use 
C                     for DMIN = 5*((NINT (DMIN/BINW)+4)/5) 
C                     for LMIN = 50
C BINW        r  (W)  Bin width to use for DMIN 0.02 if dmin <=1.0
C                                               0.05 if dmin >1.0 & <=3.0
C                                               otherwise 0.1
C                                      for LMIN 0.02
CD-end
C
C====== Parameter statements
C 

C
C====== GLOBALS:
C

C
C====== FUNCTION TYPES:
C

C
C====== LOCALS:
C
      INTEGER IFLAG
      INTEGER ND
      INTEGER IERR
      REAL DMIN
      REAL LMIN
      CHARACTER*2 VALSTR
      CHARACTER*2 ERRSTR

C     INTEGER IFLAG          !Parameter status flag
C     INTEGER ND             !No. of decimal places flag
C     INTEGER IERR           !Error flag
C     REAL DMIN              !dmin value
C     REAL LMIN              !lambda-min value
C     CHARACTER*2 VALSTR     !Value string (dummy)
C     CHARACTER*2 ERRSTR     !Error string (dummy)
C
C-------------------------------------------------------------------------------
C
      CALL LFN_SAINT_DF (NPROF, PROMIN, PROF_ROT)
      FRAC = 0.8
      SIGTEST = 5.0
      FRTEST = 0.15
      IF (IOPT.EQ.1) THEN 
         CALL LDM_GET_DMIN (1, DMIN, IFLAG, ND, IERR, ERRSTR)
         IF (DMIN.LE.1.0) THEN
            BINW = 0.02
         ELSE IF (DMIN.LE.3.0) THEN
            BINW = 0.05
         ELSE
            BINW = 0.1
         END IF
         NBINS = 5*((NINT (DMIN/BINW)+4)/5)
         IF (NBINS.GT.MAXBINS) NBINS = MAXBINS
      ELSE
         CALL LDM_GET_LMIN (1, LMIN, IFLAG, ND, IERR, ERRSTR)
         BINW = 0.02
         NBINS = 50
      END IF
      RETURN
      END
