C---------------------------------------------------------------------------
C---------------------------------------------------------------------------
	SUBROUTINE EXCLR(TABLE)
C
C	CLEARS A TABLE OF EXCLUDED REGIONS
C---------------------------------------------------------------------------
C
	INTEGER*4 TABLE(*)		!  table to store bit map
	integer EX_words			!  number of words
	PARAMETER (EX_words = 1964)

C The table covers all possible PDF encoded values:
C  PDF = 10000 * (4*THETA - pi) for THETA in radians @ Cu K alpha 1
C  so for THETA = min = 0  ==> PDF = -31416
C   for THETA = max = pi/2 ==> PDF = +31416
C  (2*31416+ 1)/32 = 1964
C	EXCLUDED REGIONS, EACH ENTRY HAS ONE BIT ASSOCIATED WITH IT
C
	DO N=1,EX_words
	  TABLE(N) = 0
	ENDDO
	RETURN
	END
C---------------------------------------------------------------------------
C---------------------------------------------------------------------------
	SUBROUTINE EXset(TABLE,pdf1,pdf2,SETCLR)
C
C	Sets or clears the bit corresponding to a particular card
C---------------------------------------------------------------------------
C
	INTEGER*4 TABLE(*)		!  table to store bit map
	INTEGER*2 pdf1,pdf2
	integer SETCLR			!  value to set (0 or 1)

	integer EX_words			!  number of words
	PARAMETER (EX_words = 1964)

	If (pdf2 .lt. pdf1) type *,'EXSET -- illegal PDF range'

	do k=pdf1,pdf2
	  k1 = k + 31416
	  N1 = MOD(k1,32)
	  k1 = k1/32 + 1
	  If (K1 .le. 0 .or. K1 .gt. EX_words) 
	1	STOP 'EXset ERROR -- illegal PDF range value'
	  IF (SETCLR .eq. 0) then 
	    TABLE(K1) = IBCLR(TABLE(K1),N1)
	  ELSE
	    TABLE(K1) = IBSET(TABLE(K1),N1)
	  ENDIF
	ENDDO
	RETURN
	END
C---------------------------------------------------------------------------
C---------------------------------------------------------------------------
	LOGICAL FUNCTION EXRtst(TABLE,PDF2T)
C
C	Returns .TRUE. if the bit corresponding to a particular angles is set
C---------------------------------------------------------------------------
C
	INTEGER*4 TABLE(*)		!  table to store bit map
	INTEGER*2 PDF2T

	integer EX_words			!  number of words
	PARAMETER (EX_words = 1964)

	k = PDF2t 
	k = k + 31416
	N = MOD(k,32)
	k = k/32 + 1
	If (K .le. 0 .or. K .gt. EX_words) 
	1	STOP 'EXRtst ERROR -- illegal PDF2T value'
	EXRtst = .false.
	IF (IBITS(TABLE(k),N,1).EQ.1) EXRtst = .true.
	RETURN
	END
