	SUBROUTINE SESPAC
C SET THE RSPACE BITS.  THE ARRAYS IRLOC AND IRSPAC ARE USED.
C AN ENTRY IS MADE FOR EACH VALUE ENTERED AND FOR THE DOUBLET BITS, 
C AND THE LEFT AND RIGHT SHIFTED BITS.
C
C	CALLED BY:	SEDILG
C	CALLS:		SERMAP
C
	INCLUDE 'SEARCH.INC'
	DIMENSION BLINE(80)
	DATA BCOLON /':'/
	IDCNT = 0			!COUNTER FOR DOUBLETS
	NSPACE = 0			!COUNTER FOR # OF RSPACES
	LEND = .FALSE.			!END OF INPUT FLAG
	WRITE (ILUO,10)
10	FORMAT (' ENTER RSPACE INFORMATION (40 MAX)'/
     *		'   SEPARATE EACH RSPACE WITH A BLANK'/
     *		'   YOU MAY USE MORE THAN ONE LINE'/
     *		'   WHEN YOU ARE FINISHED TYPE A '' :'' ')
20	WRITE (ILUO,25)
25	FORMAT ('$*')
C READ THE RSPACES
	READ (ILUI,30) IN,(BLINE(I),I=1,IN)
30	FORMAT (Q,79A1)
C SEE IF A COLON WAS ENTERED TO INDICATE END OF INPUT
	IF (BLINE(IN) .EQ. BCOLON) THEN
	  LEND = .TRUE.
	  IN = IN - 1
	END IF
	BLINE(IN+1) = BLANK		!ADD A BLANK AS A DELIMITER
	IS = 1
	DO 75 I=1,IN+1
	  IF (BLINE(I) .EQ. BLANK) THEN
	    IF (I .GT. IS) THEN
C CONVERT INTO A NUMBER
	      DECODE (I-IS+1,40,BLINE(IS),ERR=80) RSPACE
40	      FORMAT (E15.0)
C IF THE RSPACE IS WITHIN RANGE, CONVERT IT USING THE CAMERA CONSTANT
C TO THE STANDARD OF 2.5 (CONST) USED WHEN SETTING UP THE DATA FILE
	      IF ((RSPACE .GT. 0.) .AND. (NSPACE .LT. IRSMAX)) THEN
	        INUM = (RSPACE/CAMCON*CONST)/RES + 1	!BIT NUMBER
	        IF (INUM .GT. IRBMAX) GOTO 75		!TOO LARGE
C STORE THE RSPACES IN ASCENDING ORDER
	        IF (NSPACE .GT. 0) THEN
C TEST FOR MAPPING TO SAME BIT
	          DO 45 N=1,NSPACE
	            IF (INUM .EQ. ISPNUM(N)) THEN
	              WRITE (ILUO,42) RSPAC(N),RSPACE
42	              FORMAT (' SPACES: ',2F8.5,' MAP TO SAME BIT,',
     *			' FIRST IS USED')
	              GOTO 70
	            END IF    
45	            CONTINUE
C BITS ARE DIFFERENT
	          DO 50 N=NSPACE,1,-1
	            IF (RSPACE .GT. RSPAC(N)) GOTO 60
C RSPACE IS SMALLER THAN CURRENT ENTRY, SHIFT ENTRIES
	            ISPNUM(N+1) = ISPNUM(N)
	            RSPAC(N+1) = RSPAC(N)
50	            CONTINUE
	        END IF
	        N = 0
C ORDER IS OK, SAVE THE VALUE
60	        NSPACE = NSPACE + 1
	        ISPNUM(N+1) = INUM 
	        RSPAC(N+1) = RSPACE
70	        IS = I + 1
	      END IF
	    END IF
	  END IF
75	  CONTINUE
	IF (LEND) GOTO 90			!FINISHED
	GOTO 20
C ERROR
80	WRITE (ILUO,*) 'ERROR DECODING NUMBER, PLEASE REENTER'
	GOTO 20
C SET UP BIT MAPS
90	IFOMAX = 0
	DO 100 I=1,NSPACE
	  IFOMAX = IFOMAX + I		!MAX FOM VALUE
	  INUM = ISPNUM(I)
	  N = I
C MARK SINGLET BITS IN IRLOC AND IRSPAC
	  CALL SERMAP (N,INUM,1)	!SET SINGLET BIT
	  CALL SERMAP (N,INUM-1,2)	!SET LEFT SINGLET BIT
	  CALL SERMAP (N,INUM+1,3)	!SET RIGHT SINGLET BIT
C SET DOUBLET BITS
	  INUM2 = (RSPAC(I)*2/CAMCON*CONST)/RES + 1
	  IF (INUM2 .LE. IRBMAX) THEN
C ONLY IDMAX DOUBLET BITS ARE SET
	    IF (IDCNT .GE. IDMAX) THEN
	      INUM2 = -200	!MARK SO NO BIT IS SET
	    ELSE
	      IDCNT = IDCNT + 1
	      ISDNUM(IDCNT) = INUM2	!SAVE BIT VALUE FOR SERHIT ROUTINE
	    END IF
	  END IF
	  CALL SERMAP (N,INUM2,4)	!SET DOUBLET BIT
	  CALL SERMAP (N,INUM2-1,5)	!SET MINUS DOUBLET BIT
	  CALL SERMAP (N,INUM2+1,6)	!SET PLUS DOUBLET BIT
100	  CONTINUE
	ITOT = NSPACE + IDCNT		!TOTAL # OF BITS SET
	IMISS = ITOT/SFAC		!ALLOWED # BIT MISSED
	IHMIN = ITOT-IMISS		!REQUIRED # RSPACE HITS
	RETURN
	END
