disp(['read_MFS']);
% Opens Channel #1 , which is the SDM protocol from the Licor 7500
% Inputs data from ASCII data files
    ncol=8;
z=NaN+zeros(ncol,36000); % flicor=10Hz -->864000 samples
fclose('all');
z=[];
for jam=00:23
    hr=sprintf('%02i',jam);
    jd=sprintf('%03i',ddd);

    dfx=[jd hr];

    dfl=[way_raw_data_flux, yyyy(3:4),jd,'\', 'mfs0' yyyy(3:4) jd hr '_raw.txt'];
    disp(dfl);

    flist=fopen(dfl,'r');
    temp=[];

    if flist>0


       while feof(flist)==0,  
           try                   
                temp=textscan(flist,'%2f%2f%3f %f %f %f %f %*3c','headerlines', 1, 'emptyvalue', NaN);%         
               temp{1,length(temp)+1}=jam*ones(length(temp{1}),1);
               z=[z cell2mat(temp)'];
           catch
%                  for ll=1:ncol
%                      [l8,c8]=size(temp{1,ncol});
%                      if length(temp{1,ll})~=l8
%                          temp{1,ll}(l8+1)=[];
%                      end;
%                  end;
%                  if ~isempty(temp{1,1})
%                      z=[z cell2mat(temp)'];
%                  end;
            end;     
       end;    
       fclose(flist); 
       z(:,any(isnan(z),1))=[];
    end;

end;
    
tMFS= z(1,:)*60+z(2,:)+z(3,:)/1000; %time in s
jdMFS=single(ddd + (z(end,:)+ tMFS/3600)/24);
MFSpress=single(z(4,:));  %psi
MFStemp=single(z(5,:));  %degC
MFSvolflow=single(z(6,:));  %lpm
MFSmassflow=single(z(7,:));  %slpm
MFSmassflow_setpt=single(NaN*z(8,:));  %slpm

clear z %temp
   