Raw File
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This file is part of NS2DDV.                                                      %
%                                                                                   %
% Copyright(C) 2011-2018    C. Calgaro  (caterina.calgaro@math.univ-lille1.fr)      %
%                           E. Creusé   (emmanuel.creuse@math.univ-lille1.fr)       %
%                           T. Goudon   (thierry.goudon@inria.fr)                   %
%                           A. Mouton   (alexandre.mouton@math.univ-lille1.fr)      %
%                                                                                   %
% NS2DDV is free software: you can redistribute it and/or modify it under the terms %
% of the GNU General Public License as published by the Free Software Foundation,   %
% either version 3 of the License, or (at your option) any later version.           %
%                                                                                   %
% NS2DDV is distributed in the hope that it will be useful, but WITHOUT ANY         %
% WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A   %
% PARTICULAR PURPOSE. See the GNU General Public License for more details.          %
%                                                                                   %
% You should have received a copy of the GNU General Public License along with      %
% NS2DDV. If not, see <http://www.gnu.org/licenses/>.                               %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function[] = print_prompt_diags(headers, diags, types, printheaders, namefile)

	% INPUT
	% headers			Name of diagnostics to be saved
	% diags				Diagnostics to be saved
	% types				Type of diagnostics to be saved
	% printheaders		Boolean for indicating if headers must be added or not in the output file
	% namefile			The output file to be updated

	k = numel(diags);

	headline = headers{1};
	switch types{1}
		case {'DOUBLE'}
			ld = length(headers{1});
			sd = sprintf('%%%d.%de', ld, ld-8);
			diagline = sprintf(sd, diags{1});
		case {'INT'}
			li = length(headers{1});
			si = sprintf('%%%dd', li);
			diagline = sprintf(si, diags{1});
		otherwise
			error(sprintf('Problem while constituting the list of diagnostics to print in Matlab prompt command.\n'));
	end
	for i=2:k
		headline = [headline ' - ' headers{i}];
		switch types{i}
			case {'DOUBLE'}
				ld = length(headers{i});
				sd = sprintf('%%%d.%de', ld, ld-8);
				newdiag = sprintf(sd, diags{i});
			case {'INT'}
				li = length(headers{i});
				si = sprintf('%%%dd', li);
				newdiag = sprintf(si, diags{i});
			otherwise
				error(sprintf('Problem while constituting the list of diagnostics to print in Matlab prompt command.\n'));
		end
		diagline = [diagline '   ' newdiag];
	end
	
	if printheaders
		disp(headline);
		fid = fopen(namefile, 'w');
		fprintf(fid, [headline sprintf('\n')]);
		disp(diagline);
		fprintf(fid, [diagline sprintf('\n')]);
		fclose(fid);
	else
		fid = fopen(namefile, 'a');
		disp(diagline);
		fprintf(fid, [diagline sprintf('\n')]);
		fclose(fid);
	end
	
end
back to top