Skip to content

Commit

Permalink
EXODUS: slight refactor of redef/leavedef calls
Browse files Browse the repository at this point in the history
During the file open, it is not possible to call the `exi_find_file`
since the file has not yet been placed in that structure.

Not sure how it works on most of the tests...
  • Loading branch information
gdsjaar committed Jul 18, 2024
1 parent d828356 commit c60359f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions packages/seacas/libraries/exodus/src/ex_open.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright(C) 1999-2023 National Technology & Engineering Solutions
* Copyright(C) 1999-2024 National Technology & Engineering Solutions
* of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
* NTESS, the U.S. Government retains certain rights in this software.
*
Expand Down Expand Up @@ -298,7 +298,8 @@ int ex_open_int(const char *path, int mode, int *comp_ws, int *io_ws, float *ver
int dim_str_name = 0;
int stat_dim = nc_inq_dimid(exoid, DIM_STR_NAME, &dim_str_name);
if (stat_att != NC_NOERR || stat_dim != NC_NOERR) {
if ((status = exi_redef(exoid, __func__)) != NC_NOERR) {
/* This must still be nc_redef */
if ((status = nc_redef(exoid)) != NC_NOERR) {
snprintf(errmsg, MAX_ERR_LENGTH,
"ERROR: failed to place file id %d named %s into define mode", exoid, canon_path);
ex_err_fn(exoid, __func__, errmsg, status);
Expand Down Expand Up @@ -332,7 +333,7 @@ int ex_open_int(const char *path, int mode, int *comp_ws, int *io_ws, float *ver
EX_FUNC_LEAVE(EX_FATAL);
}
}
if ((status = exi_leavedef(exoid, __func__)) != NC_NOERR) {
if ((status = nc_enddef(exoid)) != NC_NOERR) {
snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to exit define mode in file id %d", exoid);
ex_err_fn(exoid, __func__, errmsg, status);
free(canon_path);
Expand Down
4 changes: 2 additions & 2 deletions packages/seacas/libraries/exodus/src/ex_open_par.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ int ex_open_par_int(const char *path, int mode, int *comp_ws, int *io_ws, float
int stat_dim = nc_inq_dimid(exoid, DIM_STR_NAME, &dim_str_name);
if (stat_att != NC_NOERR || stat_dim != NC_NOERR) {
if (!in_redef) {
if ((status = exi_redef(exoid, __func__)) != NC_NOERR) {
if ((status = nc_redef(exoid)) != NC_NOERR) {
snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to put file id %d into define mode",
exoid);
ex_err_fn(exoid, __func__, errmsg, status);
Expand All @@ -359,7 +359,7 @@ int ex_open_par_int(const char *path, int mode, int *comp_ws, int *io_ws, float
}

if (in_redef) {
if ((status = exi_leavedef(exoid, __func__)) != NC_NOERR) {
if ((status = nc_enddef(exoid)) != NC_NOERR) {
free(canon_path);
EX_FUNC_LEAVE(EX_FATAL);
}
Expand Down

0 comments on commit c60359f

Please sign in to comment.