
C LAST UPDATE: 
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C
C******************************
C**    LSC_GET_OUTPUTFLAGS   **
C******************************
C
C **** LSC SERVICE ROUTINE ONLY ****
C
C Routine: Reads set data output flags- LSC_GET_OUTPUTFLAGS
C
      SUBROUTINE  LSC_GET_OUTPUTFLAGS (KDX, OVLD_OUT, SPAT_OUT,  
     +                          NEGINT, SIGOUT)
C
      IMPLICIT NONE
C
C Purpose: Data output flags for mtz- and/or shelx files
C
C Author:  S.Arzt, December 1997
C
C Arguments:
C
      INTEGER KDX
      INTEGER OVLD_OUT
      INTEGER SPAT_OUT
      INTEGER NEGINT
      REAL SIGOUT

C Parameters:
C OVLD_OUT      (W)   >0 = include reflections marked as overloads and
C                          containing less or equal OVLD_OUT overloaded
C                          pixels in output files
C                      0 = do not include reflections marked as 
C                          overloads in output files
C                     <0 = do include all reflections marked as 
C                          overloads in output files (exept when
C                          input file is a .ge-file)
C SPAT_OUT      (W)    1 = include reflections marked as spacial 
C                          overlapps in output files
C                      0 = do not include reflections marked as
C                          spacial overlapps in output files
C NEGINT        (W)    1 = include negative intensitie in output file
C                      0 = do not include 
C SIGOUT        (W)    only reflections with I>=SIGOUT*sigma will be
C                      included in output file
 
C
C====== GLOBALS:
C
      INCLUDE 'limits.finc'
      INCLUDE 'lsm_flags.finc'
      INCLUDE 'ref_ctrl.finc'
      INCLUDE 'scp.finc'
      INCLUDE 'scps_counters.finc'
      INCLUDE 'other_scale.finc'

C
C====== FUNCTION TYPES:
C
      INTEGER KDMSTR
      INTEGER LENSTR
      
C
C====== LOCALS:
C

      INTEGER KERR
      INTEGER MAXE
      INTEGER ND, NUM_INP, ISTAT, ITYP
      INTEGER IVAL(10)
      REAL FVAL(10)
      CHARACTER*120 STR   
      CHARACTER*50 VALSTR
      CHARACTER*80 ERRSTR  


      MAXE = 80

      STR = 'OUTPUT_OVLD'	
      CALL KDMF_GETVALUE (KDX, KDMSTR(STR),LENSTR(STR), 1, 1, 
     +                    2, KDMSTR(VALSTR), FVAL, ND, IVAL, 
     +                    NUM_INP , ISTAT, ITYP, KDMSTR(ERRSTR), 
     +                    MAXE, KERR) 
      IF (KERR.NE.0) GOTO 810   
      OVLD_OUT = IVAL(1)

      STR = 'OUTPUT_SPAT'	
      CALL KDMF_GETVALUE (KDX, KDMSTR(STR),LENSTR(STR), 1, 1, 
     +                    2, KDMSTR(VALSTR), FVAL, ND, IVAL, 
     +                    NUM_INP , ISTAT, ITYP, KDMSTR(ERRSTR), 
     +                    MAXE, KERR) 
      IF (KERR.NE.0) GOTO 810   
      SPAT_OUT = IVAL(1)

      STR = 'OUTPUT_NEGINT'	
      CALL KDMF_GETVALUE (KDX, KDMSTR(STR),LENSTR(STR), 1, 1, 
     +                    2, KDMSTR(VALSTR), FVAL, ND, IVAL, 
     +                    NUM_INP , ISTAT, ITYP, KDMSTR(ERRSTR), 
     +                    MAXE, KERR) 
      IF (KERR.NE.0) GOTO 810   
      NEGINT = IVAL(1)


      STR = 'OUTPUT_SIGCUT'	
      CALL KDMF_GETVALUE (KDX, KDMSTR(STR),LENSTR(STR), 1, 1, 
     +                    2, KDMSTR(VALSTR), FVAL, ND, IVAL, 
     +                    NUM_INP , ISTAT, ITYP, KDMSTR(ERRSTR), 
     +                    MAXE, KERR) 
      IF (KERR.NE.0) GOTO 810   
      SIGOUT = FVAL(1)

      RETURN

C====== Fatal error

 810  WRITE(6,2010) ERRSTR, STR(1:LENSTR(STR))
      WRITE(6,2000)

      STOP

 2010 FORMAT (/,' ***  ERROR  ***  ERROR IN LSC_GET_OUTPUTFLAGS',
     +       /' ERROR RETURN FROM KDMF_GETVALUE:',/,
     +       A,/,' KEYWORD: ',A)
 2000 FORMAT (//,' ******** PROCESSING STOPPED *******')
      END
