diff --git a/src/DynamicModel.cc b/src/DynamicModel.cc index e225d48d7f416f3f870b107174cc3ce2c92cb82a..ebaa5152940874c43dd2e77a64e9d6e7a77c1d88 100644 --- a/src/DynamicModel.cc +++ b/src/DynamicModel.cc @@ -209,6 +209,8 @@ DynamicModel::writeDynamicBlockBytecode(const string &basename) const // Temporary variables declaration code_file << FDIMT_{static_cast<int>(blocks_temporary_terms_idxs.size())}; + temporary_terms_t temporary_terms_written; + for (int block {0}; block < static_cast<int>(blocks.size()); block++) { const BlockSimulationType simulation_type {blocks[block].simulation_type}; @@ -231,7 +233,7 @@ DynamicModel::writeDynamicBlockBytecode(const string &basename) const u_count, static_cast<int>(blocks_jacob_cols_endo[block].size())}; - writeBlockBytecodeHelper<true>(code_file, block); + writeBlockBytecodeHelper<true>(code_file, block, temporary_terms_written); } code_file << FEND_{}; } diff --git a/src/ModelTree.hh b/src/ModelTree.hh index 2cc2be0cd3ee8547e6a70d24997d2f8555a51b6b..0c0044a4b8167cd6c2b5a749068e446561cd8525 100644 --- a/src/ModelTree.hh +++ b/src/ModelTree.hh @@ -333,7 +333,7 @@ protected: // Helper for writing blocks in bytecode template<bool dynamic> - void writeBlockBytecodeHelper(BytecodeWriter &code_file, int block) const; + void writeBlockBytecodeHelper(BytecodeWriter &code_file, int block, temporary_terms_t &temporary_terms_union) const; // Helper for writing sparse derivatives indices in MATLAB/Octave driver file template<bool dynamic> @@ -1642,7 +1642,7 @@ ModelTree::writeBytecodeHelper(BytecodeWriter &code_file) const template<bool dynamic> void -ModelTree::writeBlockBytecodeHelper(BytecodeWriter &code_file, int block) const +ModelTree::writeBlockBytecodeHelper(BytecodeWriter &code_file, int block, temporary_terms_t &temporary_terms_union) const { constexpr ExprNodeBytecodeOutputType output_type { dynamic ? ExprNodeBytecodeOutputType::dynamicModel : ExprNodeBytecodeOutputType::staticModel }; @@ -1654,7 +1654,6 @@ ModelTree::writeBlockBytecodeHelper(BytecodeWriter &code_file, int block) const const int block_mfs {blocks[block].mfs_size}; const int block_recursive {blocks[block].getRecursiveSize()}; - temporary_terms_t temporary_terms_union; deriv_node_temp_terms_t tef_terms; auto write_eq_tt = [&](int eq) diff --git a/src/StaticModel.cc b/src/StaticModel.cc index 3282d4e9f050196af676cfb7e8639f75a7d3db26..7b59a2871ad6fe2cda365009fd933f74bb62928f 100644 --- a/src/StaticModel.cc +++ b/src/StaticModel.cc @@ -143,6 +143,8 @@ StaticModel::writeStaticBlockBytecode(const string &basename) const // Temporary variables declaration code_file << FDIMST_{static_cast<int>(blocks_temporary_terms_idxs.size())}; + temporary_terms_t temporary_terms_written; + for (int block {0}; block < static_cast<int>(blocks.size()); block++) { const BlockSimulationType simulation_type {blocks[block].simulation_type}; @@ -163,7 +165,7 @@ StaticModel::writeStaticBlockBytecode(const string &basename) const u_count, block_size}; - writeBlockBytecodeHelper<false>(code_file, block); + writeBlockBytecodeHelper<false>(code_file, block, temporary_terms_written); } code_file << FEND_{}; }