Skip to content

Commit b909160

Browse files
committed
EXODUS: Fixing group usage
1 parent a980da1 commit b909160

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

packages/seacas/libraries/exodus/src/ex_copy.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ int ex_copy_transient(int in_exoid, int out_exoid)
176176
static int cpy_variable_data(int in_exoid, int out_exoid, int in_large, int mesh_only)
177177
{
178178
int nvars; /* number of variables */
179+
/* NOTE: This is incorrect for files containing groups */
179180
EXCHECKI(nc_inq(in_exoid, NULL, &nvars, NULL, NULL));
180181
for (int varid = 0; varid < nvars; varid++) {
181182
bool is_filtered;
@@ -216,6 +217,7 @@ static int cpy_variables(int in_exoid, int out_exoid, int in_large, int mesh_onl
216217
{
217218
int recdimid; /* id of unlimited dimension */
218219
int nvars; /* number of variables */
220+
/* NOTE: This is incorrect for files containing groups */
219221
EXCHECKI(nc_inq(in_exoid, NULL, &nvars, NULL, &recdimid));
220222
for (int varid = 0; varid < nvars; varid++) {
221223
struct ncvar var; /* variable */
@@ -259,6 +261,7 @@ static int cpy_dimension(int in_exoid, int out_exoid, int mesh_only)
259261

260262
int ndims; /* number of dimensions */
261263
int recdimid; /* id of unlimited dimension */
264+
/* NOTE: This is incorrect for files containing groups */
262265
EXCHECKI(nc_inq(in_exoid, &ndims, NULL, NULL, &recdimid));
263266
for (int dimid = 0; dimid < ndims; dimid++) {
264267

@@ -344,6 +347,7 @@ static int cpy_global_att(int in_exoid, int out_exoid)
344347
struct ncatt att; /* attribute */
345348

346349
int ngatts;
350+
/* NOTE: This is incorrect for files containing groups */
347351
EXCHECKI(nc_inq(in_exoid, NULL, NULL, &ngatts, NULL));
348352

349353
/* copy global attributes */

packages/seacas/libraries/exodus/src/ex_get_group_id.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,20 @@ int ex_get_group_id(int parent_id, const char *group_name, int *group_id)
4040
"group in file id %d",
4141
group_name, parent_id);
4242
ex_err_fn(parent_id, __func__, errmsg, status);
43+
*group_id = 0;
4344
EX_FUNC_LEAVE(EX_FATAL);
4445
}
4546
}
4647
else {
4748
/* Full path name */
48-
int status = nc_inq_grp_full_ncid(parent_id, group_name, group_id);
49+
int rootid = parent_id & EX_FILE_ID_MASK;
50+
int status = nc_inq_grp_full_ncid(rootid, group_name, group_id);
4951
if (status != NC_NOERR) {
5052
snprintf(errmsg, MAX_ERR_LENGTH,
5153
"ERROR: Failed to locate group with full path name %s in file id %d", group_name,
5254
parent_id);
5355
ex_err_fn(parent_id, __func__, errmsg, status);
56+
*group_id = 0;
5457
EX_FUNC_LEAVE(EX_FATAL);
5558
}
5659
}
@@ -64,6 +67,7 @@ int ex_get_group_id(int parent_id, const char *group_name, int *group_id)
6467
"ERROR: Group capabilities are not available in this netcdf "
6568
"version--not netcdf4");
6669
ex_err_fn(parent_id, __func__, errmsg, NC_ENOTNC4);
70+
*group_id = 0;
6771
EX_FUNC_LEAVE(EX_FATAL);
6872
#endif
6973
}

packages/seacas/libraries/exodus/src/ex_get_init_ext.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,16 @@
2626

2727
static void exi_get_entity_count(int exoid, ex_init_params *info)
2828
{
29-
int ndims;
30-
int include_parent_group = 1;
29+
int include_parent_group = 0; // Only want dims in current group
30+
int ndims = 0;
3131
nc_inq_dimids(exoid, &ndims, NULL, include_parent_group);
32+
int *dimids = calloc(ndims, sizeof(int));
33+
nc_inq_dimids(exoid, &ndims, dimids, include_parent_group);
34+
3235
for (int dimid = 0; dimid < ndims; dimid++) {
3336
char dim_nm[NC_MAX_NAME + 1] = {'\0'};
3437
size_t dim_sz;
35-
nc_inq_dim(exoid, dimid, dim_nm, &dim_sz);
38+
nc_inq_dim(exoid, dimids[dimid], dim_nm, &dim_sz);
3639
/* For assemblies, we check for a dim starting with "num_entity_assembly" */
3740
if (strncmp(dim_nm, "num_entity_assembly", 19) == 0) {
3841
info->num_assembly++;
@@ -41,6 +44,7 @@ static void exi_get_entity_count(int exoid, ex_init_params *info)
4144
info->num_blob++;
4245
}
4346
}
47+
free(dimids);
4448
}
4549

4650
/* Used to reduce repeated code below */

packages/seacas/libraries/ioss/src/main/io_shell.C

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,11 +260,12 @@ namespace {
260260
}
261261

262262
if (!interFace.groupName.empty()) {
263-
bool success = dbi->open_group(interFace.groupName);
263+
std::string group_path = "/" + interFace.groupName;
264+
bool success = dbi->open_group(group_path);
264265
if (!success) {
265266
if (rank == 0) {
266267
fmt::print(stderr, "ERROR: Unable to open group '{}' in file '{}'\n",
267-
interFace.groupName, inpfile);
268+
group_path, inpfile);
268269
}
269270
return;
270271
}

0 commit comments

Comments
 (0)