      function xret(x1,x2,i)
      if ( i .eq. 1 ) then
         xret = x1
      else
         xret = x2
      end if
      return
      end
