
	subroutine set_cr_backgnd(mode,ic,ifm,id,jd,avg)
	implicit none
	integer*4 mode,ic,ifm,id,jd,i,j
	real*4 avg(id,jd)
	character*7 head(5)
c
	if(mode.ne.1.and.mode.ne.2.and.mode.ne.4)then
	    print *,'Bad camera mode = ',mode,', no cosmic-ray background loaded'
	    return
	endif
c
c	This version only for camera 2, 2x2 binning
c	
	if(ic.eq.2.and.mode.eq.2)then
	print *,'Reading bland background from least2.grd'
	    open(10,file='least2.grd')
	    read(10,1)head
	    do j=1,128
	        read(10,2)(avg(i,j),i=1,636)
	    enddo
1	format(a7)
2	format(20f7.0)
	else
	    print *,'Zeroing out average background'
	    do j=1,jd
	    do i=1,id
	    	avg(i,j)=0.
	    enddo
	    enddo
	endif
	 return
	 end


