diff --git a/src/IO/JSON/JSONIOHandlerImpl.cpp b/src/IO/JSON/JSONIOHandlerImpl.cpp index e5db1ef2c6..8ffb33a7f9 100644 --- a/src/IO/JSON/JSONIOHandlerImpl.cpp +++ b/src/IO/JSON/JSONIOHandlerImpl.cpp @@ -386,6 +386,20 @@ JSONIOHandlerImpl::JSONIOHandlerImpl( , m_fileFormat{format} , m_originalExtension{std::move(originalExtension)} { + // set the defaults + switch (m_fileFormat) + { + case FileFormat::Json: + // @todo take the switch to openPMD 2.0 as a chance to switch to + // short attribute mode as a default here + m_attributeMode = AttributeMode::Long; + m_mode = IOMode::Dataset; + break; + case FileFormat::Toml: + m_attributeMode = AttributeMode::Short; + m_mode = IOMode::Template; + break; + } std::tie( m_mode, m_IOModeSpecificationVia, m_printedSkippedWriteWarningAlready) = retrieveDatasetMode(config); diff --git a/test/SerialIOTest.cpp b/test/SerialIOTest.cpp index 93a233da75..e0286418f9 100644 --- a/test/SerialIOTest.cpp +++ b/test/SerialIOTest.cpp @@ -1241,7 +1241,12 @@ inline void dtype_test( "../samples/dtype_test." + backend, Access::CREATE, activateTemplateMode.value()) - : Series("../samples/dtype_test." + backend, Access::CREATE); + : + // test TOML long attribute mode by default + Series( + "../samples/dtype_test." + backend, + Access::CREATE, + R"({"toml":{"attribute":{"mode":"long"}}})"); bool adios1 = s.backend() == "ADIOS1" || s.backend() == "MPI_ADIOS1"; char c = 'c'; @@ -1836,7 +1841,8 @@ inline void fileBased_write_test(const std::string &backend) { Series o = Series( "../samples/subdir/serial_fileBased_write%03T." + backend, - Access::CREATE); + Access::CREATE, + R"({"toml":{"dataset":{"mode":"dataset"}}})"); ParticleSpecies &e_1 = o.iterations[1].particles["e"]; @@ -7397,7 +7403,10 @@ void groupbased_read_write(std::string const &ext) std::string filename = "../samples/groupbased_read_write." + ext; { - Series write(filename, Access::CREATE); + Series write( + filename, + Access::CREATE, + R"({"toml":{"dataset":{"mode":"dataset"}}})"); auto E_x = write.iterations[0].meshes["E"]["x"]; auto E_y = write.iterations[0].meshes["E"]["y"]; E_x.resetDataset(ds); @@ -7410,7 +7419,10 @@ void groupbased_read_write(std::string const &ext) } { - Series write(filename, Access::READ_WRITE); + Series write( + filename, + Access::READ_WRITE, + R"({"toml":{"dataset":{"mode":"dataset"}}})"); // create a new iteration auto E_x = write.iterations[1].meshes["E"]["x"]; E_x.resetDataset(ds); @@ -7450,7 +7462,10 @@ void groupbased_read_write(std::string const &ext) // check that truncation works correctly { - Series write(filename, Access::CREATE); + Series write( + filename, + Access::CREATE, + R"({"toml":{"dataset":{"mode":"dataset"}}})"); // create a new iteration auto E_x = write.iterations[2].meshes["E"]["x"]; E_x.resetDataset(ds);