2005-02-18 20:54:39 +01:00
|
|
|
function dynare(fname, varargin)
|
2006-03-23 12:03:04 +01:00
|
|
|
% This command runs dynare with specified model file in argument
|
2005-02-18 20:54:39 +01:00
|
|
|
% Filename.
|
|
|
|
% The name of model file begins with an alphabetic character,
|
|
|
|
% and has a filename extension of .mod or .dyn.
|
|
|
|
% When extension is omitted, a model file with .mod extension
|
|
|
|
% is processed.
|
2008-01-16 16:32:46 +01:00
|
|
|
%
|
|
|
|
% INPUTS
|
|
|
|
% fname: file name
|
|
|
|
% varargin: list of arguments following fname
|
|
|
|
%
|
|
|
|
% OUTPUTS
|
|
|
|
% none
|
|
|
|
%
|
|
|
|
% SPECIAL REQUIREMENTS
|
|
|
|
% none
|
|
|
|
%
|
|
|
|
% part of DYNARE, copyright Dynare Team (2001-2008)
|
|
|
|
% Gnu Public License.
|
2008-05-27 11:46:44 +02:00
|
|
|
|
|
|
|
if nargin < 1
|
|
|
|
error('You must provide the name of the MOD file in argument');
|
|
|
|
end
|
|
|
|
|
2008-05-23 16:45:37 +02:00
|
|
|
if ~ischar(fname)
|
2006-07-17 10:47:30 +02:00
|
|
|
error ('The argument in DYNARE must be a text string.') ;
|
2005-02-18 20:54:39 +01:00
|
|
|
end
|
2008-05-27 11:46:44 +02:00
|
|
|
|
|
|
|
dynareroot = dynare_config();
|
|
|
|
|
2005-02-18 20:54:39 +01:00
|
|
|
% Testing if file have extension
|
|
|
|
% If no extension defalut .mod is added
|
|
|
|
if isempty(strfind(fname,'.'))
|
2006-03-24 13:47:38 +01:00
|
|
|
fname1 = [fname '.dyn'];
|
|
|
|
d = dir(fname1);
|
|
|
|
if length(d) == 0
|
|
|
|
fname1 = [fname '.mod'];
|
|
|
|
end
|
|
|
|
fname = fname1;
|
|
|
|
% Checking file extension
|
2005-02-18 20:54:39 +01:00
|
|
|
else
|
2006-03-24 13:47:38 +01:00
|
|
|
if ~strcmp(upper(fname(size(fname,2)-3:size(fname,2))),'.MOD') ...
|
|
|
|
&& ~strcmp(upper(fname(size(fname,2)-3:size(fname,2))),'.DYN')
|
|
|
|
error ('Argument is a file name with .mod or .dyn extension');
|
|
|
|
end;
|
2005-02-18 20:54:39 +01:00
|
|
|
end;
|
2006-03-24 13:47:38 +01:00
|
|
|
d = dir(fname);
|
|
|
|
if length(d) == 0
|
|
|
|
disp(['DYNARE: can''t open ' fname])
|
|
|
|
return
|
|
|
|
end
|
2007-12-19 17:40:48 +01:00
|
|
|
|
2007-05-25 21:18:14 +02:00
|
|
|
command = ['"' dynareroot 'dynare_m" ' fname] ;
|
2005-02-18 20:54:39 +01:00
|
|
|
for i=2:nargin
|
|
|
|
command = [command ' ' varargin{i-1}];
|
|
|
|
end
|
|
|
|
[status, result] = system(command);
|
2008-04-02 17:01:52 +02:00
|
|
|
disp(result)
|
2005-02-18 20:54:39 +01:00
|
|
|
if status
|
2008-04-02 17:01:52 +02:00
|
|
|
% Should not use "error(result)" since message will be truncated if too long
|
|
|
|
error('Preprocessing failed')
|
2005-02-18 20:54:39 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
if ~ isempty(find(abs(fname) == 46))
|
|
|
|
fname = fname(:,1:find(abs(fname) == 46)-1) ;
|
|
|
|
end
|
2007-12-19 17:40:48 +01:00
|
|
|
evalin('base',fname) ;
|