function writeind(xdr,ydr,zdr,t,yr,fname)

% function writeind(xdr,ydr,zdr,t,yr,fname)

ndrft=length(xdr);

if nargin<6
  fname='DRIFTER.ind';
end

if nargin<5
  yr=clock*[1;0;0;0;0;0]*ones(ndrft,1);
elseif length(yr)==1
  yr=yr*ones(ndrft,1);
end

if mean(zdr)>0
  zdr=-zdr;
end

wtime=clock;
fid=fopen(fname,'w');
fprintf(fid,'Comment:\n');
fprintf(fid,'vpr data; file written: %s from writeind.m\n', ...
	datestr(datenum(now)));
fprintf(fid,' # of model dt"s btwn particle position updates\n',[]);
fprintf(fid,'1\n',[]);
fprintf(fid,' # of drog updates btwn drogue outputs\n',[]);
fprintf(fid,'%i\n',5);
fprintf(fid,' grid scaling factors in x,y directions\n',[]);
fprintf(fid,'1.0  1.0  1.0\n',[]);
fprintf(fid,' drog coordinate scaling factors\n',[]);
fprintf(fid,'1.0  1.0  1.0\n');
fprintf(fid,' Number of starting drogues (ndr)\n',[]);
fprintf(fid,'%i\n',ndrft);
fprintf(fid,' Starting Positions of Drogues\n',[]);
fprintf(fid,...
	'%10.1f %10.1f %7.2f %5i %10.5f\n',...
	[xdr(:) ydr(:) zdr(:) yr(:) t(:)]');
fclose(fid);

m=loadgrid('gbk1');
clf
plotbnd(m);
lcontour(m,m.z,[60 100]);
hold on
plot(xdr,ydr,'x');
axis tight;
