function [pid, vect] = readVectorFile(fname)
% function [pid, vect] = readVectorFile(fname)
%
% read any NADCON5 vector file; return list of PIDS
% and corresponding lat/lon, azimuth, and length of vectors
% in file
%
% INPUT
% fname name of file, with *.in format
%
% OUTPUT
% pid    name of point (PID)
% vect   dimensions (#PID x 4)
%         1-2 lat/long (deg)
%         3   azimuth (deg)
%         4   vector length (m)

% textread may be removed on future versions of Matlab, 
% which would require converting this to 'textscan' OR
% turning back on the slow method (below)
[lat,lon,az,m,pid] = textread(fname,...
                        '%f %f %f %*f %*f %f %6s');
vect = [lat lon az m];

% % --------------------------------------
% % old method, very very slow
% 
% % open file
% fid=fopen(fname,'r');
% if fid<1
%     error(sprintf('cannot open file %s',fname));
% end
% 
% % process each line, store grid
% ln = fgetl(fid);
% if ln==-1
%     warning(sprintf('no data in file %s',fname));
%     pid=[]; vect=[];
% end
% i = 1;
% while ischar(ln)
%     % parse line
%     lat = str2num(strtrim(ln(1:16)));
%     lon = str2num(strtrim(ln(17:32)));
%     az = str2num(strtrim(ln(33:39)));
%     m = str2num(strtrim(ln(63:72)));
%     vect(i,:) = [lat lon az m];
%     
%     pid{i,1} = strtrim(ln(73:end));
%     
%     % get next line; increment line counter
%     ln = fgetl(fid); 
%     i = i+1;
% end
% fclose(fid);
return
