%
%      if no arguments are given the routine will
%         try to load info from standard input files

if nargin==0;

%  load observed drifter data
  wtd=menu('Which Data type?','hand entered','GPS processed');
  if wtd==1;
    disp('**********  HARDCODED to hand entered format');
    load /data5/jmanning/drift/al7813/d17.dat
    od=d17;

%   convert to decimal deg
    ilat=41;
    ilon=69;
    lon=(-1)*(ilon+od(:,4)/60);
    lat=ilat+od(:,3)/60;

%   convert time to yearday
    lgth=ones(length(lat),1);
    mth=lgth*11;
    yr=lgth*78;
    yd=julian(mth,od(:,1),yr,od(:,2));
   
%   other data type
  elseif wtd==2;
%   generate yd using "prepdrift.m" routine
    sn=input('enter last digit of drifter sn#: ','s');
    dl=input('enter letter of drifter deployment: ','s');
%   cc=input('enter cruise code (9507)');
    cc='9507';


%   assuming fixtime  problem has been fixed
    ete=exist(['/data4/jmanning/drift/sj',cc,'/p',sn,dl,cc,'et.mat']);
    path(path,'/home3/ocn/jmanning/gbs95/drift/mfiles');
    if ete==0;
       disp('WARNING: fixtime may need running')
%      fixtime(['p',sn,dl,cc,'e'],5,[4 6]);
    end;
 
    eval(['load /data4/jmanning/drift/sj',cc,'/p',sn,dl,cc,'et.mat -ascii']);
    eval(['d= p',sn,dl,cc,'et;']);

%   convert time to yearday
    mth=rem(floor(d(:,2)/1000000)*1000000,9500000000)/1000000;
    day=rem(floor(d(:,2)/10000)*10000,floor(d(:,2)/1000000)*1000000)/10000;
    hrmn=rem(d(:,2),floor(d(:,2)/10000)*10000);
    k=0;

%   initialize dyd

    dyd(1)=julian(mth(1),day(1),95,hrmn(1));
    for i=2:length(d);
      k=k+1;
      dyd(k)=julian(mth(i),day(i),95,hrmn(i));
      dd(k)=d(i,5);
      if dd(k)<-20;
        dd(k)=99.0;
      end;
      dlat(k)=d(i,3);
      dlon(k)=d(i,4);
% flag bogus dates or when time interval > 15 minutes
      if dyd(k)<=dyd(k-1)|(dyd(k)-dyd(k-1))>(15/(24*60));
        disp(['bogus data at day= ',num2str(day(i)),' hour= ',num2str(hrmn(i))])
        k=k-1;
      end;
    end;
  end;

% data in now loaded
  yy=[yd lat lon]; 
  disp('save "yy" data? if not just return');
  keyboard
end;
