function oct_test_forcing(frcname,grdname,thefield,thetime,skip,coastfileplot)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Plot a variable from the forcing file 
% 
%  Further Information:  
%  http://www.croco-ocean.org
%  
%  This file is part of CROCOTOOLS
%
%  CROCOTOOLS is free software; you can redistribute it and/or modify
%  it under the terms of the GNU General Public License as published
%  by the Free Software Foundation; either version 2 of the License,
%  or (at your option) any later version.
%
%  CROCOTOOLS is distributed in the hope that it will be useful, but
%  WITHOUT ANY WARRANTY; without even the implied warranty of
%  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%  GNU General Public License for more details.
%
%  You should have received a copy of the GNU General Public License
%  along with this program; if not, write to the Free Software
%  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
%  MA  02111-1307  USA
%
%  Copyright (c) 2002-2006 by Pierrick Penven 
%  e-mail:Pierrick.Penven@ird.fr  
%
%  Updated    31-Aug-2006 by Pierrick Penven
%  Updated    25-Oct-2006 by Pierrick Penven (uwnd and vwnd)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
isoctave=exist('octave_config_info');
niceplot=1;
i=0;
for time=thetime
  i=i+1;
  
  subplot(2,length(thetime)/2,i)

  ncid = netcdf.open(frcname, 'NC_NOWRITE');
  stime=netcdf.getVar(ncid, netcdf.inqVarID(ncid, 'sms_time'));
  if isempty(stime)
    stime=netcdf.getVar(ncid, netcdf.inqVarID(ncid, 'bulk_time'));
    if isempty(stime)
      error('TEST_FORCING: Is it a forcing or a bulk file ?')
    end
    u=squeeze(netcdf.getVar(ncid, netcdf.inqVarID(ncid, 'uwnd')));
    v=squeeze(netcdf.getVar(ncid, netcdf.inqVarID(ncid, 'vwnd')));
    if thefield(1:3)=='spd'
      field=sqrt((oct_u2rho_2d(u)).^2+(oct_v2rho_2d(v)).^2);
      fieldname='wind speed';
      units='m/s';
    else
      field=netcdf.getVar(ncid, netcdf.inqVarID(ncid, thefield));
      fieldname=netcdf.getAtt(ncid, netcdf.inqVarID(ncid, thefield), 'long_name');
      units=netcdf.getAtt(ncid, netcdf.inqVarID(ncid, thefield), 'units');
    end
  else  
    u=squeeze(netcdf.getVar(ncid, netcdf.inqVarID(ncid, 'sustr')));
    v=squeeze(netcdf.getVar(ncid, netcdf.inqVarID(ncid, 'svstr')));
    if thefield(1:3)=='spd'
      field=sqrt((oct_u2rho_2d(u)).^2+(oct_v2rho_2d(v)).^2);
      fieldname='wind stress';
      units='N/m^2';
    else
      field=netcdf.getVar(ncid, netcdf.inqVarID(ncid, thefield));
      fieldname=netcdf.getAtt(ncid, netcdf.inqVarID(ncid, thefield), 'long_name');
      units=netcdf.getAtt(ncid, netcdf.inqVarID(ncid, thefield), 'units');
    end
  end
  netcdf.close(ncid);
%
% Read the grid
%
ncid = netcdf.open(grdname, 'NC_NOWRITE');
  if strcmp(thefield,'sustr') | strcmp(thefield,'uwnd')
    lon=netcdf.getVar(ncid, netcdf.inqVarID(ncid, 'lon_u'));
    lat=netcdf.getVar(ncid, netcdf.inqVarID(ncid, 'lat_u'));
    mask=netcdf.getVar(ncid, netcdf.inqVarID(ncid, 'mask_u'));
  elseif strcmp(thefield,'svstr') | strcmp(thefield,'vwnd')
    lon=netcdf.getVar(ncid, netcdf.inqVarID(ncid, 'lon_v'));
    lat=netcdf.getVar(ncid, netcdf.inqVarID(ncid, 'lat_v'));
    mask=netcdf.getVar(ncid, netcdf.inqVarID(ncid, 'mask_v'));
  else
    lon=netcdf.getVar(ncid, netcdf.inqVarID(ncid, 'lon_rho'));
    lat=netcdf.getVar(ncid, netcdf.inqVarID(ncid, 'lat_rho'));
    mask=netcdf.getVar(ncid, netcdf.inqVarID(ncid, 'mask_rho'));
  end
  angle=netcdf.getVar(ncid, netcdf.inqVarID(ncid, 'angle'));
  netcdf.close(ncid);
  mask(mask==0)=NaN;
%
% compute the vectors
% 
  [ured,vred,lonred,latred,speed]=oct_uv_vec2rho(u,v,lon,lat,angle,...
                                             mask,skip,[0 0 0 0]);
%
% Make the plot
%  
if (isoctave);
    aux_plot=mask.*squeeze(field);
    aux_field=flipud(aux_plot);
    imagesc(aux_field)
    colorbar
    try 
       title([fieldname',' - day: ',num2str(stime)])
    catch
       title([fieldname,' - day: ',num2str(stime)])
    end
else
  if niceplot==1
    domaxis=[min(min(lon)) max(max(lon)) min(min(lat)) max(max(lat))];
    m_proj('mercator',...
       'lon',[domaxis(1) domaxis(2)],...
       'lat',[domaxis(3) domaxis(4)]);

    m_pcolor(lon,lat,mask.*field);
    shading flat
    drawnow
    hc=colorbar;
    set(get(hc,'label'),'string',units);
    hold on
    m_quiver(lonred,latred,ured,vred,'k');
    if ~isempty(coastfileplot)
      m_usercoast(coastfileplot,'patch',[.9 .9 .9]);
    end
    hold off
    title([fieldname,' - day: ',num2str(stime)])
    m_grid('box','fancy',...
           'xtick',5,'ytick',5,'tickdir','out',...
           'fontsize',7);
  else
    imagesc(mask.*field)
    title([fieldname,' - day: ',num2str(stime)])
  end
end
end

