diff --git a/preprocessor/ModFile.cc b/preprocessor/ModFile.cc index 27299deac983001174e56b479f11879753001432..649440c95d3d79fd9a22e326b55acec4fdee397f 100644 --- a/preprocessor/ModFile.cc +++ b/preprocessor/ModFile.cc @@ -594,6 +594,9 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool no_log, b mOutputFile << "M_.H = 0;" << endl << "M_.Correlation_matrix_ME = 1;" << endl; + // May be later modified by a shocks block + mOutputFile << "M_.sigma_e_is_diagonal = 1;" << endl; + // Initialize M_.det_shocks mOutputFile << "M_.det_shocks = [];" << endl; diff --git a/preprocessor/Shocks.cc b/preprocessor/Shocks.cc index 25adbdee9a1d182c006c50799b4828f25f74ac9d..8373d9d934c550390f4c03c03df9dcbe36db44e3 100644 --- a/preprocessor/Shocks.cc +++ b/preprocessor/Shocks.cc @@ -89,9 +89,14 @@ ShocksStatement::writeOutput(ostream &output, const string &basename) const writeDetShocks(output); writeVarAndStdShocks(output); writeCovarAndCorrShocks(output); + + /* M_.sigma_e_is_diagonal is initialized to 1 by ModFile.cc. + If there are no off-diagonal elements, and we are not in overwrite mode, + then we don't reset it to 1, since there might be previous shocks blocks + with off-diagonal elements. */ if (covar_shocks.size()+corr_shocks.size() > 0) output << "M_.sigma_e_is_diagonal = 0;" << endl; - else + else if (overwrite) output << "M_.sigma_e_is_diagonal = 1;" << endl; }