view operator_def/read_stencil.m @ 825:32c360bb480e feature/operator_files

Add test and fix typo
author Ylva Rydin <ylva.rydin@telia.com>
date Mon, 10 Sep 2018 17:42:30 +0200
parents 95c26000c0ba
children
line wrap: on
line source

function [stencil_variables] = read_stencil(stencil)
fileID = fopen(stencil,'r');
line = fgetl(fileID);



while ~feof(fileID)
    if isempty(line)
    elseif strcmp(line(1),'#')
    else
        varname = genvarname(line);
        val = [];
        line = fgetl(fileID);
        while ~isempty(str2num(line))
            val = [val; str2num(line)];
            line = fgets(fileID);
            if line == -1
                break
            end
        end
     stencil_variables.(varname) = val;
    end
    line = fgetl(fileID);  
end

end