function [url,loaddodsbool,infotext] = gbfvctdu ...
         (getarchive, getranges, getmode, getvariablelist, getserverlist, passtimes, passdepths, whichurl)
%
%    This function will build gbfvctd file name and return infotext and url to the browser
%

% The preceding empty line is important
% $Log: gbfvctdu.m,v $
% Revision 1.2  1999/06/24 19:05:00  kwoklin
% Change file name of nbnerr.m. Fix some display bugs, define precision level
% of lat/lon/depth/time, and fix some more bugs in globec files.        klee
%
% Revision 1.1  1999/06/01 07:10:30  dbyrne
%
%
% Moved up from kleedata/
%
% Revision 1.3  1999/05/28 22:53:04  kwoklin
% Point to new server for all jgofs datasets. Update getjgsta on loaddods.
% Fix infotext for all gb geturl files. Fix transmissivity for some gb
% files. Modify some variable names on gb files.       klee
%

% $Id: gbfvctdu.m,v 1.2 1999/06/24 19:05:00 kwoklin Exp $
% klee 04/01/99

if exist(getarchive) == 2   
  eval(getarchive)
else
  dodsmsg('Metadata not found!')
  return
end

url = []; infotext = []; text = []; Constraint = []; loaddodsbool = 1;
URLdepth = []; URLlat = []; URLlon = [];
yearname = deblank(DodsName1(1,:));
monthname = deblank(DodsName1(2,:));
dayname = deblank(DodsName1(3,:));

URLdepth = ['&',DepthName,'>=',num2str(passtimes(whichurl,5),7),'&',DepthName,'<=', num2str(passtimes(whichurl,6),7)];
URLlat = ['&',LatitudeName(1,:),'>=',num2str(passtimes(whichurl,7),4),...
          '&',LatitudeName(1,:),'<=',num2str(passtimes(whichurl,8),4)];
% for [-180, 180]  
URLlon = ['&',LongitudeName(1,:),'>=',num2str(passtimes(whichurl,9),4),...
          '&',LongitudeName(1,:),'<=',num2str(passtimes(whichurl,10),4)];
Constraint = [Constraint, URLdepth, URLlat, URLlon]; 

StartYear = passtimes(whichurl,1);
StartMonth = passtimes(whichurl,2); 
StartDay = passtimes(whichurl,3); EndDay = passtimes(whichurl,4);
%Constraint = [Constraint, '&',yearname,'=',num2str(StartYear),'&',monthname,'=',num2str(StartMonth),...
%              '&',dayname,'>=',num2str(StartDay), '&',dayname,'<=', num2str(EndDay)];
Constraint = [Constraint, '&',monthname,'=',num2str(StartMonth),...
              '&',dayname,'>=',num2str(StartDay), '&',dayname,'<=', num2str(EndDay)];

returned_var = [];
for i = 1:size(getvariablelist,1)
  returned_var = [returned_var, dods_dbk(getvariablelist(i,:))]; 
  if strcmp(deblank(getvariablelist(i,:)), 'sal')
    returned_var = [returned_var, sprintf('%s',',',deblank(OptionalVariables(4,:)))];
  end
  if i < size(getvariablelist,1)
    returned_var = [returned_var, ','];
  end
end
%returned_var = [returned_var, ',', deblank(OptionalVariables(1,:)), ',', deblank(OptionalVariables(2,:)),...
%                ',', deblank(OptionalVariables(3,:))];
url = [Server, '?', returned_var, Constraint];

tmpvar = ['?year_utc,month_utc,day_utc,depth,depth_w,dynh_0'];
tmptext = ['loaddods ''', Server, tmpvar, Constraint, ''''];

infotext = sprintf('%s\n%s\n%s\n%s\n%s\n%s\n','   ',...
                  ['This dataset contains other information not directly selectable with the matlab GUI, such as',...
                   'dynamic height (dynh_0) and bottom depth (depth_w). Complete descriptions of the available ',...
                   'variables can be seen by selecting "View Text" in the GUI main window.',...
                  '   ',...
                  'To retrieve this information, you can issue a ''loaddods'' command from the Matlab command line,',...
                  'using a constraint expression like this:',...
                  '  '],...
                  ['URL = ',Server], ...
                  ['Proj = ',tmpvar] ,...
                  ['Sel = ',Constraint], ...
                  ['   '],...
                  ['They will return a set of date, depth and dynamic height vectors corresponding to each other.']);

return

  

  

  
