1function storeGlobalVars(fname,append)
2% PARALLEL CONTEXT
3% In a parallel context, this function stores all global vars in structure
4% fGlobalVar and saves it in the file fname.mat
5%
6% INPUTS
7% fname  [str]         name of the file
8%
9% append []                        flag to append globals to the storage file
10%
11% OUTPUTS
12% None
13%
14%
15% Copyright (C) 2009-2017 Dynare Team
16%
17% This file is part of Dynare.
18%
19% Dynare is free software: you can redistribute it and/or modify
20% it under the terms of the GNU General Public License as published by
21% the Free Software Foundation, either version 3 of the License, or
22% (at your option) any later version.
23%
24% Dynare is distributed in the hope that it will be useful,
25% but WITHOUT ANY WARRANTY; without even the implied warranty of
26% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27% GNU General Public License for more details.
28%
29% You should have received a copy of the GNU General Public License
30% along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
31
32
33GlobalNames = who('global');
34% varlist = '';
35for j=1:length(GlobalNames)
36    eval(['global ',GlobalNames{j},';']);
37    eval(['fGlobalVar.',GlobalNames{j},'=',GlobalNames{j},';']);
38end
39
40if nargin<2
41    save(fname,'fGlobalVar');
42else
43    save(fname,'fGlobalVar','-append');
44end