C+
C NAME:
C	smei_frm_mode
C PURPOSE:
C	Get mode and binning factor for SMEI data
C CATEGORY:
C	ucsd/camera/for/lib
C CALLING SEQUENCE:
	integer function smei_frm_mode(N, ibin)
C INPUTS:
C	N		integer		identifies size of SMEI frame
C					Can be horizontal size, vertical size
C					or total number of pixels in frame
C OUTPUTS:
C	smei_frm_mode	integer		mode ID (0, 1 or 2)
C	ibin		integer		binning factor (=2^mode, i.e. 1,2 or 4)
C INCLUDE:
	include		'smei_frm_layout.h'
C MODIFICATION HISTORY:
C	JUN-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
C-
	    integer	N
	    integer	ibin

	if (N .eq. SMEI__FRM_NPIX .or. N .eq. SMEI__FRM_NX .or. N .eq. SMEI__FRM_NY) then

	    mode = 0
	    ibin = 1

	else if (N .eq. SMEI__FRM_NPIX/4 .or. N .eq. SMEI__FRM_NX/2 .or. N .eq. SMEI__FRM_NY/2) then

	    mode = 1
	    ibin = 2

	else if (N .eq. SMEI__FRM_NPIX/16 .or. N .eq. SMEI__FRM_NX/4 .or. N .eq. SMEI__FRM_NY/4) then

	    mode = 2
	    ibin = 4

	else

	    mode = N
	    ibin = -1

	end if

	smei_frm_mode = mode

	return
	end
