Skip to content

Commit

Permalink
IOSS: Add test of file grouping / ungrouping
Browse files Browse the repository at this point in the history
  • Loading branch information
gdsjaar committed Oct 14, 2024
1 parent 27d3203 commit 624fda5
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 12 deletions.
29 changes: 29 additions & 0 deletions packages/seacas/libraries/ioss/src/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,35 @@ TRIBITS_ADD_ADVANCED_TEST(exodus32_to_exodus32
XHOSTTYPE Windows
)

SET(IOSHELL_ARG --split_times 1 --in_type generated 10x10x10+shell:xXyYzZ+times:4+variables:element,2,nodal,3)
TRIBITS_ADD_ADVANCED_TEST(
io_shell_group_ungroup
TEST_0 NOEXEPREFIX NOEXESUFFIX EXEC io_shell ARGS ${IOSHELL_ARG} splits.g
TEST_1 NOEXEPREFIX NOEXESUFFIX EXEC io_shell ARGS splits.g_1 splits.g_2 splits.g_3 splits.g_4 grouped.g
TEST_2 NOEXEPREFIX NOEXESUFFIX EXEC io_shell ARGS --extract_group splits.g_1 grouped.g split-extract.g_1
TEST_3 NOEXEPREFIX NOEXESUFFIX EXEC io_shell ARGS --extract_group splits.g_2 grouped.g split-extract.g_2
TEST_4 NOEXEPREFIX NOEXESUFFIX EXEC io_shell ARGS --extract_group splits.g_3 grouped.g split-extract.g_3
TEST_5 NOEXEPREFIX NOEXESUFFIX EXEC io_shell ARGS --extract_group splits.g_4 grouped.g split-extract.g_4
TEST_6 EXEC exodiff ARGS -pedantic splits.g_1 split-extract.g_1
DIRECTORY ../../../../applications/exodiff
NOEXEPREFIX NOEXESUFFIX
NUM_MPI_PROCS 1
TEST_7 EXEC exodiff ARGS -pedantic splits.g_2 split-extract.g_2
DIRECTORY ../../../../applications/exodiff
NOEXEPREFIX NOEXESUFFIX
NUM_MPI_PROCS 1
TEST_8 EXEC exodiff ARGS -pedantic splits.g_3 split-extract.g_3
DIRECTORY ../../../../applications/exodiff
NOEXEPREFIX NOEXESUFFIX
NUM_MPI_PROCS 1
TEST_9 EXEC exodiff ARGS -pedantic splits.g_4 split-extract.g_4
DIRECTORY ../../../../applications/exodiff
NOEXEPREFIX NOEXESUFFIX
NUM_MPI_PROCS 1
COMM serial
FINAL_PASS_REGULAR_EXPRESSION
)

if (TPL_ENABLE_MPI)
IF (TPL_Netcdf_PARALLEL)
TRIBITS_ADD_ADVANCED_TEST(exodus_fpp_serialize
Expand Down
41 changes: 29 additions & 12 deletions packages/seacas/libraries/ioss/src/main/io_shell.C
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ namespace {
{
Ioss::PropertyManager properties = set_properties(interFace);

bool first = true;
for (const auto &inpfile : interFace.inputFile) {

//========================================================================
Expand Down Expand Up @@ -260,8 +259,16 @@ namespace {
}

if (!interFace.groupName.empty()) {
std::string group_path = "/" + interFace.groupName;
bool success = dbi->open_group(group_path);
bool success = dbi->open_root_group();
if (!success) {
if (rank == 0) {
fmt::print(stderr, "ERROR: Unable to open root group in file '{}'\n",
inpfile);
}
return;
}
std::string group_path = interFace.groupName;
success = dbi->open_group(group_path);
if (!success) {
if (rank == 0) {
fmt::print(stderr, "ERROR: Unable to open group '{}' in file '{}'\n", group_path,
Expand Down Expand Up @@ -356,15 +363,25 @@ namespace {
if (interFace.inputFile.size() > 1) {
properties.add(Ioss::Property("APPEND_OUTPUT", Ioss::DB_APPEND_GROUP));

if (!first) {
// Putting each file into its own output group...
// The name of the group will be the basename portion of the filename...
Ioss::FileInfo file(inpfile);
dbo->create_subgroup(file.tailname());
}
else {
first = false;
}
bool success = dbo->open_root_group();
if (!success) {
if (rank == 0) {
fmt::print(stderr, "ERROR: Unable to open root group in output file.\n");
}
return;
}

// Putting each file into its own output group...
// The name of the group will be the basename portion of the filename...
Ioss::FileInfo file(inpfile);
success = dbo->create_subgroup(file.tailname());
if (!success) {
if (rank == 0) {
fmt::print(stderr, "ERROR: Unable to create group {} in output file.\n",
file.tailname());
}
return;
}
}

// Do normal copy...
Expand Down

0 comments on commit 624fda5

Please sign in to comment.