function han = roms_plot_winds(frc_file,var,day,grd_file)
% roms_plot_winds(frc_file,var,day,grd_file)
%
% plot the surface fluxes (wind,heat etc) from a ROMS forcing nc file, using
% the data nearest to the requested day
%
% Input 'var' can be any valid surface flux variable in the netcdf file
% If var = 'wind' a vector plot is made of the wind stress components
%
% John Wilkin

nc = netcdf(frc_file);

if isempty(day)
  sms_time = nc{'sms_time'}(:);
  disp(['sms_time values are in the range ' mat2str(range(sms_time))])
  disp(['apparent time interval is ' num2str(diff(sms_time(1:2))) ' day'])
  return
end

sms_time = nc{'sms_time'}(:);
tmp = abs(day-sms_time(:));
tindex = min(find(tmp==min(tmp)));

grd = get_roms_grid(grd_file);
lon = grd.lon_rho;
lat = grd.lat_rho;
mask = grd.mask_rho_nan;

j = tindex;
switch var
  case 'wind'
    sustr = nc{'sustr'}(tindex,:,:);
    svstr = nc{'svstr'}(tindex,:,:);
    u = sustr.*grd.mask_u;
    v = svstr.*grd.mask_v;
    roms_quiver(lon,lat,u,v,grd.angle,2,0)
  otherwise
    data = nc{var}(tindex,:,:);
    pcolorjw(lon,lat,data.*mask);      
end

day_str = [' day ' num2str(sms_time(j))];
title([var ': ' day_str])

plotnzb(0,'k');axiseauc


