function [nlines,ndepths,desc,p,t,s,pt,r0,r1,bv,t0,t1,s0,s1,o2,par,tr,fl]=readctd(filename)
%  read a ctd ascii file and return 
% number of data lines, number of depths,
% descriptive strings for variables, 
% pressure (p), temperature (t), salinity (s), potential temperature (pt), 
% potdens0 (r0), potdens1 (r1), buoyancy frequency (bv), 
%  temp0 (t0), temp1 (t1), sal0 (s0), sal1 (s1), oxygen (o2), 
%  PAR (par), transmissivity (tr), fluorescense (fl).
%  all variables are column vectors.
%
%           get header information
fid=fopen(filename,'r');
a=fgetl(fid);
nlines=sscanf(a,'%d',1);

for i=1:nlines
   a=fgetl(fid);
   desc(i)={a};
end
status=fclose(fid);

data=textread(filename,'','headerlines',nlines+1);

[ndepths,n]=size(data);

p=data(:,1);
t=data(:,2);
s=data(:,3);
pt=data(:,4);
r0=data(:,5);
r1=data(:,6);
bv=data(:,7);
t0=data(:,8);
t1=data(:,9);
s0=data(:,10);
s1=data(:,11);
o2=data(:,12);
par=data(:,13);
tr=data(:,14);
fl=data(:,15);

%clear data
