Home > . > dynare.m

dynare

PURPOSE ^

Copyright (C) 2001 Michel Juillard

SYNOPSIS ^

function dynare(fname, varargin)

DESCRIPTION ^

 Copyright (C) 2001 Michel Juillard

    DYNARE ( 'Filename' )
    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.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % Copyright (C) 2001 Michel Juillard
0002 %
0003 function dynare(fname, varargin)
0004 %    DYNARE ( 'Filename' )
0005 %    This command runs dynare with specified model file in argument
0006 %     Filename.
0007 %    The name of model file begins with an alphabetic character,
0008 %    and has a filename extension of .mod or .dyn.
0009 %    When extension is omitted, a model file with .mod extension
0010 %    is processed.
0011 
0012 if ~isstr(fname)
0013     error ('The argument in DYNARE must be a text string.') ;
0014 end
0015 % Testing if file have extension
0016 % If no extension defalut .mod is added
0017 if isempty(strfind(fname,'.'))
0018   fname1 = [fname '.dyn'];
0019   d = dir(fname1);
0020   if length(d) == 0
0021     fname1 = [fname '.mod'];
0022   end
0023   fname = fname1;
0024   % Checking file extension
0025 else
0026   if ~strcmp(upper(fname(size(fname,2)-3:size(fname,2))),'.MOD') ...
0027     && ~strcmp(upper(fname(size(fname,2)-3:size(fname,2))),'.DYN')
0028     error ('Argument is a file name with .mod or .dyn extension');
0029   end;
0030 end;
0031 d = dir(fname);
0032 if length(d) == 0
0033   disp(['DYNARE: can''t open ' fname])
0034   return
0035 end
0036 dynareroot = strrep(which('dynare.m'),'dynare.m','');
0037 command = [dynareroot 'dynare_m ' fname] ;
0038 for i=2:nargin
0039   command = [command ' ' varargin{i-1}];
0040 end
0041 [status, result] = system(command);
0042 if status
0043   error(result)
0044 end
0045 
0046 if ~ isempty(find(abs(fname) == 46))
0047     fname = fname(:,1:find(abs(fname) == 46)-1) ;
0048 end
0049 evalin('base',fname) ;
0050 
0051 
0052 % MJ 2/9/99: replace clear function by clear ff_
0053 % MJ 4/7/00: change the path of dynare_m
0054 % MJ 02/26/01: replaced local variable x by fname
0055 % MJ 09/19/01: evaluates mod script in 'base' workspace

Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003