function out = readcmstel(telfile)
% out = read_cmstel(telfile)
% Reads a CMS telescoping grid file
% and output all variables to a structure array
% written by Alex Sanchez, USACE
fid = fopen(telfile,'r');
fgets(fid); %Skip header line
data=fscanf(fid,'%f %f %f %d',4);
out.ncells = data(4);
out.x0 = data(2);
out.y0 = data(3);
out.angle = data(1);
data=fscanf(fid,'%d %f %f %f %f %d %d %d %d %d %d %d %d %f',[14,out.ncells])';
fclose(fid);
out.id = data(:,1);
out.x = data(:,2);
out.y = data(:,3);
out.dx = data(:,4);
out.dy = data(:,5);
out.iloc = data(:,6:13);
out.depth = data(:,14);
return