function windloop(V,W);
%
% program to make current vector movies
%
% (wind as well is optional)
%
% first, load the current and wind data into a matrix "V" and "W"
% using the "buildmat.m" routine
%
if nargin==0;
mint=input('Enter minimum yearday: ');
maxt=input('Enter maximum yearday: ');

cd /home2/ocn/jmanning/m
[V]=buildmat(mint,maxt);
%
w2=menu('Do you have another set of vectors (like wind stress)?','yes','no');
  if w2==2;
    cd /home2/ocn/jmanning/m
    [W]=buildmat(mint,maxt);
    end;
%
end;
%
% Now load the mooring position data
%
  load /home2/ocn/jmanning/gbr/posn.dat
  x=posn(:,3)';
  y=posn(:,2)';
%
% Now load the wind buoy position data
%
if nargin==2; w2=1; end;
%
 if w2==1;
  load /home2/ocn/jmanning/gbr/wind/latlon.dat
  wx=latlon(:,3)';
  wy=latlon(:,2)';
 end;
%
%  load the bathymetry data
%
load  /home2/ocn/jmanning/gbr/gscgrid.mtl
%
  lon=gscgrid(1:50,1)';
  lat=gscgrid(1:50:2500,2);
  z=reshape(gscgrid(:,3),50,50)';
%
% define contour levels
%
  cint=[60;200];
%
% create a 2-panel figure and store it in a movie
%
f2=figure(1);
set(gcf,'units','pixels');
set(gcf,'position',[0, 0, 200,200])
     ikk=[0];
%
% define movie array
%
clear fall85;
%
fall85=zeros(length(getframe(f2,[0, 0, 200,200])),50);
%
%
% Big "for loop" cycle through time (hours for example)
%
[rV,cV]=size(V);
%
 for im=1:1:50;
%
% define boundaries
%
     bound=[-69.5 -68 40 41.5];
%
% plot the current 
%
   u=V(im,1:2:cV-1);
   v=V(im,2:2:cV);
   arrow(x,y,u,v,5,-1,1,bound)
%
% plot the wind stress if asked for
%
 if w2==1;
   wsu=W(im,1);
   wsv=W(im,2);
   arrow(wx,wy,wsu,wsv,.5,-2,0,bound)
 end;
%
     hold on
%
% put in bathymetry 
%
     cl=contour(lon,lat,z,cint);
%
%    label the month
%
     intx=(bound(2)-bound(1))/20.;
     inty=(bound(4)-bound(3))/10.;
     text(bound(1)+intx,bound(3)+inty,int2str(im));
%
%
% save this to movie
%
   fall85(:,im)=getframe(f2,[0,0,200,200]);
        clg
%
 end
%
save fall85.mat fall85
%
clg
axis('off');
set(gcf,'position',[100, 100, 400,400])
movie(fall85,2);
%
%cd /home2/ocn/jmanning/drivem

