function [err,tim] = driver_tsfcoll( fun, n, r, NN, last )
%
%  [err,tim] = driver_tsfcoll( fun, n, rr, NN, [, last] )
%
%  Driver for tsfcoll for the problem defined by the function fun:
%      fun   = string with the function identifier;
%      n     = uniform grid (1:n)/n;
%      r     = parameter of the graded mesh (>=1);
%      NN    = vectors with the N parameters;
%      last  = flag to check the accuracy in the last point only.
%
%  In output:
%      err  = mescd obtained;
%      tim  = elapsed time.
%
last = nargin<5;
disp(['TSFCOLL on ' fun])
fprintf('uniform grid with nodes (1:%i)/%i and r=%g\n',n,n,r)
if last
   disp('error check on the whole solution')
else
   disp('error check in the last point')
end   
if r<1, error('r?'), end
eta = (1:n)'/n; 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
f = @(t,y) feval(fun,t,y);
[alpha,T,y0] = feval(fun);
y0  = y0(:);
lh  = length(NN);
err = zeros(lh,1);
tim = err;
for i = 1:lh
    tic
    [t,y]  = tsfcoll( f, T, y0, alpha, eta, r, NN(i) );
    tim(i) = toc;
    if last
        yt = feval(fun,t.');
    else
        yt = feval(fun,T);
        y  = y(end);
    end
    err(i) = mescd(y.',yt);
end
eval(sprintf(['save ' fun '_tsfcoll-%i-%i err tim NN'],n,r))
return