Added (command line) nointeractive option.

time-shift
Stéphane Adjemian (Charybdis) 2013-07-10 12:02:12 +02:00
parent dd21816b13
commit 3dc372e5bc
8 changed files with 58 additions and 34 deletions

View File

@ -747,6 +747,9 @@ computations.
Activate the @code{nograph} option (@xref{nograph}), so that Dynare will not produce any Activate the @code{nograph} option (@xref{nograph}), so that Dynare will not produce any
graph graph
@item nointeractive
Instructs Dynare to not request user input
@item cygwin @item cygwin
Tells Dynare that your MATLAB is configured for compiling MEX files with Tells Dynare that your MATLAB is configured for compiling MEX files with
Cygwin (@pxref{Software requirements}). This option is only available Cygwin (@pxref{Software requirements}). This option is only available

View File

@ -93,30 +93,35 @@ if isempty(varlist)
string = [ cas , ' will be computed for the ' num2str(M_.endo_nbr) ' endogenous variables']; string = [ cas , ' will be computed for the ' num2str(M_.endo_nbr) ' endogenous variables'];
string = [ string ' of your model, this can be very long....']; string = [ string ' of your model, this can be very long....'];
format_text(string, 10) format_text(string, 10)
choice = []; if options_.nointeractive
while isempty(choice) % Default behaviour is to consider all the endogenous variables.
disp(' ') varlist = M_.endo_names(1:M_.orig_endo_nbr, :);
disp(' ') else
disp('Choose one of the following options:') choice = [];
disp(' ') while isempty(choice)
disp(' [1] Consider all the endogenous variables.') disp(' ')
disp(' [2] Consider all the observed endogenous variables.') disp(' ')
disp(' [3] Stop Dynare and change the mod file.') disp('Choose one of the following options:')
disp(' ') disp(' ')
choice = input('options [default is 1] = '); disp(' [1] Consider all the endogenous variables.')
if isempty(choice) disp(' [2] Consider all the observed endogenous variables.')
choice=1; disp(' [3] Stop Dynare and change the mod file.')
end disp(' ')
if choice==1 choice = input('options [default is 1] = ');
varlist = M_.endo_names(1:M_.orig_endo_nbr, :); if isempty(choice)
elseif choice==2 choice=1;
varlist = options_.varobs; end
elseif choice==3 if choice==1
varlist = NaN; varlist = M_.endo_names(1:M_.orig_endo_nbr, :);
else elseif choice==2
disp('') varlist = options_.varobs;
disp('YOU HAVE TO ANSWER 1, 2 or 3!') elseif choice==3
disp('') varlist = NaN;
else
disp('')
disp('YOU HAVE TO ANSWER 1, 2 or 3!')
disp('')
end
end end
end end
end end

View File

@ -107,6 +107,9 @@ gmhmaxlik.nclimb = 200000;
gmhmaxlik.nscale = 200000; gmhmaxlik.nscale = 200000;
options_.gmhmaxlik = gmhmaxlik; options_.gmhmaxlik = gmhmaxlik;
% Request user input.
options_.nointeractive = 0;
% Graphics % Graphics
options_.graphics.nrows = 3; options_.graphics.nrows = 3;
options_.graphics.ncols = 3; options_.graphics.ncols = 3;

View File

@ -127,9 +127,15 @@ if ~options_.load_mh_file && ~options_.mh_recover
init_iter = init_iter + 1; init_iter = init_iter + 1;
if init_iter > 100 && validate == 0 if init_iter > 100 && validate == 0
disp(['MH: I couldn''t get a valid initial value in 100 trials.']) disp(['MH: I couldn''t get a valid initial value in 100 trials.'])
disp(['MH: You should Reduce mh_init_scale...']) if options_.nointeractive
disp(sprintf('MH: Parameter mh_init_scale is equal to %f.',options_.mh_init_scale)) disp(['MH: I reduce mh_init_scale by ten percent:'])
options_.mh_init_scale = input('MH: Enter a new value... '); options_.mh_init_scale = .9*options_.mh_init_scale;
disp(sprintf('MH: Parameter mh_init_scale is now equal to %f.',options_.mh_init_scale))
else
disp(['MH: You should Reduce mh_init_scale...'])
disp(sprintf('MH: Parameter mh_init_scale is equal to %f.',options_.mh_init_scale))
options_.mh_init_scale = input('MH: Enter a new value... ');
end
trial = trial+1; trial = trial+1;
end end
end end

View File

@ -36,7 +36,7 @@ using namespace std;
Splitting main() in two parts was necessary because ParsingDriver.h and MacroDriver.h can't be Splitting main() in two parts was necessary because ParsingDriver.h and MacroDriver.h can't be
included simultaneously (because of Bison limitations). included simultaneously (because of Bison limitations).
*/ */
void main2(stringstream &in, string &basename, bool debug, bool clear_all, bool no_tmp_terms, bool no_log, bool no_warn, bool warn_uninit, bool console, bool nograph, void main2(stringstream &in, string &basename, bool debug, bool clear_all, bool no_tmp_terms, bool no_log, bool no_warn, bool warn_uninit, bool console, bool nograph, bool nointeractive,
bool parallel, const string &parallel_config_file, const string &cluster_name, bool parallel_slave_open_mode, bool parallel, const string &parallel_config_file, const string &cluster_name, bool parallel_slave_open_mode,
bool parallel_test bool parallel_test
#if defined(_WIN32) || defined(__CYGWIN32__) #if defined(_WIN32) || defined(__CYGWIN32__)
@ -48,7 +48,7 @@ void
usage() usage()
{ {
cerr << "Dynare usage: dynare mod_file [debug] [noclearall] [savemacro[=macro_file]] [onlymacro] [nolinemacro] [notmpterms] [nolog] [warn_uninit]" cerr << "Dynare usage: dynare mod_file [debug] [noclearall] [savemacro[=macro_file]] [onlymacro] [nolinemacro] [notmpterms] [nolog] [warn_uninit]"
<< " [console] [nograph] [parallel[=cluster_name]] [conffile=parallel_config_path_and_filename] [parallel_slave_open_mode] [parallel_test] " << " [console] [nograph] [nointeractive] [parallel[=cluster_name]] [conffile=parallel_config_path_and_filename] [parallel_slave_open_mode] [parallel_test] "
<< " [-D<variable>[=<value>]]" << " [-D<variable>[=<value>]]"
#if defined(_WIN32) || defined(__CYGWIN32__) #if defined(_WIN32) || defined(__CYGWIN32__)
<< " [cygwin] [msvc]" << " [cygwin] [msvc]"
@ -85,6 +85,7 @@ main(int argc, char **argv)
bool warn_uninit = false; bool warn_uninit = false;
bool console = false; bool console = false;
bool nograph = false; bool nograph = false;
bool nointeractive = false;
#if defined(_WIN32) || defined(__CYGWIN32__) #if defined(_WIN32) || defined(__CYGWIN32__)
bool cygwin = false; bool cygwin = false;
bool msvc = false; bool msvc = false;
@ -132,6 +133,8 @@ main(int argc, char **argv)
console = true; console = true;
else if (!strcmp(argv[arg], "nograph")) else if (!strcmp(argv[arg], "nograph"))
nograph = true; nograph = true;
else if (!strcmp(argv[arg], "nointeractive"))
nointeractive = true;
#if defined(_WIN32) || defined(__CYGWIN32__) #if defined(_WIN32) || defined(__CYGWIN32__)
else if (!strcmp(argv[arg], "cygwin")) else if (!strcmp(argv[arg], "cygwin"))
cygwin = true; cygwin = true;
@ -224,7 +227,7 @@ main(int argc, char **argv)
return EXIT_SUCCESS; return EXIT_SUCCESS;
// Do the rest // Do the rest
main2(macro_output, basename, debug, clear_all, no_tmp_terms, no_log, no_warn, warn_uninit, console, nograph, main2(macro_output, basename, debug, clear_all, no_tmp_terms, no_log, no_warn, warn_uninit, console, nograph, nointeractive,
parallel, parallel_config_file, cluster_name, parallel_slave_open_mode, parallel_test parallel, parallel_config_file, cluster_name, parallel_slave_open_mode, parallel_test
#if defined(_WIN32) || defined(__CYGWIN32__) #if defined(_WIN32) || defined(__CYGWIN32__)
, cygwin, msvc , cygwin, msvc

View File

@ -26,7 +26,7 @@ using namespace std;
#include "ConfigFile.hh" #include "ConfigFile.hh"
void void
main2(stringstream &in, string &basename, bool debug, bool clear_all, bool no_tmp_terms, bool no_log, bool no_warn, bool warn_uninit, bool console, bool nograph, main2(stringstream &in, string &basename, bool debug, bool clear_all, bool no_tmp_terms, bool no_log, bool no_warn, bool warn_uninit, bool console, bool nograph, bool nointeractive,
bool parallel, const string &parallel_config_file, const string &cluster_name, bool parallel_slave_open_mode, bool parallel, const string &parallel_config_file, const string &cluster_name, bool parallel_slave_open_mode,
bool parallel_test bool parallel_test
#if defined(_WIN32) || defined(__CYGWIN32__) #if defined(_WIN32) || defined(__CYGWIN32__)
@ -58,7 +58,7 @@ main2(stringstream &in, string &basename, bool debug, bool clear_all, bool no_tm
mod_file->computingPass(no_tmp_terms); mod_file->computingPass(no_tmp_terms);
// Write outputs // Write outputs
mod_file->writeOutputFiles(basename, clear_all, no_log, no_warn, console, nograph, config_file mod_file->writeOutputFiles(basename, clear_all, no_log, no_warn, console, nograph, nointeractive, config_file
#if defined(_WIN32) || defined(__CYGWIN32__) #if defined(_WIN32) || defined(__CYGWIN32__)
, cygwin, msvc , cygwin, msvc
#endif #endif

View File

@ -455,7 +455,7 @@ ModFile::computingPass(bool no_tmp_terms)
} }
void void
ModFile::writeOutputFiles(const string &basename, bool clear_all, bool no_log, bool no_warn, bool console, bool nograph, const ConfigFile &config_file ModFile::writeOutputFiles(const string &basename, bool clear_all, bool no_log, bool no_warn, bool console, bool nograph, bool nointeractive, const ConfigFile &config_file
#if defined(_WIN32) || defined(__CYGWIN32__) #if defined(_WIN32) || defined(__CYGWIN32__)
, bool cygwin, bool msvc , bool cygwin, bool msvc
#endif #endif
@ -511,6 +511,9 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool no_log, b
<< "options_.nodisplay = 1;" << endl; << "options_.nodisplay = 1;" << endl;
if (nograph) if (nograph)
mOutputFile << "options_.nograph = 1;" << endl; mOutputFile << "options_.nograph = 1;" << endl;
if (nointeractive)
mOutputFile << "options_.nointeractive = 1;" << endl;
cout << "Processing outputs ..."; cout << "Processing outputs ...";

View File

@ -128,10 +128,11 @@ public:
\param clear_all Should a "clear all" instruction be written to output ? \param clear_all Should a "clear all" instruction be written to output ?
\param console Are we in console mode ? \param console Are we in console mode ?
\param nograph Should we build the figures? \param nograph Should we build the figures?
\param nointeractive Should Dynare request user input?
\param cygwin Should the MEX command of use_dll be adapted for Cygwin? \param cygwin Should the MEX command of use_dll be adapted for Cygwin?
\param msvc Should the MEX command of use_dll be adapted for MSVC? \param msvc Should the MEX command of use_dll be adapted for MSVC?
*/ */
void writeOutputFiles(const string &basename, bool clear_all, bool no_log, bool no_warn, bool console, bool nograph, const ConfigFile &config_file void writeOutputFiles(const string &basename, bool clear_all, bool no_log, bool no_warn, bool console, bool nograph, bool nointeractive, const ConfigFile &config_file
#if defined(_WIN32) || defined(__CYGWIN32__) #if defined(_WIN32) || defined(__CYGWIN32__)
, bool cygwin, bool msvc , bool cygwin, bool msvc
#endif #endif