
yourfmt=menu('What format is your data stored?',...
          '1) ascii column file',...
          '2) .mat',...
          '3) some other file with header info',...
          '4) netCDF (not operational yet)');

%
if yourfmt == 1
%
  timeform= menu('How do you want to extract data? ',...
      ' using a particular column (such as yearday) as a delimiting keyed variable',...
      ' using all the data and to be prompted for minimum & interval time');
  if timeform==1;
    tinit=input('Enter desired intial time in yearday (121.5 = noon on May 1, for example):');
    ti=input(' Enter your sampling time interval in hours:  ');
    tiend=input('Enter your final time in yearday (121.5 = noon on May 1, for example):');
%
%   An M-file called "BUILDMAT.M" is used to load data
%   from ASCII files. It returns an mxn matrix "Y" which
%   has "m" # of pts. and "n" variables
    [y]=buildmat(tinit,tiend);
%
  elseif timeform==2;
    disp(' ');
    disp(' this option assumes you want the entire file(s)');
    disp(' ');
    tinit=input('Enter your intial time in yearday (121.5 = noon on May 1, for example):');     ti=input(' Enter your sampling time interval in hours:  ');
    [y]=buildmat
  end;
%
% now form the time vector
%
  tint=ti/24;
  ndays=tint*(length(y(:,1))-1);
  t=tinit:tint:tinit+ndays;
 %
end


if yourfmt == 2
    disp('  ')
    disp('This option assumes you have all variables in a "y" matrix.');
    disp(' and your time variable in a "t" matrix.');
    disp('  ')
    filen=input('Enter the .MAT filename without the ".mat" specification: ','s');
%
% check to see if this file exist
%
    filen=[filen,'.mat'];
    e=exist(filen);
    if e==0;
      disp(' ');
      disp(' Sorry, no file exist with that name. Try again.');
      disp('  ')
      filen=input('Enter the .MAT filename without the ".mat" specification: ','s');
    else
    end;
   disp(' ');
   disp([' Please wait while loading',filen,'...']);
   disp(' ');
   eval(['load ',filen,';']);

%    ti=input(' Enter your sampling time interval in hours:  ');
%  we assume that the sampling time interval in hours can
%  be derived from mean(diff(t))
   ti=mean(diff(t))*24;

   stt=menu('What to do now?','continue','extract certain columns',...
            'extract certain coloumns AND save that as a separate file');

   if stt>=2;
     col=input('Enter the vector of column numbers of interest: ');
     y=y(:,col);
   end;

   if stt==3;
%    save this file as a separate file for future processing
     ei=input('Enter extra identifyer to add to original filename: ','s');
     eval(['save ',filen(1:length(filen)-4),ei,' t y']);
   end;

end


if yourfmt==3;
%
%  here we load data differently depending on what format is is

  ext=input('Enter extension (ie type): ','s');
  
  if ext=='bls';
    disp('Assume a "bl2ml.ctl" file with list of filenames')
    disp('exist before running this.');
    bl2ml
  end;
end;
  