diff --git a/src/ComputingTasks.cc b/src/ComputingTasks.cc index 400eda98b4d87e3fd08f89810a4cdcb120cbc823..d6efce8d921713875f8fcd9996bf9a7bad7b808e 100644 --- a/src/ComputingTasks.cc +++ b/src/ComputingTasks.cc @@ -2635,6 +2635,22 @@ void IdentificationStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) { mod_file_struct.identification_present = true; + auto it = options_list.num_options.find("order"); + if (it != options_list.num_options.end()) + { + int order = stoi(it->second); + if (order < 1 || order > 2) + { + cerr << "ERROR: the order option of identification command must be either 1 or 2" << endl; + + exit(EXIT_FAILURE); + } + mod_file_struct.identification_order = max(mod_file_struct.identification_order, order); + + } + else + // The default value for order is 1 (which triggers 2nd order dynamic derivatives) + mod_file_struct.identification_order = max(mod_file_struct.identification_order, 1); } void diff --git a/src/DynareBison.yy b/src/DynareBison.yy index b1a2cf90502582e863d7081299660e842286d9d3..1a668e36949c2924f12ce4a51b439237b8abf7e1 100644 --- a/src/DynareBison.yy +++ b/src/DynareBison.yy @@ -2247,6 +2247,7 @@ identification_option : o_ar | o_tol_sv | o_checks_via_subsets | o_max_dim_subsets_groups + | o_order ; model_comparison : MODEL_COMPARISON mc_filename_list ';' diff --git a/src/ModFile.cc b/src/ModFile.cc index d395a38b3081baab5eff0b0410edd662176e9de3..13445056e22816ef6528fe67f823fc2d4a832986 100644 --- a/src/ModFile.cc +++ b/src/ModFile.cc @@ -758,8 +758,9 @@ ModFile::computingPass(bool no_tmp_terms, FileOutputType output, int params_deri cerr << "ERROR: Incorrect order option..." << endl; exit(EXIT_FAILURE); } - int derivsOrder = mod_file_struct.order_option; - if (mod_file_struct.identification_present || linear || output == FileOutputType::second) + int derivsOrder = max(mod_file_struct.order_option, + mod_file_struct.identification_order + 1); + if (mod_file_struct.sensitivity_present || linear || output == FileOutputType::second) derivsOrder = max(derivsOrder, 2); if (mod_file_struct.estimation_analytic_derivation || output == FileOutputType::third) derivsOrder = max(derivsOrder, 3); diff --git a/src/Statement.hh b/src/Statement.hh index 9c7df3e5d1e3a51ba6f3ff46df46a874ecd73f5b..137a2dcaadb5af62aba19d91061a6218f2359ce8 100644 --- a/src/Statement.hh +++ b/src/Statement.hh @@ -68,6 +68,8 @@ public: bool svar_identification_present{false}; //! Whether an identification statement is present or the identification option of dynare_sensitivity statement is equal to one bool identification_present{false}; + //! The maximum of the “order” option in identification statements + int identification_order{0}; //! Whether a sensitivity statement is present bool sensitivity_present{false}; //! Whether the option analytic_derivation is given to estimation