clc;
fid = fopen('FAR.DATA','r');
model.datafile = textscan(fid, '%s','Delimiter','');
fclose(fid);
model.datafile = model.datafile{:};
DATA = model.datafile;
% Find COMPDAT line
La = ~ cellfun(@isempty, strfind(DATA,'WELSPECS','ForceCelloutput',true));
Lia = ~ cellfun(@isempty, strfind(DATA,'COMPDAT','ForceCelloutput',true));
Welspecs = model.WELSPECS; %%The Number of WELSPECS and COMPDAT and WCONPROD
in which the parameters are changed.* _
Compdat = model.COMPDAT;
mm = model.CompletionNodes;
LNCOMPDAT=find(Lia); % Line number of COMPDAT
LNWELSPECS=find(La); % Line number of WELSPECS
% Next line after COMPDAT is Well Completion DATA — LN+1 % Spliting The line of Data for ii = 1:size(Welspecs,1) % In this loop the line of WELSPECS and COMPDAT is conveted to cell array
for jj =1:Welspecs(ii,2)
splitSt{jj,ii} = regexp(cell2mat(DATA(LNWELSPECS(Welspecs(ii,1))+jj)),'\ ','split');
end
for jj=1:Compdat(ii,2)
splitStr{jj,ii} = regexp(cell2mat(DATA(LNCOMPDAT(Compdat(ii,1))+jj)),'\ ','split');
end
end