function [bcsetlist] = readELCOMbc_datFile(filename) % function [bcsetlist] = readELCOMbc_datFile(filename) % % funcion to get bc name from a bc.dat file % output bcsetlist can be used in plotELCOMinputDir % Inputs: % filename : filename string % Outputs % bcsetlist : =structure giving bcset_no and bc_name % eg: bcsetlist.bcset_no = [1 2] % eg: bcsetlist.bc_name = [{'River A'},{'Dam Wall Outflow'} ] % % Uses: % line2strs.m % % Written by C. Dallimore 27 July 04 % % Open file fileno = fopen(filename); if (fileno == -1) disp('ERROR in readELCOMbcfile file not found'); bcsetlist = []; return end % rewind file to start frewind(fileno) % read comment lines comment = 1; eof = 0; i=0; while (~eof) tmp_str=fgetl(fileno); if ischar(tmp_str) & ~(strcmp(tmp_str,'EOF')) % Check for comment lines if (tmp_str(1) ~= '!') % Check for new bc set if (any(isletter(tmp_str))) n = 0; i = i+1; str_arr = line2strs(tmp_str); bcset_no(i) = str2num(str_arr{1}); tmp_str2 = str_arr{3}; tmp_str2(findstr(tmp_str2,'_'))=' '; bc_name(i) = cellstr(tmp_str2); end end else eof = 1; end end bcsetlist.bcset_no = bcset_no; bcsetlist.bc_name = bc_name;