@@ -1251,17 +1251,37 @@ AdvanceStatus ADIOS2File::advance(AdvanceMode mode)
12511251 return engineType == " bp5writer" ;
12521252 };
12531253
1254+ if (this ->m_currentStep == 0 )
1255+ {
1256+ int max_steps_from_env =
1257+ auxiliary::getEnvNum (" OPENPMD_BP5_GROUPENCODING_MAX_STEPS" , -1 );
1258+ if (max_steps_from_env == 0 )
1259+ {
1260+ m_max_steps_bp5 = std::nullopt ;
1261+ }
1262+ else if (max_steps_from_env != -1 )
1263+ {
1264+ m_max_steps_bp5 =
1265+ std::make_optional<size_t >(size_t (max_steps_from_env));
1266+ }
1267+ }
1268+
12541269 // Check some conditions on which to now cancel operation due to
12551270 // unwieldy metadata sizes in BP5 with group encoding
12561271 if (this ->m_impl ->m_handler ->m_encoding ==
12571272 IterationEncoding::groupBased &&
1258- this ->m_currentStep >= 1000 &&
1273+ this ->m_max_steps_bp5 .has_value () &&
1274+ this ->m_currentStep >= *this ->m_max_steps_bp5 &&
12591275 (this ->m_mode == adios2::Mode::Write ||
12601276 this ->m_mode == adios2::Mode::Append) &&
12611277 check_bp5 ())
12621278 {
1263- throw error::OperationUnsupportedInBackend (" ADIOS2" , R"(
1264- Trying to create group-based output with more than 1000 steps in BP5 engine.
1279+ throw error::OperationUnsupportedInBackend (
1280+ " ADIOS2" ,
1281+ R"(
1282+ Trying to create group-based output with more than )" +
1283+ std::to_string (*this ->m_max_steps_bp5 ) +
1284+ R"( steps in BP5 engine.
12651285As this engine is not adequate for group encoding, this will create immense
12661286metadata sizes. For more context, check:
12671287
@@ -1278,7 +1298,11 @@ Please consider using either of the following instead:
12781298* (experimental) variable encoding (e.g. by `Series::setIterationEncoding()`
12791299 or by the JSON config {"iteration_encoding": "variable_based"}).
12801300 Note that there is at this point no complete read support for variable-encoded
1281- outputs.)" );
1301+ outputs.
1302+
1303+ Use the environment variable OPENPMD_BP5_GROUPENCODING_MAX_STEPS to adjust the
1304+ number of allowed steps. Set the value as 0 to disable this check.
1305+ Be aware of the performance implications described above.)" );
12821306 }
12831307
12841308 if (streamStatus != StreamStatus::DuringStep)
0 commit comments