function [URL] = ncdcurl(archive, pass_times, StartColumn, ...
    EndColumn, StartRow, EndRow, dset_stride, ranges, variable, server)
%
%   This function will build the a DODS URL and constraint expression for
%   NCDC Monthly Temperature Anonmoly Data. The data covers the time range 
%   1856 to 1995.   Note that the returned data values are typically 
%   fractions of a degree and therefore need to be amplified by a factor of 
%   approximately 150 in order to fall within the value range of the default 
%   color palette of the browser
%

% To compute the index TAX_15TH determine number of years since 1856, dif1856,
% the month of the year for the input date, iMonth and compute  
%                index = 12*dif1856 + iMonth

% The preceding empty line is important.
%
% $Id: ncdcurl.m,v 1.3 1998/11/09 20:26:56 dbyrne Exp $

% $Log: ncdcurl.m,v $
% Revision 1.3  1998/11/09 20:26:56  dbyrne
% *** empty log message ***
%
% Revision 1.2  1998/11/05 16:01:54  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.1  1998/09/13 21:31:13  dbyrne
% Updated to elminate global variables and add multivariables.
%
% Revision 1.1  1998/09/09 09:34:20  dbyrne
% Used to be ncdcanomurl (name was too long).
%
% Revision 1.1  1998/05/17 14:18:07  dbyrne
% *** empty log message ***
%
% Revision 1.2  1997/11/12 18:35:29  tom
% Some strange changes.
%
% 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);
dif1856 = year - 1856;
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

% Got the month compute index.

Index = 12*dif1856 + iMonth;

Constraint = sprintf('%s', variable,'[', num2str(Index), ':', num2str(Index), '][',...
      num2str(StartRow), ':', num2str(dset_stride), ':', num2str(EndRow),'][', ...
      num2str(StartColumn), ':', num2str(dset_stride), ':',...
      num2str(EndColumn), ']');

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

return
