function pth=read_pthtd(dfname,trunstart,ndts)

if nargin<2
  trunstart=0;
end

if nargin<3
  ndts=inf;
end

% open file

fid=fopen(dfname);

% strip .ind echo

for in=1:15
  fgetl(fid);
end

% get number of drifters

pth.ndrog=fscanf(fid,'%f\n',1);

% Strip another useless line

fgetl(fid);

% Get year and yearday of launch

pth.dstart=fscanf(fid,'%f',[5 pth.ndrog])';
pth.ystart=pth.dstart(:,4);
pth.dstart=pth.dstart(:,5);

% Strip 5 more useless lines

for in=1:6
fgetl(fid);
end

% Read time step

pth.tstp=fscanf(fid,'%f',[1 3])*[0;1;0]/86400;

% Read drogue lines

pthi=fscanf(fid,'%f',[4*pth.ndrog ndts]);
pth.ndts=size(pthi,2);

% Parse path

pth.x = reshape(pthi(1:4:length(pthi(:))),pth.ndrog,pth.ndts);
pth.y = reshape(pthi(2:4:length(pthi(:))),pth.ndrog,pth.ndts);
pth.z = reshape(pthi(3:4:length(pthi(:))),pth.ndrog,pth.ndts);
pth.t = trunstart+pthi(4:4*pth.ndrog:length(pthi(:)))/86400;

% Close path file

fclose(fid);
