      subroutine spinbit(run,bunch,isb)
      integer isb,run,bunch
      integer pat1(120) 
      integer pat2(120) 
      integer pat3(120) 
      integer pat4(120) 
      integer pat5(120) 
      data pat1/
     +    51, 0, 83, 0, 53, 0, 85, 0, 
     +    51, 0, 83, 0, 53, 0, 85, 0, 
     +    51, 0, 83, 0, 53, 0, 85, 0, 
     +    51, 0, 83, 0, 53, 0,  5, 0, 
     +     3, 0,  3, 0,  5, 0,  5, 0,
     +    51, 0, 83, 0, 53, 0, 85, 0, 
     +    51, 0, 83, 0, 53, 0, 85, 0, 
     +    51, 0, 83, 0, 53, 0, 85, 0, 
     +    51, 0, 83, 0, 53, 0, 85, 0, 
     +    51, 0, 83, 0, 53, 0, 85, 0, 
     +    51, 0, 83, 0, 53, 0, 85, 0, 
     +    51, 0, 83, 0, 53, 0, 85, 0, 
     +    51, 0, 83, 0, 53, 0, 85, 0, 
     +    51, 0, 83, 0, 53, 0, 80, 0, 
     +    48, 0, 80, 0, 48, 0, 80, 0/
      data pat2/
     +    51, 0, 85, 0, 51, 0, 85, 0,
     +    51, 0, 85, 0, 51, 0, 85, 0,
     +    51, 0, 85, 0, 51, 0, 85, 0,
     +    51, 0, 85, 0, 51, 0,  5, 0,
     +     3, 0,  5, 0,  3, 0,  5, 0,
     +    51, 0, 85, 0, 51, 0, 85, 0,
     +    51, 0, 85, 0, 51, 0, 85, 0,
     +    51, 0, 85, 0, 51, 0, 85, 0,
     +    51, 0, 85, 0, 51, 0, 85, 0,
     +    51, 0, 85, 0, 51, 0, 85, 0,
     +    51, 0, 85, 0, 51, 0, 85, 0,
     +    51, 0, 85, 0, 51, 0, 85, 0,
     +    51, 0, 85, 0, 51, 0, 85, 0,
     +    51, 0, 85, 0, 51, 0, 80, 0, 
     +    48, 0, 80, 0, 48, 0, 80, 0/
      data pat3/
     +    51, 0, 53, 0, 83, 0, 85, 0, 
     +    51, 0, 53, 0, 83, 0, 85, 0, 
     +    51, 0, 53, 0, 83, 0, 85, 0, 
     +    51, 0, 53, 0, 51, 0,  5, 0, 
     +     3, 0,  5, 0,  3, 0,  5, 0,
     +    51, 0, 53, 0, 83, 0, 85, 0, 
     +    51, 0, 53, 0, 83, 0, 85, 0, 
     +    51, 0, 53, 0, 83, 0, 85, 0, 
     +    51, 0, 53, 0, 83, 0, 85, 0, 
     +    51, 0, 53, 0, 83, 0, 85, 0, 
     +    51, 0, 53, 0, 83, 0, 85, 0, 
     +    51, 0, 53, 0, 83, 0, 85, 0, 
     +    51, 0, 53, 0, 83, 0, 85, 0, 
     +    51, 0, 53, 0, 83, 0, 80, 0, 
     +    48, 0, 48, 0, 80, 0, 80, 0/
      data pat4/
     +    53, 0, 51, 0, 85, 0, 83, 0, 
     +    53, 0, 51, 0, 85, 0, 83, 0, 
     +    53, 0, 51, 0, 85, 0, 83, 0, 
     +    53, 0, 51, 0, 53, 0,  3, 0, 
     +     5, 0,  3, 0,  5, 0,  3, 0,
     +    53, 0, 51, 0, 85, 0, 83, 0, 
     +    53, 0, 51, 0, 85, 0, 83, 0, 
     +    53, 0, 51, 0, 85, 0, 83, 0, 
     +    53, 0, 51, 0, 85, 0, 83, 0, 
     +    53, 0, 51, 0, 85, 0, 83, 0, 
     +    53, 0, 51, 0, 85, 0, 83, 0, 
     +    53, 0, 51, 0, 85, 0, 83, 0, 
     +    53, 0, 51, 0, 85, 0, 83, 0, 
     +    53, 0, 51, 0, 85, 0, 80, 0, 
     +    48, 0, 48, 0, 80, 0, 80, 0/
      data pat5/
     +    85, 0, 83, 0, 53, 0, 51, 0,
     +   153, 0, 85, 0, 83, 0, 53, 0,
     +    51, 0, 85, 0, 83, 0, 53, 0,
     +    51, 0, 85, 0, 83, 0,  5, 0,
     +     3, 0,  5, 0,  3, 0,  5, 0,
     +    51, 0, 53, 0, 83, 0, 85, 0,
     +   153, 0, 51, 0, 53, 0, 83, 0,
     +    85, 0, 51, 0, 53, 0, 83, 0,
     +    85, 0, 51, 0, 53, 0, 83, 0,
     +    85, 0, 51, 0, 53, 0, 83, 0,
     +    85, 0, 51, 0, 53, 0, 83, 0,
     +   153, 0, 85, 0, 51, 0, 53, 0,
     +    83, 0, 85, 0, 51, 0, 53, 0,
     +    83, 0, 85, 0, 51, 0, 48, 0,
     +    80, 0, 80, 0, 48, 0, 48, 0/
      isb=-1
      if(run.ge.4123008 .and. run.le.4123133) then
         isb=pat1(bunch+1)
      elseif(run.ge.4123134 .and. run.le.4125069) then
         isb=pat3(bunch+1)
      elseif(run.ge.4126001 .and. run.le.4147016) then
         isb=pat1(bunch+1)
      elseif(run.ge.4147019 .and. run.le.4148018) then
         isb=pat4(bunch+1)
      elseif(run.ge.4148019 .and. run.le.4148033) then
         isb=pat4(bunch+1)
      elseif(run.ge.4148037 .and. run.le.4150010) then
         isb=pat5(bunch+1)
      endif
      return
      end


