function [URL] = prevuurl(archive, pass_times, StartColumn, ...
    EndColumn, StartRow, EndRow, dset_stride, ranges, variable, server)
%
%   This function will build the prevu file name.
%

% The preceding empty line is important.
%
% $Id: prevuurl.m,v 1.6 1998/11/09 20:26:57 dbyrne Exp $

% $Log: prevuurl.m,v $
% Revision 1.6  1998/11/09 20:26:57  dbyrne
% *** empty log message ***
%
% Revision 1.3  1998/11/05 16:01:55  root
% Changed LonVector and LatVector to be used if no Lon returned and tried the update function.
% DataScale and DataNull should now be optional!
%
% Revision 1.4  1998/09/13 21:31:17  dbyrne
% Updated to elminate global variables and add multivariables.
%
% Revision 1.2  1998/09/09 16:10:28  dbyrne
% Fixed numerous small bugs.
%
% Revision 1.1  1998/05/17 14:18:11  dbyrne
% *** empty log message ***
%
% Revision 1.1.1.1  1997/09/22 14:13:55  tom
% Imported Matlab GUI sources to CVS
%

variable = deblank(variable);
server = deblank(server);
year = pass_times(1);
yearday = pass_times(2);

if rem(year,4) ~= 0 | year == 1900
   MonthFirstDay = [1 32 60 91 121 152 182 213 244 274 305 335 400];
else
   MonthFirstDay = [1 32 61 92 122 153 183 214 245 275 306 336 400];
end

iMonth = 0;
while MonthFirstDay(iMonth+1) <= yearday
   iMonth = iMonth + 1;
end

% Got the month now the get the directory in which the data of interest reside.

if iMonth < 10
   Directory = sprintf('%2s%2.2i%1s%1.1i%1s', '19', year, '/', iMonth, '/');
else
   Directory = sprintf('%2s%2.2i%1s%2.2i%1s', '19', year, '/', iMonth, '/');
end

Satellites = pass_times(6);
if all(pass_times >= 0)
  ImgName = sprintf('%1s%2.2i%3.3i%2.2i%2.2i%2.2i%6s', Satellites, ...
      pass_times(1), pass_times(2), pass_times(3), pass_times(4), pass_times(5), '.pvu.Z');
else
  ImgName = sprintf('%1s%2.2i%3.3i%2.2i%2.2i%2.2i%6s', Satellites, ...
      pass_times(1), pass_times(2), pass_times(3), 0, 0, '.pvu.Z');
end
Constraint = sprintf('%s', variable,'[', ...
      num2str(StartRow), ':', num2str(dset_stride), ':', num2str(EndRow),'][', ...
      num2str(StartColumn), ':', num2str(dset_stride), ':',...
      num2str(EndColumn), ']');

URL = sprintf('%s', server, Directory, ImgName, '?', Constraint);

return




