function Var = LTSpiceRaw_Fa( filename, varargin )
  
  tic
  if nargin==0,
    error( 'Function takes 1, 2, or 3 input parameters.' );
  elseif nargin==1,
    selected_vars = [2]; %  always 1 and 2
    downsamp_N = 1;
  elseif nargin==2,
    selected_vars = varargin{1};
    if ischar(selected_vars), selected_vars=lower(selected_vars); end
    downsamp_N = 0;
  elseif nargin==3,
    selected_vars = varargin{1};
    if ischar(selected_vars), selected_vars=lower(selected_vars); end
    downsamp_N = varargin{2};
  else
    error( 'Function takes only 1, 2, or 3 input parameters.' );
  end
  
  filename = fliplr(deblank(fliplr(deblank(filename))));   
        % Remove leading and trailing spaces.
  fid = fopen(filename, 'rb');
  if length(fid)==1 & isnumeric(fid) & fid==-1,
    %try to append ".raw" to the file name ...
    fid = fopen(sprintf( '%s.raw', filename ), 'rb');
    if length(fid)==1 & isnumeric(fid) & fid==-1,
      error( sprintf( 'Could not open file "%s"', filename ) );
    end    
  end       

  fprintf('Filename: %s\n',filename);
  fprintf('Variables: ');
  fprintf('%u ',selected_vars);
  fprintf('\nDownSampl: ');
  fprintf('%f\n',downsamp_N);
  
  % Open File
  [filename, the_permision, machineformat] = fopen(fid);
  ns=1; % Initializing
  
  % Run till No. Variables is found
  a=fgetl(fid);Var.top{1}=a(find((a==char(0))==0)); %#ok<*FNDSB>
  tmp=Var.top{ns};ns=ns+1;disp(tmp);
  while strcmp(tmp(5:13),'Variables')==0
   a=fgetl(fid);Var.top{ns}=a(find((a==char(0))==0));
   tmp=Var.top{ns};
    ns=ns+1;
  end
  Var.no=str2num(tmp(16:end));  % Variables

  % Run till No. Points is found
  a=fgetl(fid);Var.top{ns}=a(find((a==char(0))==0));
  tmp=Var.top{ns};
  while strcmp(tmp(5:10),'Points')==0
    a=fgetl(fid);Var.top{ns}=a(find((a==char(0))==0));
    tmp=Var.top{ns};
    ns=ns+1;
  end
  Var.points=str2num(tmp(14:end)); %#ok<*ST2NM> % Points

  % Run till Offset is found
  ns=ns+1;a=fgetl(fid);Var.top{ns}=a(find((a==char(0))==0));
  tmp=Var.top{ns};
  while strcmp(tmp(1:6),'Offset')==0
   a=fgetl(fid);Var.top{ns}=a(find((a==char(0))==0));
   tmp=Var.top{ns};
    ns=ns+1;
  end
  Var.offset=str2num(tmp(9:end)); % Offset: 

  % Run til Variables: are found
  ns=ns+1;
  while strcmp(tmp(1:9),'Variables')==0
    a=fgetl(fid);Var.top{ns}=a(find((a==char(0))==0));
    tmp=Var.top{ns};
    ns=ns+1;
  end

  % Make list of variables
  for n=1:Var.no
    a=fgetl(fid);Var.str{n}=a(find((a==char(0))==0)); % Variables:
    x=(Var.str{n}==char(9)); y=find(x==1);  
    for n3=1:size(y,2)-1
      Var.list{n}{n3}=Var.str{n}(y(n3)+1:y(n3+1)-1);
    end;       
    Var.list{n}{n3+1}=Var.str{n}(y(n3+1)+1:end);
  end;
  
  % Run till Binary are found
  a=fgetl(fid);Var.top{ns}=a(find((a==char(0))==0));
  tmp=Var.top{ns};
  while strcmp(tmp(1:6),'Binary')==0
    a=fgetl(fid);Var.top{ns}=a(find((a==char(0))==0));
    tmp=Var.top{ns};
    ns=ns+1;
  end

  % Display all meas. data
  for N=1:Var.no;
    disp(Var.str{N}),
  end;
  n=0; nl=floor(0.01*double(intmax)/(Var.no+1));
  tmp = fread(fid,1,'int8',0); % Ignore 1 byte
  Var.selected_vars=selected_vars;
  posb=ftell(fid);  
  while (~feof(fid)) % Data
    n=n+1;
    data = single(fread(fid,[Var.no+1 nl],'single',0));
    [tmp,szy]=size(data);
    Vxr.data(:,n*nl-nl+1:n*nl-nl+szy)=...
        data(selected_vars+2,:);
    clear data; % toc
  end
  toc; fseek(fid,posb,'bof');n=0;
  while (~feof(fid)) % Time
    n=n+1;
    data = fread(fid,[1 nl],'double',4*(Var.no-1));
    [tmp,szy]=size(data);
    Vxr.time(1,n*nl-nl+1:n*nl-nl+szy)=data(1,:);
    clear data; toc
  end
  toc;
  % Group plots into Steps
  x=find(Vxr.time==0); n=0;
  % disp(x);
  if size(x,2)-1>1
    for n=1:size(x,2)-1
      Var.time{n}=Vxr.time(1,x(n):x(n+1)-1);
      Var.data{n}=Vxr.data(:,x(n):x(n+1)-1);
    end;
  end;  
  Var.time{n+1}=Vxr.time(1,x(n+1):end);
  Var.data{n+1}=Vxr.data(:,x(n+1):end);
  fclose(fid); toc; clear Vxr
  
  n=1; % Show selected variable info 
  for N=Var.selected_vars+1;
    disp([num2str(n) '  ' Var.str{N}]);
    n=n+1;
  end;
 
  % sort data to remove negative timesteps
  
  % Time adjust data if downsamp_N > 0
  if (downsamp_N >0);
    for n2=1:size(x,2)
      dtid=(Var.time{n2}(end)-Var.time{n2}(1))...
            /(size(Var.time{n2},2)-1);
      Vxr.tim2{n2}=[Var.time{n2}(1):...
                   dtid*downsamp_N:Var.time{n2}(end)];
      for n3=1:size(selected_vars,2)                     
        Vxr.data{n2}(n3,:)= interp1(Var.time{n2},...
               Var.data{n2}(n3,:),Vxr.tim2{n2},'spline');
      end;
      Var.time{n2}=Vxr.tim2{n2};
      Var.data{n2}=Vxr.data{n2};
      toc;
    end;
    disp('Time adjusted downsapling')
  end;
  
  % Desimate data if downsamp_N < 0
  if (downsamp_N < 0);
    for n2=1:size(x,2)
      Var.time{n2}=Var.time{n2}(1:-downsamp_N:end);
      Var.data{n2}=Var.data{n2}(:,1:-downsamp_N:end);
    toc;
    end;
    disp('Desimated downsapling')
  end;
clear Vxr
end