function dyngraph(str)
% function dyngraph('name.pdf')
%   'name.pdf' is by default the model's name
%   '.pdf' est facultative

% Created Gilles Bélanger
% Ministère des Finances du Québec
% Released under GPL 2

N = length(get(0,'Children'));
if nargin == 0
    str = get(0,'DiaryFile');
    str = str(1:length(str)-4);
    str = [ str '.pdf' ];
elseif length(str) > 5
	if strcmp('.pdf',str(length(str)-3:length(str))) == 0
		str = [ str '.pdf' ];
    end
end
for k=1:N
    figure(k)
    suptitle(get(k,'Name'))
    if k > 1
        print('-dpsc2','input.ps','-append')
    else
        print('-dpsc2','input.ps')
    end
end
system('del *_IRF_*.pdf *_IRF_*.fig *_IRF_*.eps');
ps2pdf('psfile', 'input.ps', 'pdffile', str, 'gspapersize', 'a4', 'deletepsfile', 1)
end
