;+
;NAME:
;	hxt_usegrd
;PURPOSE:
;	Reads in the flag for SC use
;CATEGORY:
;       Yohkoh HXT
;CALLING SEQUENCE:
;	hxt_usegrd,grausfile,grause
;INPUT:	
;	grausfile= grid use filename, or an array of 64 1's or 0's
;                  if set to 0, that subcollimator is not used
;OUTPUT:
;	grause(8)=Each element is either 0b or 255b, 
;		If grause(j)=0b, then the Subcollimators with 
;		spatial wave number j+1 aren't used in the calculation
;               changed, 26-nov-96
;MODIFICATION HISTORY:
;	Written June '92 by J.McTiernan
;       Rewritten, 26-nov-1996, jmm, to allow individual
;       collimators to be dropped out.
;       2-dec-1996, allow an array of 64 1's and 0's to be passed in.
;       New name, 24-jun-1998, jmm
;-
PRO Hxt_usegrd, grausfile, grause
   grdnum = 64                    ;no. of SC grids
;Open file, or allow an array of 64 0's and 1's to be passed in
   sizz = size(grausfile) & typ = sizz(sizz(0)+1)
   n = N_ELEMENTS(grausfile)
   numbers = (typ EQ 1) OR (typ EQ 2) OR (typ EQ 4) OR (typ EQ 5)
   IF(typ EQ 7) THEN BEGIN      ;a filename
      openr, twelve, grausfile, /GET_LUN
;Input data
      iuse = intarr(grdnum)
      readf, twelve, iuse
      free_lun, twelve
   ENDIF ELSE IF(numbers AND (n EQ grdnum)) THEN BEGIN
      iuse = fix(grausfile)
   ENDIF ELSE BEGIN
      message, /info, 'Bad input, use all SC''s'
      iuse = intarr(grdnum)+1
   ENDELSE
;Put data into wierd format
   juse = intarr(8, 8)
   juse(*) = iuse(*)
   grause = bytarr(8)
   arrx = [1, 2, 4, 8, 16, 32, 64, 128]
   FOR kj = 0, 7 DO grause(kj) = total(arrx*juse(*, kj))

   RETURN
END

