Skip to content

Commit

Permalink
IOSS: fix thread-safe group/change_set handling
Browse files Browse the repository at this point in the history
  • Loading branch information
gdsjaar committed Nov 13, 2024
1 parent 45cd431 commit a3b7f5d
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 23 deletions.
40 changes: 20 additions & 20 deletions packages/seacas/libraries/ioss/src/main/io_shell.C
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ namespace {
return options;
}

bool open_change_set(const std::string &cs_name, Ioss::DatabaseIO *db, int rank)
bool open_change_set(const std::string &cs_name, Ioss::Region &region, int rank)
{
bool success = true;
if (!cs_name.empty()) {
success = db->open_internal_change_set(cs_name);
success = region.load_internal_change_set_mesh(cs_name);
if (!success) {
if (rank == 0) {
fmt::print(stderr, "ERROR: Unable to open change_set '{}' in file '{}'\n", cs_name,
db->get_filename());
region.get_database()->get_filename());
}
}
}
Expand Down Expand Up @@ -278,17 +278,17 @@ namespace {
dbi->set_block_omissions(interFace.omitted_blocks, inclusions);
}

// NOTE: 'region' owns 'db' pointer at this time...
Ioss::Region region(dbi, "region_1");

// Change_set specified... We will read the specified changeSet from the input file
if (!interFace.changeSetName.empty()) {
bool success = open_change_set(interFace.changeSetName, dbi, rank);
bool success = open_change_set(interFace.changeSetName, region, rank);
if (!success) {
return;
}
}

// NOTE: 'region' owns 'db' pointer at this time...
Ioss::Region region(dbi, "region_1");

if (region.mesh_type() == Ioss::MeshType::HYBRID) {
if (rank == 0) {
fmt::print(stderr,
Expand Down Expand Up @@ -599,31 +599,31 @@ namespace {
dbi2->set_int_byte_size_api(Ioss::USE_INT64_API);
}

// NOTE: 'input_region2' owns 'dbi2' pointer at this time...
Ioss::Region input_region2(dbi2, "region_2");

if (input_region2.mesh_type() == Ioss::MeshType::HYBRID) {
fmt::print(stderr,
"\nERROR: io_shell does not support '{}' meshes. Only 'Unstructured' or "
"'Structured' mesh is supported at this time.\n",
input_region2.mesh_type_string());
return false;
}

{
bool success = open_change_set(interFace.changeSetName, dbi1, rank);
bool success = open_change_set(interFace.changeSetName, input_region1, rank);
if (!success) {
return false;
}
}

{
bool success = open_change_set(interFace.changeSetName, dbi2, rank);
bool success = open_change_set(interFace.changeSetName, input_region2, rank);
if (!success) {
return false;
}
}

// NOTE: 'input_region2' owns 'dbi2' pointer at this time...
Ioss::Region input_region2(dbi2, "region_2");

if (input_region2.mesh_type() == Ioss::MeshType::HYBRID) {
fmt::print(stderr,
"\nERROR: io_shell does not support '{}' meshes. Only 'Unstructured' or "
"'Structured' mesh is supported at this time.\n",
input_region2.mesh_type_string());
return false;
}

// Get integer size being used on input file #1 and set it in
// the interFace.
int_byte_size_api = dbi2->int_byte_size_api();
Expand Down
22 changes: 19 additions & 3 deletions packages/seacas/libraries/ioss/src/main/io_shell_ts.C
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,22 @@ namespace {

template <typename INT>
void set_owned_node_count(Ioss::Region &region, int my_processor, INT dummy);

bool open_change_set(const std::string &cs_name, Ioss::Region &region, int rank)
{
bool success = true;
if (!cs_name.empty()) {
success = region.load_internal_change_set_mesh(cs_name);
if (!success) {
if (rank == 0) {
fmt::print(stderr, "ERROR: Unable to open change_set '{}' in file '{}'\n", cs_name,
region.get_database()->get_filename());
}
}
}
return success;
}

} // namespace
// ========================================================================

Expand Down Expand Up @@ -217,12 +233,12 @@ namespace {
dbi->set_int_byte_size_api(Ioss::USE_INT64_API);
}

if (!interFace.groupName.empty()) {
bool success = dbi->open_internal_change_set(interFace.groupName);
if (!interFace.changeSetName.empty()) {
bool success = open_change_set(interFace.changeSetName, region, rank);
if (!success) {
if (rank == 0) {
fmt::print(stderr, "ERROR: Unable to open group '{}' in file '{}'\n",
interFace.groupName, inpfile);
interFace.changeSetName, inpfile);
}
return;
}
Expand Down

0 comments on commit a3b7f5d

Please sign in to comment.