cd ~dmenemen/llc_2160/regions/latlon/drift
load global_v3/Release
N=length(Release.Lon);
for t=Release.Tme
    flat=['global/DriftLat_n4331_dt3600_' datestr(t,30)];
    flon=['global/DriftLon_n4331_dt3600_' datestr(t,30)];
    if exist(flat)
        D=dir(flon);
        Lon=readbin(flon,[N D.bytes/4/N]);
        Lat=readbin(flat,[N D.bytes/4/N]);
        if length(find(Lon==0))>0 | length(find(Lat==0))>0 | ...
                length(find(isnan(Lon)))>0 | length(find(isnan(Lat)))>0
            disp([datestr(t) ' ' ...
                  int2str(length(find(isnan(Lon)))) ' ' ...
                  int2str(length(find(isnan(Lat)))) ' ' ...
                  int2str(length(find(Lon==0))) ' ' ...
                  int2str(length(find(Lat==0))) ' ' ...
                  int2str(length(find(Lon==0&Lat==0)))])
        end
    else
        break
    end
end

for t=Release.Tme
    flat=['global/DriftLat_n4331_dt3600_' datestr(t,30)];
    flon=['global/DriftLon_n4331_dt3600_' datestr(t,30)];
    if exist(flat)
        D=dir(flon);
        if D.bytes ~= 151775564
            disp(flon)
        end
        D=dir(flat);
        if D.bytes ~= 151775564
            disp(flat)
        end
    end
end

%%%%%%%%%%%
cd ~dmenemen/llc_2160/regions/latlon/drift
load global_v3/Release
N=length(Release.Lon);
t=Release.Tme(end);
tme=t:(1/24):(t+DriftLength);
flat=['global/DriftLat_n4331_dt3600_' datestr(t,30)];
flon=['global/DriftLon_n4331_dt3600_' datestr(t,30)];
D=dir(flon);
Lon=readbin(flon,[N D.bytes/4/N]);
Lat=readbin(flat,[N D.bytes/4/N]);
it=1:length(Lon);
clf,subplot(211),plot(tme(it),Lon(1,it),tme(it),Lat(1,it))
axis([tme(1) tme(it(end)) -25 150]), datetick('keeplimits')
subplot(212),plot(Lon(1,it)),hold on,plot(Lat(1,it))
axis([it(1) it(end) -25 150])

datestr(tme(4365))
