function [err,tim] = driver_flmm2( fun, hh, meth, last )
%
%  [err,tim] = driver_flmm2( fun, hh, meth, last )
%
%  Driver for flmm2 for the problem defined by the function fun:
%      fun  = string with the function identifier;
%      hh   = timesteps used;
%      meth = method used (1=trapezoidal; 2=Newton-Gregory; 3=BDF2);
%      last = flag to check the accuracy in the last point only.
%
%  In output:
%      err  = mescd obtained;
%      tim  = elapsed time.
%
last = nargin<4;
if meth==1
    metodo = 'trapezoidal rule';
elseif meth==2
    metodo = 'Newton-Gregory formula';
elseif meth==3
    metodo = 'BDF2 method';
else
    error('meth?')
end    
disp(['FLMM2-' metodo ' on ' fun])
if last
   disp('error check on the whole solution')
else
   disp('error check in the last point')
end   
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
f     = @(t,y) feval(fun,t,y);
Jf    = @(t,y) feval(fun,t,y,1);
[alpha,T,y0] = feval(fun);
y0    = y0.';
lh    = length(hh);
err   = zeros(lh,1);
tim   = err;
tol   = 1e-15;
itmax = 1000;
for i = 1:lh
    tic
    [t,y]  = flmm2(alpha,f,Jf,0,T,y0,hh(i),[],meth,tol,itmax);
    tim(i) = toc;
    if last
        yt = feval(fun,t.');
    else
        yt = feval(fun,T);
        y  = y(:,end);  disp([y.' yt])        
    end
    err(i) = mescd(y.',yt);
end
eval(sprintf(['save ' fun '_flmm2-%i err tim hh'],meth))
return