function u = advectl(x, t, al, x0l, deltal)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Function to compute exact solution of advection equation for 
% intitial data given by a gaussian pulse.
%
% Input arguments
%
%      x:      (real vector) Spatial grid, length nx. 
%      t:      (real scalar) Time at which to compute solution.
%      al:     (real scalar) Overall amplitude of gaussian.
%      x01:    (real scalar) x location of centre of gaussian.
%      deltal: (real scalar) Effective width of gaussian.
%
% Output argument
%
%      u:      (real vector)  Length nx vector containing exact solution 
%              u(t,x(j)) 
%
% Assumes that x is monotonically increasing.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   % Define output argument u to be 0 length vector as default (so 
   % that *some* vector is returned in the case that an invalid
   % input argument is detected.
   u  = zeros(0,0);

   if ~ isvector(x) 
      fprintf('advect1: x is not a vector\n');
      return;
   end

   % Initialize u to 0 vector with same length as x.
   u = zeros(1,length(x));
   if deltal == 0
      fprintf('advect1: deltal = 0\n');
      return
   end

   % Compute values using gaussian function (which also returns 
   % first and second derivatives of the profile).
   [u du ddu] = gaussian(x + t, al, x0l, deltal);

   % Make initial data compatible with boundary condition.
   u([length(u)]) = 0;
end
