function movie02
%
%   The function movie02 reads a lot of floats and tcolor,
%   on the pre-existing figure.  The beginning of the data 
%   (launching position is defined by a 'o', each data point is 
%   shown with '.', and every 'step' days with a cross.
%
%-------------------------------------------------------------------
%   Written by Vassilis Zervakis, in February 1996, while at
%              AINCO - Interocean, Madrid, Spain.
%   Modified by Mike Sparrow in October '97.
%-------------------------------------------------------------------
%
global moviefigure
global lonmin lonmax latmin latmax
global taillength trailshow trailcolor seacolor
global firstday firstmonth firstyear
global lastday lastmonth lastyear
global h1 h9 tjump
%
taillength=taillength*tjump;
%
% ------Load floats---------------------------
starter = dmy2rd( firstday, firstmonth, firstyear);
ender   = dmy2rd(  lastday,  lastmonth,  lastyear);
%  Calculate the rows of Matrices X and Y------------
rows = ender - starter + 1;
%--Initialize the X, Y matrices --------------------------
X = [];
Y = [];
ans = 1;
numfloats = 0;
while ans == 1,
   [float, number, timer, temp, pres, lat, lon, u, v, www] = rfcread1;
   numfloats = numfloats + 1
   NN = length(lat);
   clear number;
   clear temp;
   clear pres;
   clear u;
   clear v;
   clear wwww;
%--Initialize the X, Y matrices --------------------------
   Zplus = zeros(rows,1);
   Zplus = Zplus + 999.;
   X = [ X Zplus ];
   Y = [ Y Zplus ];
   n1 = size(X) ;
%  --Check if float data within the time limits ------
   if (timer(NN) <= starter) | (timer(1) >= ender),
     mbox('OK','Data out of time range',' Select other float ' )
     ans = 1;
   elseif (min(lat)>latmax)|(max(lat)<latmin)|(min(lon)>lonmax)|(max(lon)<lonmin),
%  --if float data within the space limits ------
     mbox('OK','Data out of space limits',' Select other float ' );
     ans = 1;
   else
%  ---Find the first data that correspond to the time starter-----
%  ---if the float data begin BEFORE the the time starter-----
      k = 1;
      if timer(1) < starter,
        while timer(k) < starter, 
          k = k + 1;
        end
        k1 = k 
%  ---Load the X, Y matrices with data from the floats -------
        l = 1;
        while (l <= rows) & (k <= NN),
          X(l,numfloats) = lon(k);
          Y(l,numfloats) = lat(k);      
          l = l+1;
          k = k+1;
        end
%  ---Find the first data that correspond to the time starter-----
%  ---if the float data begin AFTER the the time starter-----
      k = 1;
      elseif round(timer(1)) >= round(starter),
        st = round(starter);
        point2 = 1
        while k < rows,
          if round(timer(1))==st,
            k1 = k;
            k = rows;
            point2 = 2
          else
            k = k + 1;
            st = st + 1;
          end
        end
%  ---Load the X, Y matrices with data from the floats -------
        point2 = 3
        k = k1;
        l = 1;
        while (k <= rows) & (l <= NN),
          X(k,numfloats) = lon(l);      
          Y(k,numfloats) = lat(l);      
          l = l+1;
          k = k+1;
        end
      end
      charanswer = mbox('YESNO','Load data from another float?');
      ans = strcmp(charanswer,'YES');
      if ans == 0,
        figure(moviefigure);
        if (trailshow == 'no '),
           trailcolor = seacolor ;
         else 
           trailcolor = 'g' ;
        end
        replay = 'yes' ;
        kk = 0;
        while (replay == 'yes') & (kk < 5),
          kk = kk + 1 ;
          hold on ;
          global X1 Y1
          X1 = X;
          Y1 = Y;
          cometall(X,Y,taillength,trailcolor);
          hold off;
        end
        set(h1,'Enable','on',...
               'Callback',['global X1 Y1 trailcolor taillength,',...
               'cometall(X1,Y1,taillength,trailcolor)']) ;
  	set(h9,'Enable','on',...
               'Callback',['global X1 Y1,',...
                           'disper01(X1,Y1)']) ;
      end
   end
end
