Skip to content
Snippets Groups Projects
Select Git revision
  • ef26fe00345cb6d84df1cf4b37aec86421c61c7f
  • master default protected
  • 6.x protected
  • madysson
  • 5.x protected
  • asm
  • time-varying-information-set
  • 4.6 protected
  • dynare_minreal
  • dragonfly
  • various_fixes
  • 4.5 protected
  • clang+openmp
  • exo_steady_state
  • declare_vars_in_model_block
  • julia
  • error_msg_undeclared_model_vars
  • static_aux_vars
  • slice
  • aux_func
  • penalty
  • 6.4 protected
  • 6.3 protected
  • 6.2 protected
  • 6.1 protected
  • 6.0 protected
  • 6-beta2 protected
  • 6-beta1 protected
  • 5.5 protected
  • 5.4 protected
  • 5.3 protected
  • 5.2 protected
  • 5.1 protected
  • 5.0 protected
  • 5.0-rc1 protected
  • 4.7-beta3 protected
  • 4.7-beta2 protected
  • 4.7-beta1 protected
  • 4.6.4 protected
  • 4.6.3 protected
  • 4.6.2 protected
41 results

dynare.m

Blame
  • dynare.m 4.38 KiB
    function dynare(fname, varargin)
    %       This command runs dynare with specified model file in argument
    %       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.
    %
    % INPUTS
    %   fname:      file name
    %   varargin:   list of arguments following fname
    %             
    % OUTPUTS
    %   none
    %        
    % SPECIAL REQUIREMENTS
    %   none
    
    % Copyright (C) 2001-2011 Dynare Team
    %
    % This file is part of Dynare.
    %
    % Dynare 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.
    %
    % Dynare 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 Dynare.  If not, see <http://www.gnu.org/licenses/>.
    
    if strcmpi(fname,'help')
        disp(' ')
        disp(['This is dynare version ' dynare_version() '.'])
        disp(' ')
        disp('USAGE: dynare FILENAME[.mod,.dyn] [OPTIONS]')
        disp(' ')
        disp('dynare executes instruction included in FILENAME.mod.')
        disp('See the reference manual for the available options.')
        return
    end
    
    warning_config()
    
    if exist('OCTAVE_VERSION')
        if octave_ver_less_than('3.0.0')
            warning('This version of Dynare has only been tested on Octave 3.0.0 and above. Since your Octave version is older than that, Dynare may fail to run, or give unexpected results. Consider upgrading your Octave installation.');
        end
    else
        if matlab_ver_less_than('7.0')
            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.');
        end
    end
    
    % disable output paging (it is on by default on Octave)
    more off
    
    % sets default format for save() command
    if exist('OCTAVE_VERSION')
        default_save_options('-mat')
    end
    
    % Escape if test or doc flag
    if strcmpi(fname,'--test')
        if nargin>1
            dynare_config([],0);
            number_of_matlab_routines = length(varargin);
            for i=1:number_of_matlab_routines
                dynTest(varargin{i});
            end
        else
            disp('You have to specify at least one matlab routine after --test flag!')
        end
        return
    end
    
    if strcmpi(fname,'--doc')
        if nargin==2
            dynare_config([],0);
            dynInfo(varargin{1})
        else
            if nargin<2
                disp('You have to specify a matlab routine after --doc flag!')
            else
                disp('I can only show internal documentation for one matlab routine!')
            end
        end
        return
    end
    
    % detect if MEX files are present; if not, use alternative M-files
    dynareroot = dynare_config;
    
    if nargin < 1
        error('DYNARE: you must provide the name of the MOD file in argument')
    end
    
    if ~ischar(fname)
        error('DYNARE: argument of dynare must be a text string')
    end
    
    % Testing if file have extension
    % If no extension default .mod is added
    if isempty(strfind(fname,'.'))
        fname1 = [fname '.dyn'];
        d = dir(fname1);
        if length(d) == 0
            fname1 = [fname '.mod'];
        end
        fname = fname1;
        % Checking file extension
    else
        if ~strcmp(upper(fname(size(fname,2)-3:size(fname,2))),'.MOD') ...
                && ~strcmp(upper(fname(size(fname,2)-3:size(fname,2))),'.DYN')
            error('DYNARE: argument must be a filename with .mod or .dyn extension')
        end;
    end;
    d = dir(fname);
    if length(d) == 0
        error(['DYNARE: can''t open ' fname])
    end
    
    command = ['"' dynareroot 'dynare_m" ' fname] ;
    for i=2:nargin
        command = [command ' ' varargin{i-1}];
    end
    
    % Workaround for bug in Octave >= 3.2
    % See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=550823
    if exist('OCTAVE_VERSION') && ~octave_ver_less_than('3.2.0')
        sleep(2)
    end
    
    [status, result] = system(command);
    disp(result)
    if status
        % Should not use "error(result)" since message will be truncated if too long
        error('DYNARE: preprocessing failed')
    end
    
    if ~ isempty(find(abs(fname) == 46))
        fname = fname(:,1:find(abs(fname) == 46)-1) ;
    end
    evalin('base',fname) ;