0001 function dynare(fname, varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 if strcmpi(fname,'help')
0037 disp(' ')
0038 disp(['This is dynare version ' dynare_version() '.'])
0039 disp(' ')
0040 disp('USAGE: dynare FILENAME[.mod,.dyn] [OPTIONS]')
0041 disp(' ')
0042 disp('dynare executes instruction included in FILENAME.mod.')
0043 disp('See the reference manual for the available options.')
0044 return
0045 end
0046
0047 warning_config()
0048
0049 if exist('OCTAVE_VERSION')
0050 if octave_ver_less_than('3.2.2')
0051 warning('This version of Dynare has only been tested on Octave 3.2.2 and above. Since your Octave version is older than that, Dynare may fail to run, or give unexpected results. Consider upgrading your Octave installation.');
0052 end
0053 else
0054 if matlab_ver_less_than('7.0')
0055 warning('This version of Dynare has only been tested on MATLAB 7.0 (R14) and above. Since your MATLAB version is older than that, Dynare may fail to run, or give unexpected results. Consider upgrading your MATLAB installation, or switch to Octave.');
0056 end
0057 end
0058
0059
0060 more off
0061
0062
0063 if exist('OCTAVE_VERSION')
0064 default_save_options('-mat')
0065 end
0066
0067
0068 dynareroot = dynare_config;
0069
0070 if nargin < 1
0071 error('DYNARE: you must provide the name of the MOD file in argument')
0072 end
0073
0074 if ~ischar(fname)
0075 error('DYNARE: argument of dynare must be a text string')
0076 end
0077
0078
0079
0080 if isempty(strfind(fname,'.'))
0081 fname1 = [fname '.dyn'];
0082 d = dir(fname1);
0083 if length(d) == 0
0084 fname1 = [fname '.mod'];
0085 end
0086 fname = fname1;
0087
0088 else
0089 if ~strcmp(upper(fname(size(fname,2)-3:size(fname,2))),'.MOD') ...
0090 && ~strcmp(upper(fname(size(fname,2)-3:size(fname,2))),'.DYN')
0091 error('DYNARE: argument must be a filename with .mod or .dyn extension')
0092 end;
0093 end;
0094 d = dir(fname);
0095 if length(d) == 0
0096 error(['DYNARE: can''t open ' fname])
0097 end
0098
0099 command = ['"' dynareroot 'dynare_m" ' fname] ;
0100 for i=2:nargin
0101 command = [command ' ' varargin{i-1}];
0102 end
0103
0104
0105
0106 if exist('OCTAVE_VERSION') && octave_ver_less_than('3.4.0')
0107 sleep(2)
0108 end
0109
0110 [status, result] = system(command);
0111 disp(result)
0112 if status
0113
0114 error('DYNARE: preprocessing failed')
0115 end
0116
0117 if ~ isempty(find(abs(fname) == 46))
0118 fname = fname(:,1:find(abs(fname) == 46)-1) ;
0119 end
0120 evalin('base',fname) ;