function [URL] = doeurl(archive, pass_times, StartColumn, ...
    EndColumn, StartRow, EndRow, dset_stride, ranges, variable, server)
%
%   This function will build DOE precip anomaly file names.
%

% The preceding empty line is important.
%
% $Id: doeurl.m,v 1.2 1999/06/29 16:51:49 kwoklin Exp $

% $Log: doeurl.m,v $
% Revision 1.2  1999/06/29 16:51:49  kwoklin
% Quick fixes on some cat files.           klee
%
% Revision 1.1  1999/05/27 18:25:24  tom
% added to the GUI
%

% Need to get the month first.
year = pass_times(1);
yearday = pass_times(2);

if rem(year,4) ~= 0 | year == 1900
   MonthLastDay = [31 59 90 120 151 181 212 243 273 304 334 400];
else
   MonthLastDay = [31 60 91 121 152 182 213 244 274 305 335 400];
end

iMonth = 0;
while yearday > MonthLastDay(iMonth+1)
  iMonth = iMonth + 1;
end

StartYear = floor(ranges(4,1));

% I think it should be 1851, since data started from 1851.   klee
%jMonth = (StartYear - 1854) * 12 + iMonth;
jMonth = (StartYear - 1851) * 12 + iMonth;
 
% Got the month now the constraint.
Server = ['http://www.cdc.noaa.gov/cgi-bin/nph-nc/Datasets/doe/' ...
      deblank(server)];
variable = deblank(variable);
Constraint = [sprintf('%s', variable, '[', num2str(jMonth), ':', ...
      num2str(jMonth), '][', num2str(StartRow), ':', ...
      num2str(dset_stride), ':', num2str(EndRow),'][', ...
      num2str(StartColumn), ':', num2str(dset_stride), ':',...
      num2str(EndColumn), ']')];
URL = sprintf('%s', Server, '?', Constraint);
return
