function gvector 
% direct derivation from webvectt.m (JH 00/10/09; EF) -- much abbreviated
% especially important for topog. and for temp. mapping.

global XYDATA
global UVDATA
global VECFIG

if isempty(VECFIG.ii)
   msg = sprintf('\nNo data <Selection Cancelled?>\n\nClose & select.');
   noticeOK(msg)
   return
end

set(gcf, 'DefaultAxesFontSize', 12, ...
           'DefaultTextFontSize', 12, ...
           'Color', [1 1 1]);
if VECFIG.bold, set(gcf, 'DefaultAxesFontWeight','bold'); end;
orient tall

latrange = VECFIG.latrange; 
lonrange = VECFIG.lonrange;
max_llr = max(diff(lonrange), diff(latrange));
biglonrange=lonrange + [-1 1]; 
biglatrange=latrange + [-1 1];

%where the legend goes
xykey = [lonrange(1)+.05*diff(lonrange)  latrange(1)+diff(latrange)*.1];

if VECFIG.basinresolution == 1 
%       biglatrange(1) = max(biglatrange(1),-72);  %ss limitations in topography
%       biglatrange(2) = min(biglatrange(2),72);
   % use smith-sandwell if whole section is inside +/- 70deg
   if (max(abs(biglatrange))<70) & exist('ss_block'), 
      if max_llr  > 15, nsub = 9;
      elseif max_llr  > 5, nsub = 3;
      else nsub = 1;
      end     
      eval('[top_lon, top_lat, topog]= ss_block(biglonrange, biglatrange, nsub);')
      % eval is used to hide ss_block from the compiler--otherwise an
      % error will result even if this block of code is never executed.
      [top_lat, top_lon, topog] = decimate_topo(top_lat, top_lon, topog, 60); 
      % establish border longs. to match with figure's beg. & end longs.    
      [topog top_lon] = m_fixlon(top_lon, top_lat, topog, VECFIG.lonrange);
   else
      msg = sprintf('\n   Smith Sandwell\n\nNot in range or unavailable.\n\nUsing Tbase (or m_elev).');
      notice(msg, 3);
      VECFIG.basinresolution = 2;
   end 
end
                     
if VECFIG.basinresolution == 2     % use Tbase: medium res.
   if exist('m_tbase')
      disp('Trying m_tbase')
      eval('[topog, top_lon, top_lat]=m_tbase([ biglonrange  biglatrange]);','VECFIG.basinresolution = 3;');
      % above eval as error: try -catch configuration
   else
      msg = sprintf('\nTbase file unavailable.\nUsing m_elev (default).');
      notice(msg, 3);
      VECFIG.basinresolution = 3;
   end
end

if VECFIG.basinresolution == 3  % default, coarse resolution
   disp('Using m_elev')
   [topog, top_lon, top_lat]=m_elev([ biglonrange  biglatrange]);
   % establish border longs. to match with figure's beg. & end longs.    
   top_lon = top_lon(1,:);
   top_lat = top_lat(:,1)';
   [topog top_lon] = m_fixlon(top_lon, top_lat, topog, VECFIG.lonrange);
end

topo_clev = [-6000:500:500];  % Topography contour levels.
if VECFIG.blkwht
   topo_cmap = topograys(topo_clev); 
   temperature_cmap = colormap('gray'); % but, hopefully using 'k'
else  % color
   topo_cmap = topocolors(topo_clev);
   temperature_cmap = jet(64);
end
topo_irange =  [1 size(topo_cmap,1)]; % indices into topo_cmap
colormap([topo_cmap ; temperature_cmap]);

% Temperature color indexing.  
TT = VECFIG.TT;
if VECFIG.usecdata
   if VECFIG.radioscale ==1     % scale > 1=whole cruise; 2=plot; 3=custom
      mintt = floor(min(TT));
      maxtt = ceil(max(TT));
      if maxtt - mintt < 2.0, maxtt = mintt + 2.0; end  % min to plot, with salinity chk.
      if maxtt < 1.0, maxtt = 1.0; end 
   elseif VECFIG.radioscale == 2
      subTT = TT(VECFIG.ii);
      mintt = floor(min(subTT));
      maxtt = ceil(max(subTT));
      if maxtt - mintt < 2.0, maxtt = mintt + 2.0; end  % min to plot, with salinity chk.
      if maxtt < 1.0, maxtt = 1.0; end 
   else
      mintt = VECFIG.cdata_mm(1);
      maxtt = VECFIG.cdata_mm(2);
      subTT = TT(VECFIG.ii);
      submintt = min(subTT);  
      submaxtt = max(subTT);  
      if submintt < mintt | submaxtt > maxtt
         xx = gcf;  
         close(xx)
         msg =  sprintf('\n\tWarning!\n\nCustomized temperature limits           \ndo Not encompass temp. range.');
         noticeOK(msg)
         return
      end
   end
   trange=[mintt maxtt];
end

irange = [1 64];
irange = irange + size(topo_cmap, 1);  % makes indices into temperature_cmap
   
badT =  ((mean(TT) < -98) | any(isnan(TT)));  % -99 is missing T (ascii)
if size(VECFIG.TT) == size(VECFIG.mv_color), badT = 1; end;
trouble = 0;
if (badT)
   iT = VECFIG.mv_color;
   mapstyle = 'scaled';
else
   eval('iT = c_index(TT(VECFIG.ii), trange, irange, NaN);', 'trouble = 1;')
   if trouble == 1
      marks = findstr(VECFIG.mv_cdatafile,'/');
      shortname = VECFIG.mv_cdatafile(marks(end-2):end);
      okstr = sprintf('\nTemperature file error. \n\nEdit: %s\n\nMatrix indexing error', shortname); 
      noticeOK(okstr)
      return
   end
   mapstyle = 'direct';  %'direct';  %'scaled'; %  ???
end

eval(VECFIG.m_proj_str);

%% EF: we add some extreme values to topo_clev for contouring
%   so that the clipping in cf_index can work; anything
%   outside the topo_clev range now gets mapped to the extreme
%   values of the range.
if VECFIG.basintype == 1
   [cmat, htopo] = m_contourf(top_lon,top_lat,topog, ...
      [-100000 topo_clev 100000]);
   set(htopo, 'EdgeColor', 'none');
   cf_index(htopo, topo_clev, topo_irange);
elseif  VECFIG.basintype == 2
   if VECFIG.usecdata == 0   % uniform arrow color
      colormap(topo_cmap);
      [cmat, htopo] = m_contour(top_lon,top_lat,topog, ...
         [-100000 topo_clev 100000]);
   else
      [cmat, htopo] = m_contour(top_lon,top_lat,topog, ...
         [-100000 topo_clev 100000]);
      cf_index(htopo, topo_clev, topo_irange);
   end
end  % do nothing, if VECFIG.basintype == 3 (no contours / lines)

eval(VECFIG.m_coast_str);
if VECFIG.blkwht,  m_coast('patch',[0.4 .4 .4]); end;
eval(VECFIG.m_grid_str);
hold on

if VECFIG.vec_scale ~= 0
	[hvp] = m_vec_ell2(VECFIG.vec_scale, XYDATA.X, XYDATA.Y, UVDATA.UU, UVDATA.VV, iT, ...
      'headlength',   VECFIG.mv_headlength, ...
		'shaftwidth',   VECFIG.mv_shaftwidth, ...
      'centered',      VECFIG.mv_centered, ...
		'headangle',    VECFIG.mv_headangle, ...
		'headwidth',    VECFIG.mv_headwidth, ...
		'EdgeColor',    VECFIG.mv_edgecolor, ...
      'CDataMapping', mapstyle);
   %       'centered',      VECFIG.mv_centered, ...  doesn't work?!
else
   radii = ones(length(XYDATA.X),1);   %plot as circles, not arrows
   radii = radii * str2num(VECFIG.circlescale);
   [hvp] = m_vec_ell(250, XYDATA.X, XYDATA.Y, 'circles', radii, ... 
       'centered', 1, ...
       'colors', iT, ...
       'EdgeColor',    VECFIG.mv_edgecolor, ...
       'CDataMapping', mapstyle);
end

if VECFIG.mv_supplementary == 1 & ~isempty(VECFIG.mv_suppdatafile)
   found = 1;
   eval('supps = load(VECFIG.mv_suppdatafile);','found = 0;')
   if found
      %supps = read_asc(VECFIG.mv_suppdatafile);
      % this will need revision depending upon final file structure
      lons = supps(:,4);
      lats = supps(:,5);
%       lon = supps(:,4); % custom for glottest.txt (ka0006)
%       lonmin = supps(:,5);
%       lons = lon + lonmin/60.0 + 140.0; 
%       lat = supps(:,6);
%       latmin = supps(:,7);
%       lats = lat + latmin/60.0 - 17.0;
      %
      radii = ones(length(lons),1);   %plot as circles, supplementary data only
      radii = radii * str2num(VECFIG.circlescalesupp);
      [hvp2] = m_vec_ell(250, lons, lats, 'circles', radii, ...
         'centered', 1, ...
         'colors', VECFIG.mv_colorsupp, ...
         'EdgeColor',    VECFIG.mv_edgecolorsupp, ...
         'CDataMapping', mapstyle);
   else
      notice('   Supplemental file not found.', 2);
   end
end

if VECFIG.blkwht
   [hkp,hkt] = m_vec(VECFIG.vec_scale, xykey(1), xykey(2), 0.5, 0, 'k',...
      'key',' 50 cm/s', 'headlength',VECFIG.mv_headlength,...
      'shaftwidth',VECFIG.mv_shaftwidth,'EdgeColor','k');
   set(hkt,'FontSize',10,'color','k');
else
   [hkp,hkt] = m_vec(VECFIG.vec_scale, xykey(1), xykey(2), 0.5, 0, 'm',...
      'key',' 50 cm/s', 'headlength',VECFIG.mv_headlength,...
      'shaftwidth',VECFIG.mv_shaftwidth,'EdgeColor','k');
   set(hkt,'FontSize',10,'color','m');
end

if VECFIG.basintype < 3  % skip color bar if  no contours / lines
   h_dcb = dcolbar( topo_clev/1000, 'vert', 'Depth (km)');
   h_dcbp = findobj(h_dcb,'Type','patch');
   cf_index(h_dcbp, topo_clev/1000, topo_irange);
end

if ~VECFIG.skiptitle, title(VECFIG.title); end;
if ~badT & mintt < 33 & maxtt >= 1.0 % weak screening for salinity data, etc.
   ind_cbar( trange, irange, 'horiz', 'SST (^{o}C)');
   if VECFIG.basintype < 3, center_cbar(h_dcb); end;
end

if VECFIG.webplot
   old_axes = gca;
   aa = axes('position', [0 0 1 1]);
   axis('off')
   ht = text(0.5, 0.005, 'Preliminary processing at Univ. of Hawaii',...
      'units', 'normalized',...
      'VerticalAlignment', 'bottom',...
      'HorizontalAlignment' , 'center');
   set(ht, 'Interpreter', 'none') 
   axes(old_axes);
end



