@@ -248,11 +248,12 @@ namespace
248248 }
249249} // namespace
250250
251- auto JSONIOHandlerImpl::retrieveDatasetMode (openPMD::json::TracingJSON &config)
252- const -> std::pair<IOMode, SpecificationVia>
251+ auto JSONIOHandlerImpl::retrieveDatasetMode (
252+ openPMD::json::TracingJSON &config) const -> DatasetMode
253253{
254- IOMode res = m_mode;
255- SpecificationVia res_2 = SpecificationVia::DefaultValue;
254+ IOMode ioMode = m_mode;
255+ SpecificationVia specificationVia = SpecificationVia::DefaultValue;
256+ bool skipWarnings = false ;
256257 if (auto [configLocation, maybeConfig] = getBackendConfig (config);
257258 maybeConfig.has_value ())
258259 {
@@ -274,13 +275,19 @@ auto JSONIOHandlerImpl::retrieveDatasetMode(openPMD::json::TracingJSON &config)
274275 auto mode = modeOption.value ();
275276 if (mode == " dataset" )
276277 {
277- res = IOMode::Dataset;
278- res_2 = SpecificationVia::Manually;
278+ ioMode = IOMode::Dataset;
279+ specificationVia = SpecificationVia::Manually;
279280 }
280281 else if (mode == " template" )
281282 {
282- res = IOMode::Template;
283- res_2 = SpecificationVia::Manually;
283+ ioMode = IOMode::Template;
284+ specificationVia = SpecificationVia::Manually;
285+ }
286+ else if (mode == " template_no_warn" )
287+ {
288+ ioMode = IOMode::Template;
289+ specificationVia = SpecificationVia::Manually;
290+ skipWarnings = true ;
284291 }
285292 else
286293 {
@@ -292,7 +299,7 @@ auto JSONIOHandlerImpl::retrieveDatasetMode(openPMD::json::TracingJSON &config)
292299 }
293300 }
294301 }
295- return std::make_pair (res, res_2) ;
302+ return DatasetMode{ioMode, specificationVia, skipWarnings} ;
296303}
297304
298305auto JSONIOHandlerImpl::retrieveAttributeMode (
@@ -379,7 +386,9 @@ JSONIOHandlerImpl::JSONIOHandlerImpl(
379386 , m_fileFormat{format}
380387 , m_originalExtension{std::move (originalExtension)}
381388{
382- std::tie (m_mode, m_IOModeSpecificationVia) = retrieveDatasetMode (config);
389+ std::tie (
390+ m_mode, m_IOModeSpecificationVia, m_printedSkippedWriteWarningAlready) =
391+ retrieveDatasetMode (config);
383392 std::tie (m_attributeMode, m_attributeModeSpecificationVia) =
384393 retrieveAttributeMode (config);
385394
@@ -403,7 +412,9 @@ JSONIOHandlerImpl::JSONIOHandlerImpl(
403412 , m_fileFormat{format}
404413 , m_originalExtension{std::move (originalExtension)}
405414{
406- std::tie (m_mode, m_IOModeSpecificationVia) = retrieveDatasetMode (config);
415+ std::tie (
416+ m_mode, m_IOModeSpecificationVia, m_printedSkippedWriteWarningAlready) =
417+ retrieveDatasetMode (config);
407418 std::tie (m_attributeMode, m_attributeModeSpecificationVia) =
408419 retrieveAttributeMode (config);
409420
@@ -548,7 +559,13 @@ void JSONIOHandlerImpl::createDataset(
548559 parameter.options , /* considerFiles = */ false );
549560 // Retrieves mode from dataset-specific configuration, falls back to global
550561 // value if not defined
551- IOMode localMode = retrieveDatasetMode (config).first ;
562+ auto [localMode, _, skipWarnings] = retrieveDatasetMode (config);
563+ (void )_;
564+ // No use in introducing logic to skip warnings only for one particular
565+ // dataset. If warnings are skipped, then they are skipped consistently.
566+ // Use |= since `false` is the default value and we don't wish to reset
567+ // the flag.
568+ m_printedSkippedWriteWarningAlready |= skipWarnings;
552569
553570 parameter.warnUnusedParameters (
554571 config,
@@ -1183,9 +1200,14 @@ void JSONIOHandlerImpl::writeDataset(
11831200 case IOMode::Dataset:
11841201 break ;
11851202 case IOMode::Template:
1186- std::cerr << " [JSON/TOML backend: Warning] Trying to write data to a "
1187- " template dataset. Will skip."
1188- << std::endl;
1203+ if (!m_printedSkippedWriteWarningAlready)
1204+ {
1205+ std::cerr
1206+ << " [JSON/TOML backend: Warning] Trying to write data to a "
1207+ " template dataset. Will skip."
1208+ << std::endl;
1209+ m_printedSkippedWriteWarningAlready = true ;
1210+ }
11891211 return ;
11901212 }
11911213
0 commit comments