function [URL] = coadurl(archive, pass_times, StartColumn, ...
    EndColumn, StartRow, EndRow, dset_stride, ranges, variable, server)
%
%   This function will build the COADS and Esbensen-Kushnir file names.
%

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

% $Log: coadurl.m,v $
% Revision 1.4  1998/11/09 20:26:56  dbyrne
% *** empty log message ***
%
% Revision 1.5  1998/11/05 16:01:51  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.2  1998/09/13 21:31:07  dbyrne
% Updated to elminate global variables and add multivariables.
%
% Revision 1.4  1998/09/09 20:24:40  dbyrne
% Fixed syntax bug in Constraint expression.
%
% Revision 1.3  1998/09/08 21:18:08  dbyrne
% URL builder for the COADS monthly data, multivariable version.
%
% Revision 1.2  1998/09/08 14:59:07  dbyrne
% Modifications for multiple servers ....
%
% Revision 1.1  1998/05/17 14:18:01  dbyrne
% *** empty log message ***
%
% Revision 1.1.1.1  1997/09/22 14:13:54  tom
% Imported Matlab GUI sources to CVS
%

% 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));
jMonth = (StartYear - 1854) * 12 + iMonth;
 
% Got the month now the constraint.
Server = ['http://ferret.wrc.noaa.gov/cgi-bin/nph-nc/data/' ...
      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
