From 26a20ce47575365181f24bcfab062ef7ce87b88a Mon Sep 17 00:00:00 2001 From: Seacas Upstream <kwrobot@kitware.com> Date: Mon, 8 Oct 2018 13:18:05 -0400 Subject: [PATCH] exodusII 2018-10-08 (226af280) Code extracted from: https://gitlab.kitware.com/third-party/seacas.git at commit 226af280af9eca955698bb87dec617beed1133b7 (for/vtk-20181008-7.15f-master). --- CMakeLists.txt | 17 +-- README | 2 +- include/exodusII.h | 4 +- include/exodusII_int.h | 4 +- src/deprecated/ex_put_concat_node_sets.c | 3 +- src/deprecated/ex_put_elem_var.c | 3 +- src/deprecated/ex_put_elem_var_tab.c | 3 +- src/ex_conv.c | 7 +- src/ex_copy.c | 4 +- src/ex_create.c | 29 +--- src/ex_create_par.c | 63 ++++---- src/ex_err.c | 34 +++-- src/ex_get_block_param.c | 19 ++- src/ex_get_coord.c | 2 +- src/ex_get_glob_vars_int.c | 13 -- src/ex_get_init_ext.c | 2 +- src/ex_get_map.c | 3 +- src/ex_get_nodal_var_int.c | 13 -- src/ex_get_partial_coord.c | 2 +- src/ex_get_partial_nodal_var_int.c | 13 -- src/ex_get_partial_var.c | 13 -- src/ex_get_side_set_node_list.c | 30 ++-- src/ex_get_time.c | 13 -- src/ex_get_var.c | 13 -- src/ex_ne_util.c | 6 +- src/ex_put_all_var_param_ext.c | 178 +++++++++++++++-------- src/ex_put_block_params.c | 43 +++--- src/ex_put_info.c | 16 +- src/ex_put_init_ext.c | 20 ++- src/ex_put_map.c | 3 +- src/ex_put_names.c | 12 +- src/ex_put_partial_set.c | 3 +- src/ex_put_partial_var.c | 15 -- src/ex_put_prop.c | 3 +- src/ex_put_prop_array.c | 3 +- src/ex_put_prop_names.c | 3 +- src/ex_put_qa.c | 36 +++-- src/ex_put_var.c | 15 -- src/ex_utils.c | 75 +++++----- 39 files changed, 332 insertions(+), 408 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 73606f9521b..025abc43e0a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -297,19 +297,14 @@ set(headers "${CMAKE_CURRENT_BINARY_DIR}/include/exodusII_cfg.h" "${CMAKE_CURRENT_BINARY_DIR}/include/exodus_config.h") -vtk_add_library(vtkexodusII ${sources} ${headers}) -target_link_libraries(vtkexodusII PUBLIC ${vtknetcdf_LIBRARIES}) -if (NOT VTK_INSTALL_NO_DEVELOPMENT) - install(FILES - ${headers} - DESTINATION "${VTK_INSTALL_INCLUDE_DIR}/vtkexodusII/include" - COMPONENT Development) -endif() - -target_compile_definitions(vtkexodusII +vtk_module_add_module(VTK::exodusII + SOURCES ${sources} + HEADERS ${headers} + HEADERS_SUBDIR "vtkexodusII/include") +target_compile_definitions(exodusII PRIVATE exoIIc_EXPORTS) -target_include_directories(vtkexodusII +target_include_directories(exodusII PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>" "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>") diff --git a/README b/README index ad5473c7ce6..9db9eef34dd 100644 --- a/README +++ b/README @@ -2,7 +2,7 @@ CONTACT: Greg Sjaardema, -Sandia-2017 National Laboratories, +Sandia National Laboratories, gdsjaar@sandia.gov ======================================================================== diff --git a/include/exodusII.h b/include/exodusII.h index 8fc66fe8527..6ba6fd6ce97 100644 --- a/include/exodusII.h +++ b/include/exodusII.h @@ -72,8 +72,8 @@ #endif /* EXODUS version number */ -#define EX_API_VERS 7.13f -#define EX_API_VERS_NODOT 713 +#define EX_API_VERS 7.15f +#define EX_API_VERS_NODOT 715 #define EX_VERS EX_API_VERS #define NEMESIS_API_VERSION EX_API_VERS #define NEMESIS_API_VERSION_NODOT EX_API_VERS_NODOT diff --git a/include/exodusII_int.h b/include/exodusII_int.h index f98f890f915..5a2301d5440 100644 --- a/include/exodusII_int.h +++ b/include/exodusII_int.h @@ -722,7 +722,7 @@ struct ex_file_item unsigned int file_type : 2; /* 0 - classic, 1 -- 64 bit classic, 2 --netcdf4, 3 --netcdf4 classic */ unsigned int is_parallel : 1; /* 1 true, 0 false */ - unsigned int is_mpiio : 1; /* 1 true, 0 false */ + unsigned int is_hdf5 : 1; /* 1 true, 0 false */ unsigned int is_pnetcdf : 1; /* 1 true, 0 false */ unsigned int has_nodes : 1; /* for input only at this time */ unsigned int has_edges : 1; /* for input only at this time */ @@ -774,7 +774,7 @@ char *ex_name_var_of_object(ex_entity_type /*obj_type*/, int /*i*/, int /*j*/); char *ex_name_of_map(ex_entity_type /*map_type*/, int /*map_index*/); int ex_conv_ini(int exoid, int *comp_wordsize, int *io_wordsize, int file_wordsize, - int int64_status, int is_parallel, int is_mpiio, int is_pnetcdf); + int int64_status, int is_parallel, int is_hdf5, int is_pnetcdf); void ex_conv_exit(int exoid); nc_type nc_flt_code(int exoid); diff --git a/src/deprecated/ex_put_concat_node_sets.c b/src/deprecated/ex_put_concat_node_sets.c index eddc38d7c91..0720cc92b2d 100644 --- a/src/deprecated/ex_put_concat_node_sets.c +++ b/src/deprecated/ex_put_concat_node_sets.c @@ -47,8 +47,7 @@ node sets. ``Concatenated node sets'' refers to the arrays required to define all of the node sets (ID array, counts arrays, pointers arrays, node list array, and distribution factors array) as described in Section 3.10 on page 11. Writing concatenated node sets is more -efficient than writing individual node sets. See #Efficiency for a -discussion of efficiency issues. +efficient than writing individual node sets. Because the distribution factors are floating point values, the application code must declare the array passed to be the appropriate diff --git a/src/deprecated/ex_put_elem_var.c b/src/deprecated/ex_put_elem_var.c index 61280f03cc0..70a2e5b5d5a 100644 --- a/src/deprecated/ex_put_elem_var.c +++ b/src/deprecated/ex_put_elem_var.c @@ -65,8 +65,7 @@ The function ex_put_elem_var() writes the values of a single element variable for one element block at one time step. It is recommended, but not required, to write the element variable truth table (with ex_put_elem_var_tab() before this function is invoked for better -efficiency. See #Efficiency for a discussion of -efficiency issues. +efficiency. Because element variables are floating point values, the application code must declare the array passed to be the appropriate type diff --git a/src/deprecated/ex_put_elem_var_tab.c b/src/deprecated/ex_put_elem_var_tab.c index 503e0793411..8f804263a0b 100644 --- a/src/deprecated/ex_put_elem_var_tab.c +++ b/src/deprecated/ex_put_elem_var_tab.c @@ -69,8 +69,7 @@ will be output. Although writing the element variable truth table is optional, it is encouraged because it creates at one time all the necessary ~~~{.c}{NetCDF} variables in which to hold the exodus element variable -values. This results in significant time savings. See -Section #Efficiency for a discussion of efficiency issues. +values. This results in significant time savings. The function ex_put_variable_param() must be called before this routine in order to define the number of element variables. diff --git a/src/ex_conv.c b/src/ex_conv.c index 003a35a3788..e61d39e3bab 100644 --- a/src/ex_conv.c +++ b/src/ex_conv.c @@ -111,7 +111,7 @@ void ex_check_valid_file_id(int exoid, const char *func) } int ex_conv_ini(int exoid, int *comp_wordsize, int *io_wordsize, int file_wordsize, - int int64_status, int is_parallel, int is_mpiio, int is_pnetcdf) + int int64_status, int is_parallel, int is_hdf5, int is_pnetcdf) { char errmsg[MAX_ERR_LENGTH]; struct ex_file_item *new_file; @@ -146,11 +146,10 @@ int ex_conv_ini(int exoid, int *comp_wordsize, int *io_wordsize, int file_wordsi * \param int64_status the flags specifying how integer values should be * stored on the database and how they should be * passes through the api functions. - * See #FileVars for more information. * * \param is_parallel 1 if parallel file; 0 if serial * - * \param is_mpiio 1 if parallel netcdf-4 mode; 0 if not. + * \param is_hdf5 1 if parallel netcdf-4 mode; 0 if not. * * \param is_pnetcdf 1 if parallel PNetCDF file; 0 if not. * @@ -239,7 +238,7 @@ int ex_conv_ini(int exoid, int *comp_wordsize, int *io_wordsize, int file_wordsi new_file->shuffle = 0; new_file->file_type = filetype - 1; new_file->is_parallel = is_parallel; - new_file->is_mpiio = is_mpiio; + new_file->is_hdf5 = is_hdf5; new_file->is_pnetcdf = is_pnetcdf; new_file->has_nodes = 1; /* default to yes in case not set */ new_file->has_edges = 1; diff --git a/src/ex_copy.c b/src/ex_copy.c index 1c29cdea4c6..649fbf268c3 100644 --- a/src/ex_copy.c +++ b/src/ex_copy.c @@ -371,7 +371,9 @@ int cpy_dimension(int in_exoid, int out_exoid, int mesh_only) /* If the dimension isn't one we specifically don't want * to copy (ie, number of QA or INFO records) and it * hasn't been defined, copy it */ - if (strcmp(dim_nm, DIM_NUM_QA) == 0 || strcmp(dim_nm, DIM_NUM_INFO) == 0) { + if (strcmp(dim_nm, DIM_NUM_QA) == 0 || strcmp(dim_nm, DIM_NUM_INFO) == 0 || + strcmp(dim_nm, DIM_N4) == 0 || strcmp(dim_nm, DIM_STR) == 0 || + strcmp(dim_nm, DIM_LIN) == 0) { is_filtered = 1; } else if (mesh_only == 1 && diff --git a/src/ex_create.c b/src/ex_create.c index 2c6ffc2825f..d3a4b60eab2 100644 --- a/src/ex_create.c +++ b/src/ex_create.c @@ -163,7 +163,6 @@ int ex_create_int(const char *path, int cmode, int *comp_ws, int *io_ws, int run { int exoid; int status; - int dimid; int old_fill; int lio_ws; int filesiz = 1; @@ -379,6 +378,7 @@ int ex_create_int(const char *path, int cmode, int *comp_ws, int *io_ws, int run #if NC_HAS_DISKLESS if (my_mode & EX_DISKLESS) { nc_mode |= NC_DISKLESS; + nc_mode |= NC_WRITE; } #endif @@ -492,33 +492,6 @@ int ex_create_int(const char *path, int cmode, int *comp_ws, int *io_ws, int run } } - /* define some dimensions and variables */ - - /* create string length dimension */ - if ((status = nc_def_dim(exoid, DIM_STR, (MAX_STR_LENGTH + 1), &dimid)) != NC_NOERR) { - snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define string length in file id %d", exoid); - ex_err(__func__, errmsg, status); - EX_FUNC_LEAVE(EX_FATAL); - } - - /* The name string length dimension is delayed until the ex_put_init function - */ - - /* create line length dimension */ - if ((status = nc_def_dim(exoid, DIM_LIN, (MAX_LINE_LENGTH + 1), &dimid)) != NC_NOERR) { - snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define line length in file id %d", exoid); - ex_err(__func__, errmsg, status); - EX_FUNC_LEAVE(EX_FATAL); - } - - /* create number "4" dimension; must be of type long */ - if ((status = nc_def_dim(exoid, DIM_N4, 4L, &dimid)) != NC_NOERR) { - snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define number \"4\" dimension in file id %d", - exoid); - ex_err(__func__, errmsg, status); - EX_FUNC_LEAVE(EX_FATAL); - } - { int int64_db_status = int64_status & EX_ALL_INT64_DB; if ((status = nc_put_att_int(exoid, NC_GLOBAL, ATT_INT64_STATUS, NC_INT, 1, diff --git a/src/ex_create_par.c b/src/ex_create_par.c index bf5bb447111..3fbb38f943e 100644 --- a/src/ex_create_par.c +++ b/src/ex_create_par.c @@ -169,7 +169,6 @@ int ex_create_par_int(const char *path, int cmode, int *comp_ws, int *io_ws, MPI { int exoid; int status; - int dimid; int old_fill; int lio_ws; int filesiz = 1; @@ -186,7 +185,7 @@ int ex_create_par_int(const char *path, int cmode, int *comp_ws, int *io_ws, MPI int int64_status; int pariomode = 0; - int is_mpiio = 0; + int is_hdf5 = 0; int is_pnetcdf = 0; unsigned int my_mode = cmode; @@ -319,11 +318,17 @@ int ex_create_par_int(const char *path, int cmode, int *comp_ws, int *io_ws, MPI /* Check parallel io mode. Valid is NC_MPIPOSIX or NC_MPIIO or NC_PNETCDF * Exodus uses different flag values; map to netcdf values + * + * NOTE: In curent versions of NetCDF, MPIPOSIX and MPIIO are ignored and the + * underlying format is either NC_PNETCDF or NC_NETCDF4 (hdf5-based) + * They map NC_MPIIO to NC_PNETCDF, but in the past, exodus mapped EX_MPIIO + * to EX_NETCDF4. */ { int tmp_mode = 0; if (my_mode & EX_MPIPOSIX) { - pariomode = NC_MPIPOSIX; + pariomode = NC_MPIIO; + is_hdf5 = 1; tmp_mode = EX_NETCDF4; #if !NC_HAS_HDF5 snprintf(errmsg, MAX_ERR_LENGTH, @@ -336,7 +341,7 @@ int ex_create_par_int(const char *path, int cmode, int *comp_ws, int *io_ws, MPI } else if (my_mode & EX_MPIIO) { pariomode = NC_MPIIO; - is_mpiio = 1; + is_hdf5 = 1; tmp_mode = EX_NETCDF4; #if !NC_HAS_HDF5 snprintf(errmsg, MAX_ERR_LENGTH, @@ -345,6 +350,19 @@ int ex_create_par_int(const char *path, int cmode, int *comp_ws, int *io_ws, MPI "have that option enabled.\n"); ex_err(__func__, errmsg, EX_BADPARAM); EX_FUNC_LEAVE(EX_FATAL); +#endif + } + else if (my_mode & EX_NETCDF4) { + pariomode = NC_MPIIO; + is_hdf5 = 1; + tmp_mode = EX_NETCDF4; +#if !NC_HAS_HDF5 + snprintf(errmsg, MAX_ERR_LENGTH, + "EXODUS: ERROR: EX_NETCDF4 parallel output requested which " + "requires NetCDF-4 support, but the library does not " + "have that option enabled.\n"); + ex_err(__func__, errmsg, EX_BADPARAM); + EX_FUNC_LEAVE(EX_FATAL); #endif } else if (my_mode & EX_PNETCDF) { @@ -452,6 +470,14 @@ int ex_create_par_int(const char *path, int cmode, int *comp_ws, int *io_ws, MPI mode_name = "NOCLOBBER"; } +#if NC_HAS_DISKLESS + /* Use of diskless (in-memory) and parallel is not tested... */ + if (my_mode & EX_DISKLESS) { + nc_mode |= NC_DISKLESS; + nc_mode |= NC_WRITE; + } +#endif + if ((status = nc_create_par(path, nc_mode | pariomode, comm, info, &exoid)) != NC_NOERR) { #if NC_HAS_HDF5 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: file create failed for %s, mode: %s", path, mode_name); @@ -502,7 +528,7 @@ int ex_create_par_int(const char *path, int cmode, int *comp_ws, int *io_ws, MPI /* initialize floating point size conversion. since creating new file, * i/o wordsize attribute from file is zero. */ - if (ex_conv_ini(exoid, comp_ws, io_ws, 0, int64_status, 1, is_mpiio, is_pnetcdf) != EX_NOERR) { + if (ex_conv_ini(exoid, comp_ws, io_ws, 0, int64_status, 1, is_hdf5, is_pnetcdf) != EX_NOERR) { snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to init conversion routines in file id %d", exoid); ex_err(__func__, errmsg, EX_LASTERR); @@ -563,33 +589,6 @@ int ex_create_par_int(const char *path, int cmode, int *comp_ws, int *io_ws, MPI } } - /* define some dimensions and variables */ - - /* create string length dimension */ - if ((status = nc_def_dim(exoid, DIM_STR, (MAX_STR_LENGTH + 1), &dimid)) != NC_NOERR) { - snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define string length in file id %d", exoid); - ex_err(__func__, errmsg, status); - EX_FUNC_LEAVE(EX_FATAL); - } - - /* The name string length dimension is delayed until the ex_put_init function - */ - - /* create line length dimension */ - if ((status = nc_def_dim(exoid, DIM_LIN, (MAX_LINE_LENGTH + 1), &dimid)) != NC_NOERR) { - snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define line length in file id %d", exoid); - ex_err(__func__, errmsg, status); - EX_FUNC_LEAVE(EX_FATAL); - } - - /* create number "4" dimension; must be of type long */ - if ((status = nc_def_dim(exoid, DIM_N4, 4L, &dimid)) != NC_NOERR) { - snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define number \"4\" dimension in file id %d", - exoid); - ex_err(__func__, errmsg, status); - EX_FUNC_LEAVE(EX_FATAL); - } - { int int64_db_status = int64_status & EX_ALL_INT64_DB; if ((status = nc_put_att_int(exoid, NC_GLOBAL, ATT_INT64_STATUS, NC_INT, 1, diff --git a/src/ex_err.c b/src/ex_err.c index f1dcb7ccc23..b1ded48d215 100644 --- a/src/ex_err.c +++ b/src/ex_err.c @@ -131,34 +131,42 @@ void ex_err(const char *module_name, const char *message, int err_num) EX_FUNC_VOID(); } + /* save the error message for replays */ + if (message != NULL) { + strncpy(EX_ERRMSG, message, MAX_ERR_LENGTH); + EX_ERRMSG[MAX_ERR_LENGTH - 1] = '\0'; + } + if (module_name != NULL) { + strncpy(EX_PNAME, module_name, MAX_ERR_LENGTH); + EX_PNAME[MAX_ERR_LENGTH - 1] = '\0'; + } + if (err_num == EX_PRTLASTMSG) { - fprintf(stderr, "[%s] %s\n", EX_PNAME, EX_ERRMSG); + fprintf(stderr, "\n[%s] %s\n", EX_PNAME, EX_ERRMSG); fprintf(stderr, " exerrval = %d\n", EX_ERR_NUM); EX_FUNC_VOID(); } + if (err_num == EX_LASTERR) { + err_num = EX_ERR_NUM; + } + else { + exerrval = err_num; + EX_ERR_NUM = err_num; + } + if (err_num == EX_NULLENTITY) { if (exoptval & EX_NULLVERBOSE) { - fprintf(stderr, "Exodus Library Warning: [%s]\n\t%s\n", module_name, message); + fprintf(stderr, "\nExodus Library Warning: [%s]\n\t%s\n", module_name, message); } } else if (exoptval & EX_VERBOSE) { /* check see if we really want to hear this */ - fprintf(stderr, "Exodus Library Warning/Error: [%s]\n\t%s\n", module_name, message); + fprintf(stderr, "\nExodus Library Warning/Error: [%s]\n\t%s\n", module_name, message); if (err_num < 0) { fprintf(stderr, "\t%s\n", ex_strerror(err_num)); } } - /* save the error message for replays */ - strncpy(EX_ERRMSG, message, MAX_ERR_LENGTH); - strncpy(EX_PNAME, module_name, MAX_ERR_LENGTH); - EX_ERRMSG[MAX_ERR_LENGTH - 1] = '\0'; - EX_PNAME[MAX_ERR_LENGTH - 1] = '\0'; - if (err_num != EX_LASTERR) { - exerrval = err_num; - EX_ERR_NUM = err_num; - } - fflush(stderr); /* with netCDF 3.4, (fatal) system error codes are > 0; diff --git a/src/ex_get_block_param.c b/src/ex_get_block_param.c index 3bd8d4324af..8180ea237f9 100644 --- a/src/ex_get_block_param.c +++ b/src/ex_get_block_param.c @@ -71,13 +71,13 @@ int ex_get_block_param(int exoid, ex_block *block) size_t len, i; char errmsg[MAX_ERR_LENGTH]; int status; - const char *dnument; - const char *dnumnod; - const char *dnumedg; - const char *dnumfac; - const char *dnumatt; - const char *ablknam; - const char *vblkcon; + const char *dnument = NULL; + const char *dnumnod = NULL; + const char *dnumedg = NULL; + const char *dnumfac = NULL; + const char *dnumatt = NULL; + const char *ablknam = NULL; + const char *vblkcon = NULL; struct ex_file_item *file = NULL; @@ -235,6 +235,11 @@ int ex_get_block_param(int exoid, ex_block *block) block->num_attribute = len; } + if (block->num_nodes_per_entry == 0 && block->num_edges_per_entry == 0 && + block->num_faces_per_entry == 0) { + vblkcon = NULL; + } + if (block->num_nodes_per_entry > 0) { ; /* Do nothing, vblkcon should be correctly set already */ } diff --git a/src/ex_get_coord.c b/src/ex_get_coord.c index 337d38a7b2d..343af1ca601 100644 --- a/src/ex_get_coord.c +++ b/src/ex_get_coord.c @@ -113,7 +113,7 @@ int ex_get_coord(int exoid, void *x_coor, void *y_coor, void *z_coor) /* inquire id's of previously defined dimensions */ - if (ex_get_dimension(exoid, DIM_NUM_DIM, "dimensions", &num_dim, &ndimdim, __func__) != + if (ex_get_dimension(exoid, DIM_NUM_DIM, "dimension count", &num_dim, &ndimdim, __func__) != NC_NOERR) { EX_FUNC_LEAVE(EX_FATAL); } diff --git a/src/ex_get_glob_vars_int.c b/src/ex_get_glob_vars_int.c index 2b4626deafe..f9f3a1cf136 100644 --- a/src/ex_get_glob_vars_int.c +++ b/src/ex_get_glob_vars_int.c @@ -78,19 +78,6 @@ int ex_get_glob_vars_int(int exoid, int time_step, int num_glob_vars, void *glob EX_FUNC_LEAVE(EX_WARN); } - /* Verify that time_step is within bounds */ - { - int num_time_steps = ex_inquire_int(exoid, EX_INQ_TIME); - if (time_step <= 0 || time_step > num_time_steps) { - snprintf(errmsg, MAX_ERR_LENGTH, - "ERROR: time_step is out-of-range. Value = %d, valid " - "range is 1 to %d in file id %d", - time_step, num_time_steps, exoid); - ex_err(__func__, errmsg, EX_BADPARAM); - EX_FUNC_LEAVE(EX_FATAL); - } - } - /* read values of global variables */ start[0] = --time_step; start[1] = 0; diff --git a/src/ex_get_init_ext.c b/src/ex_get_init_ext.c index 6a49ac433c9..3c90e2e6842 100644 --- a/src/ex_get_init_ext.c +++ b/src/ex_get_init_ext.c @@ -120,7 +120,7 @@ int ex_get_init_ext(int exoid, ex_init_params *info) info->num_elem_maps = 0; dimid = 0; - if (ex_get_dim_value(exoid, "dimensions", DIM_NUM_DIM, dimid, &info->num_dim) != EX_NOERR) { + if (ex_get_dim_value(exoid, "dimension count", DIM_NUM_DIM, dimid, &info->num_dim) != EX_NOERR) { EX_FUNC_LEAVE(EX_FATAL); } if (ex_get_dim_value(exoid, "nodes", DIM_NUM_NODES, dimid, &info->num_nodes) != EX_NOERR) { diff --git a/src/ex_get_map.c b/src/ex_get_map.c index a90473b0406..ed1ab2892b2 100644 --- a/src/ex_get_map.c +++ b/src/ex_get_map.c @@ -42,8 +42,7 @@ /*! The function ex_get_map() reads the element order map -from the database. See #ElementOrderMap for a description of the -element order map. If an element order map is not stored in the data +from the database. If an element order map is not stored in the data file, a default array (1,2,3,. .. num_elem) is returned. Memory must be allocated for the element map array ({num_elem} in length) before this call is made. diff --git a/src/ex_get_nodal_var_int.c b/src/ex_get_nodal_var_int.c index 69f0f36b872..00951e76f9d 100644 --- a/src/ex_get_nodal_var_int.c +++ b/src/ex_get_nodal_var_int.c @@ -116,19 +116,6 @@ int ex_get_nodal_var_int(int exoid, int time_step, int nodal_var_index, int64_t return (EX_NOERR); } - /* Verify that time_step is within bounds */ - { - int num_time_steps = ex_inquire_int(exoid, EX_INQ_TIME); - if (time_step <= 0 || time_step > num_time_steps) { - snprintf(errmsg, MAX_ERR_LENGTH, - "ERROR: time_step is out-of-range. Value = %d, valid " - "range is 1 to %d in file id %d", - time_step, num_time_steps, exoid); - ex_err(__func__, errmsg, EX_BADPARAM); - return (EX_FATAL); - } - } - if (ex_large_model(exoid) == 0) { /* read values of the nodal variable */ if ((status = nc_inq_varid(exoid, VAR_NOD_VAR, &varid)) != NC_NOERR) { diff --git a/src/ex_get_partial_coord.c b/src/ex_get_partial_coord.c index a0423ad335e..498c1773269 100644 --- a/src/ex_get_partial_coord.c +++ b/src/ex_get_partial_coord.c @@ -120,7 +120,7 @@ int ex_get_partial_coord(int exoid, int64_t start_node_num, int64_t num_nodes, v EX_FUNC_LEAVE(EX_FATAL); } - if (ex_get_dimension(exoid, DIM_NUM_DIM, "dimensions", &num_dim, &ndimdim, __func__) != + if (ex_get_dimension(exoid, DIM_NUM_DIM, "dimension count", &num_dim, &ndimdim, __func__) != NC_NOERR) { EX_FUNC_LEAVE(EX_FATAL); } diff --git a/src/ex_get_partial_nodal_var_int.c b/src/ex_get_partial_nodal_var_int.c index b4946cc2602..b8f7f8f80d0 100644 --- a/src/ex_get_partial_nodal_var_int.c +++ b/src/ex_get_partial_nodal_var_int.c @@ -80,19 +80,6 @@ int ex_get_partial_nodal_var_int(int exoid, int time_step, int nodal_var_index, EX_FUNC_ENTER(); ex_check_valid_file_id(exoid, __func__); - /* Verify that time_step is within bounds */ - { - int num_time_steps = ex_inquire_int(exoid, EX_INQ_TIME); - if (time_step <= 0 || time_step > num_time_steps) { - snprintf(errmsg, MAX_ERR_LENGTH, - "ERROR: time_step is out-of-range. Value = %d, valid " - "range is 1 to %d in file id %d", - time_step, num_time_steps, exoid); - ex_err(__func__, errmsg, EX_BADPARAM); - EX_FUNC_LEAVE(EX_FATAL); - } - } - if (ex_large_model(exoid) == 0) { /* read values of the nodal variable */ if ((status = nc_inq_varid(exoid, VAR_NOD_VAR, &varid)) != NC_NOERR) { diff --git a/src/ex_get_partial_var.c b/src/ex_get_partial_var.c index fde06e48192..8fca6a534f0 100644 --- a/src/ex_get_partial_var.c +++ b/src/ex_get_partial_var.c @@ -80,19 +80,6 @@ int ex_get_partial_var(int exoid, int time_step, ex_entity_type var_type, int va } #endif - /* Verify that time_step is within bounds */ - { - int num_time_steps = ex_inquire_int(exoid, EX_INQ_TIME); - if (time_step <= 0 || time_step > num_time_steps) { - snprintf(errmsg, MAX_ERR_LENGTH, - "ERROR: time_step is out-of-range. Value = %d, valid " - "range is 1 to %d in file id %d", - time_step, num_time_steps, exoid); - ex_err(__func__, errmsg, EX_BADPARAM); - EX_FUNC_LEAVE(EX_FATAL); - } - } - if (var_type == EX_NODAL) { /* FIXME: Special case: ignore obj_id, possible large_file complications, * etc. */ diff --git a/src/ex_get_side_set_node_list.c b/src/ex_get_side_set_node_list.c index edcafb927a8..4b82c70b8dc 100644 --- a/src/ex_get_side_set_node_list.c +++ b/src/ex_get_side_set_node_list.c @@ -101,8 +101,8 @@ int ex_get_side_set_node_list(int exoid, ex_entity_id side_set_id, void_int *sid void_int *elem_blk_ids = NULL; void_int *connect = NULL; void_int *ss_elem_ndx = NULL; - int64_t *ss_elem_node_ndx = NULL; - int64_t *ss_parm_ndx = NULL; + int64_t * ss_elem_node_ndx = NULL; + int64_t * ss_parm_ndx = NULL; void_int *side_set_elem_list = NULL; void_int *side_set_side_list = NULL; size_t elem_ctr, node_ctr, elem_num_pos; @@ -508,7 +508,7 @@ int ex_get_side_set_node_list(int exoid, ex_entity_id side_set_id, void_int *sid err_stat = EX_FATAL; goto cleanup; } - ss_parm_ndx[i] = j; /* assign parameter block index */ + ss_parm_ndx[i] = j; /* assign parameter block index */ ss_elem_node_ndx[i] = elem_blk_parms[j].num_nodes_per_side[side - 1]; /* Update node_ctr (which points to next node in chain */ @@ -526,8 +526,8 @@ int ex_get_side_set_node_list(int exoid, ex_entity_id side_set_id, void_int *sid err_stat = EX_WARN; } } - /* At this point, the `ss_elem_node_ndx` only contains the nodes per face. We now compute the exclusive scan - * to determine where the nodes will be put in the list for each face + /* At this point, the `ss_elem_node_ndx` only contains the nodes per face. We now compute the + * exclusive scan to determine where the nodes will be put in the list for each face */ if (ex_int64_status(exoid) & EX_BULK_INT64_API) { for (i = 0; i < tot_num_ss_elem; i++) { @@ -542,7 +542,7 @@ int ex_get_side_set_node_list(int exoid, ex_entity_id side_set_id, void_int *sid int64_t sum = 0; for (i = 0; i < tot_num_ss_elem; i++) { - int64_t cnt = ss_elem_node_ndx[i]; + int64_t cnt = ss_elem_node_ndx[i]; ss_elem_node_ndx[i] = sum; sum += cnt; } @@ -623,7 +623,7 @@ int ex_get_side_set_node_list(int exoid, ex_entity_id side_set_id, void_int *sid num_nodes_per_elem = elem_blk_parms[parm_ndx].num_nodes_per_elem; connect_offset = num_nodes_per_elem * elem_num_pos; side_num = side - 1; - node_pos = ss_elem_node_ndx[elem_ndx]; + node_pos = ss_elem_node_ndx[elem_ndx]; switch (elem_blk_parms[parm_ndx].elem_type_val) { case EX_EL_CIRCLE: @@ -650,7 +650,7 @@ int ex_get_side_set_node_list(int exoid, ex_entity_id side_set_id, void_int *sid connect_offset + tri_table[side_num][0] - 1); get_nodes(exoid, side_set_node_list, node_pos + 1, connect, connect_offset + tri_table[side_num][1] - 1); - if (num_nodes_per_elem > 3) /* 6-node TRI */ + if (num_nodes_per_elem > 3) /* 6-node TRI */ { get_nodes(exoid, side_set_node_list, node_pos + 2, connect, connect_offset + tri_table[side_num][2] - 1); @@ -665,7 +665,7 @@ int ex_get_side_set_node_list(int exoid, ex_entity_id side_set_id, void_int *sid connect_offset + tri3_table[side_num][0] - 1); get_nodes(exoid, side_set_node_list, node_pos + 1, connect, connect_offset + tri3_table[side_num][1] - 1); - if (side_num + 1 <= 2) /* 3, 4, 6, 7-node face */ + if (side_num + 1 <= 2) /* 3, 4, 6, 7-node face */ { if (num_nodes_per_elem == 3) /* 3-node face */ { @@ -747,8 +747,8 @@ int ex_get_side_set_node_list(int exoid, ex_entity_id side_set_id, void_int *sid connect_offset + shell_table[side_num][0] - 1); get_nodes(exoid, side_set_node_list, node_pos + 1, connect, connect_offset + shell_table[side_num][1] - 1); - if (num_nodes_per_elem > 2) { /*** KLUGE for 2D shells ***/ - if (side_num + 1 <= 2) { /* 4-node face */ + if (num_nodes_per_elem > 2) { /*** KLUGE for 2D shells ***/ + if (side_num + 1 <= 2) { /* 4-node face */ get_nodes(exoid, side_set_node_list, node_pos + 2, connect, connect_offset + shell_table[side_num][2] - 1); get_nodes(exoid, side_set_node_list, node_pos + 3, connect, @@ -756,7 +756,7 @@ int ex_get_side_set_node_list(int exoid, ex_entity_id side_set_id, void_int *sid } } if (num_nodes_per_elem == 8) { - if (side_num + 1 <= 2) { /* 8-node face */ + if (side_num + 1 <= 2) { /* 8-node face */ get_nodes(exoid, side_set_node_list, node_pos + 4, connect, connect_offset + shell_table[side_num][4] - 1); get_nodes(exoid, side_set_node_list, node_pos + 5, connect, @@ -772,7 +772,7 @@ int ex_get_side_set_node_list(int exoid, ex_entity_id side_set_id, void_int *sid } } if (num_nodes_per_elem == 9) { - if (side_num + 1 <= 2) { /* 9-node face */ + if (side_num + 1 <= 2) { /* 9-node face */ get_nodes(exoid, side_set_node_list, node_pos + 4, connect, connect_offset + shell_table[side_num][4] - 1); get_nodes(exoid, side_set_node_list, node_pos + 5, connect, @@ -992,7 +992,7 @@ int ex_get_side_set_node_list(int exoid, ex_entity_id side_set_id, void_int *sid get_nodes(exoid, side_set_node_list, node_pos++, connect, connect_offset + pyramid_table[side_num][2] - 1); - if (pyramid_table[side_num][3] == 0) { /* degenerate side? */ + if (pyramid_table[side_num][3] == 0) { /* degenerate side? */ } else { get_nodes(exoid, side_set_node_list, node_pos++, connect, @@ -1067,7 +1067,7 @@ int ex_get_side_set_node_list(int exoid, ex_entity_id side_set_id, void_int *sid connect_offset + hex_table[side_num][2] - 1); get_nodes(exoid, side_set_node_list, node_pos + 3, connect, connect_offset + hex_table[side_num][3] - 1); - if (num_nodes_per_elem > 12) /* more nodes than HEXSHELL */ + if (num_nodes_per_elem > 12) /* more nodes than HEXSHELL */ { get_nodes(exoid, side_set_node_list, node_pos + 4, connect, connect_offset + hex_table[side_num][4] - 1); diff --git a/src/ex_get_time.c b/src/ex_get_time.c index 587aec458d2..8e2b6de85f0 100644 --- a/src/ex_get_time.c +++ b/src/ex_get_time.c @@ -103,19 +103,6 @@ int ex_get_time(int exoid, int time_step, void *time_value) file->time_varid = varid; } - /* Verify that time_step is within bounds */ - { - int num_time_steps = ex_inquire_int(exoid, EX_INQ_TIME); - if (time_step <= 0 || time_step > num_time_steps) { - snprintf(errmsg, MAX_ERR_LENGTH, - "ERROR: time_step is out-of-range. Value = %d, valid " - "range is 1 to %d in file id %d", - time_step, num_time_steps, exoid); - ex_err(__func__, errmsg, EX_BADPARAM); - EX_FUNC_LEAVE(EX_FATAL); - } - } - /* read time value */ start[0] = --time_step; diff --git a/src/ex_get_var.c b/src/ex_get_var.c index c46779b2524..62aaca2a5b2 100644 --- a/src/ex_get_var.c +++ b/src/ex_get_var.c @@ -108,19 +108,6 @@ int ex_get_var(int exoid, int time_step, ex_entity_type var_type, int var_index, EX_FUNC_ENTER(); ex_check_valid_file_id(exoid, __func__); - /* Verify that time_step is within bounds */ - { - int num_time_steps = ex_inquire_int(exoid, EX_INQ_TIME); - if (time_step <= 0 || time_step > num_time_steps) { - snprintf(errmsg, MAX_ERR_LENGTH, - "ERROR: time_step is out-of-range. Value = %d, valid " - "range is 1 to %d in file id %d", - time_step, num_time_steps, exoid); - ex_err(__func__, errmsg, EX_BADPARAM); - EX_FUNC_LEAVE(EX_FATAL); - } - } - if (var_type == EX_NODAL) { /* FIXME: Special case: ignore obj_id, possible large_file complications, * etc. */ diff --git a/src/ex_ne_util.c b/src/ex_ne_util.c index 9e88865d28f..8ee74fb3e02 100644 --- a/src/ex_ne_util.c +++ b/src/ex_ne_util.c @@ -112,7 +112,7 @@ int ne_id_lkup(int exoid, const char *ne_var_name, int64_t *idx, ex_entity_id ne "in file ID %d", ne_var_name, exoid); ex_err(__func__, errmsg, status); - return (-1); + return (EX_FATAL); } /* Get the length of this variable */ @@ -121,7 +121,7 @@ int ne_id_lkup(int exoid, const char *ne_var_name, int64_t *idx, ex_entity_id ne "ERROR: failed to find dimension for variable \"%s\" in file ID %d", ne_var_name, exoid); ex_err(__func__, errmsg, status); - return (-1); + return (EX_FATAL); } idx[1] = length; @@ -139,7 +139,7 @@ int ne_id_lkup(int exoid, const char *ne_var_name, int64_t *idx, ex_entity_id ne snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable \"%s\" in file ID %d", ne_var_name, exoid); ex_err(__func__, errmsg, status); - return (-1); + return (EX_FATAL); } if (id_val == ne_var_id) { diff --git a/src/ex_put_all_var_param_ext.c b/src/ex_put_all_var_param_ext.c index 4aa50220e7f..260f7b03902 100644 --- a/src/ex_put_all_var_param_ext.c +++ b/src/ex_put_all_var_param_ext.c @@ -62,6 +62,11 @@ static int *get_status_array(int exoid, int var_count, const char *VARIABLE, con static int put_truth_table(int exoid, int varid, int *table, const char *label); static int define_truth_table(ex_entity_type obj_type, int exoid, int num_ent, int num_var, int *var_tab, int *status_tab, void_int *ids, const char *label); +static int ex_define_vars(int exoid, ex_entity_type obj_type, const char *entity_name, + const char *entity_blk_name, int numvar, const char *DNAME, int dimid1, + int dimid2, int DVAL, void_int **entity_ids, const char *VNOV, + const char *VTV, int **status_var, int *truth_table, + int *truth_table_var); #define EX_GET_IDS_STATUS(TNAME, NUMVAR, DNAME, DID, DVAL, VIDS, EIDS, VSTAT, VSTATVAL) \ if (NUMVAR > 0) { \ @@ -97,16 +102,17 @@ int ex_put_all_var_param_ext(int exoid, const ex_var_params *vp) int in_define = 0; int status; int temp; - int time_dim, num_nod_dim, dimid; + int time_dim = 0, num_nod_dim = 0, dimid = 0; size_t num_elem_blk, num_edge_blk, num_face_blk; size_t num_nset, num_eset, num_fset, num_sset, num_elset; - int numelblkdim, numelvardim, numedvardim, numedblkdim, numfavardim, numfablkdim, numnsetdim, - nsetvardim, numesetdim, esetvardim, numfsetdim, fsetvardim, numssetdim, ssetvardim, - numelsetdim, elsetvardim; + int numelblkdim = 0, numelvardim = 0, numedvardim = 0, numedblkdim = 0, numfavardim = 0, + numfablkdim = 0, numnsetdim = 0, nsetvardim = 0, numesetdim = 0, esetvardim = 0, + numfsetdim = 0, fsetvardim = 0, numssetdim = 0, ssetvardim = 0, numelsetdim = 0, + elsetvardim = 0; int i; - int edblk_varid, fablk_varid, eblk_varid, nset_varid, eset_varid, fset_varid, sset_varid, - elset_varid, varid; + int edblk_varid = 0, fablk_varid = 0, eblk_varid = 0, nset_varid = 0, eset_varid = 0, + fset_varid = 0, sset_varid = 0, elset_varid = 0, varid = 0; void_int *eblk_ids = NULL; void_int *edblk_ids = NULL; @@ -225,63 +231,61 @@ int ex_put_all_var_param_ext(int exoid, const ex_var_params *vp) } } -#define EX_DEFINE_VARS(TID, STNAME, TNAME, NUMVAR, DNAME, DID1, DID2, DVAL, VIDS, VNOV, VTV, \ - VSTATVAL, VTABVAL, VTABVAR) \ - if (NUMVAR > 0) { \ - status = define_dimension(exoid, DNAME, NUMVAR, STNAME, &DID2); \ - if (status != NC_NOERR) \ - goto error_ret; \ - \ - /* Now define STNAME variable name variable */ \ - if (define_variable_name_variable(exoid, VNOV, DID2, STNAME) != NC_NOERR) \ - goto error_ret; \ - \ - if (define_truth_table(TID, exoid, DVAL, NUMVAR, VTABVAL, VSTATVAL, VIDS, TNAME) != NC_NOERR) \ - goto error_ret; \ - \ - free(VSTATVAL); \ - VSTATVAL = NULL; \ - free(VIDS); \ - VIDS = NULL; \ - \ - /* create a variable array in which to store the STNAME variable truth \ - * table \ - */ \ - \ - dims[0] = DID1; \ - dims[1] = DID2; \ - \ - if ((status = nc_def_var(exoid, VTV, NC_INT, 2, dims, &VTABVAR)) != NC_NOERR) { \ - snprintf(errmsg, MAX_ERR_LENGTH, \ - "ERROR: failed to define " STNAME " variable truth table in file id %d", exoid); \ - ex_err(__func__, errmsg, status); \ - goto error_ret; /* exit define mode and return */ \ - } \ + if ((status = + ex_define_vars(exoid, EX_EDGE_BLOCK, "edge", "edge block", vp->num_edge, DIM_NUM_EDG_VAR, + numedblkdim, numedvardim, num_edge_blk, &edblk_ids, VAR_NAME_EDG_VAR, + VAR_EBLK_TAB, &edblk_stat, vp->edge_var_tab, &edblk_varid)) != EX_NOERR) { + goto error_ret; + } + + if ((status = + ex_define_vars(exoid, EX_FACE_BLOCK, "face", "face block", vp->num_face, DIM_NUM_FAC_VAR, + numfablkdim, numfavardim, num_face_blk, &fablk_ids, VAR_NAME_FAC_VAR, + VAR_FBLK_TAB, &fablk_stat, vp->face_var_tab, &fablk_varid)) != EX_NOERR) { + goto error_ret; + } + + if ((status = ex_define_vars(exoid, EX_ELEM_BLOCK, "element", "element block", vp->num_elem, + DIM_NUM_ELE_VAR, numelblkdim, numelvardim, num_elem_blk, &eblk_ids, + VAR_NAME_ELE_VAR, VAR_ELEM_TAB, &eblk_stat, vp->elem_var_tab, + &eblk_varid)) != EX_NOERR) { + goto error_ret; + } + + if ((status = + ex_define_vars(exoid, EX_NODE_SET, "nodeset", "node set", vp->num_nset, DIM_NUM_NSET_VAR, + numnsetdim, nsetvardim, num_nset, &nset_ids, VAR_NAME_NSET_VAR, + VAR_NSET_TAB, &nset_stat, vp->nset_var_tab, &nset_varid)) != EX_NOERR) { + goto error_ret; + } + + if ((status = + ex_define_vars(exoid, EX_EDGE_SET, "edgeset", "edge set", vp->num_eset, DIM_NUM_ESET_VAR, + numesetdim, esetvardim, num_eset, &eset_ids, VAR_NAME_ESET_VAR, + VAR_ESET_TAB, &eset_stat, vp->eset_var_tab, &eset_varid)) != EX_NOERR) { + goto error_ret; + } + + if ((status = + ex_define_vars(exoid, EX_FACE_SET, "faceset", "face set", vp->num_fset, DIM_NUM_FSET_VAR, + numfsetdim, fsetvardim, num_fset, &fset_ids, VAR_NAME_FSET_VAR, + VAR_FSET_TAB, &fset_stat, vp->fset_var_tab, &fset_varid)) != EX_NOERR) { + goto error_ret; + } + + if ((status = + ex_define_vars(exoid, EX_SIDE_SET, "sideset", "side set", vp->num_sset, DIM_NUM_SSET_VAR, + numssetdim, ssetvardim, num_sset, &sset_ids, VAR_NAME_SSET_VAR, + VAR_SSET_TAB, &sset_stat, vp->sset_var_tab, &sset_varid)) != EX_NOERR) { + goto error_ret; + } + + if ((status = ex_define_vars(exoid, EX_ELEM_SET, "elemset", "element set", vp->num_elset, + DIM_NUM_ELSET_VAR, numelsetdim, elsetvardim, num_elset, &elset_ids, + VAR_NAME_ELSET_VAR, VAR_ELSET_TAB, &elset_stat, vp->elset_var_tab, + &elset_varid)) != EX_NOERR) { + goto error_ret; } - EX_DEFINE_VARS(EX_EDGE_BLOCK, "edge", "edge block", vp->num_edge, DIM_NUM_EDG_VAR, numedblkdim, - numedvardim, num_edge_blk, edblk_ids, VAR_NAME_EDG_VAR, VAR_EBLK_TAB, edblk_stat, - vp->edge_var_tab, edblk_varid); - EX_DEFINE_VARS(EX_FACE_BLOCK, "face", "face block", vp->num_face, DIM_NUM_FAC_VAR, numfablkdim, - numfavardim, num_face_blk, fablk_ids, VAR_NAME_FAC_VAR, VAR_FBLK_TAB, fablk_stat, - vp->face_var_tab, fablk_varid); - EX_DEFINE_VARS(EX_ELEM_BLOCK, "element", "element block", vp->num_elem, DIM_NUM_ELE_VAR, - numelblkdim, numelvardim, num_elem_blk, eblk_ids, VAR_NAME_ELE_VAR, VAR_ELEM_TAB, - eblk_stat, vp->elem_var_tab, eblk_varid); - EX_DEFINE_VARS(EX_NODE_SET, "nodeset", "node set", vp->num_nset, DIM_NUM_NSET_VAR, numnsetdim, - nsetvardim, num_nset, nset_ids, VAR_NAME_NSET_VAR, VAR_NSET_TAB, nset_stat, - vp->nset_var_tab, nset_varid); - EX_DEFINE_VARS(EX_EDGE_SET, "edgeset", "edge set", vp->num_eset, DIM_NUM_ESET_VAR, numesetdim, - esetvardim, num_eset, eset_ids, VAR_NAME_ESET_VAR, VAR_ESET_TAB, eset_stat, - vp->eset_var_tab, eset_varid); - EX_DEFINE_VARS(EX_FACE_SET, "faceset", "face set", vp->num_fset, DIM_NUM_FSET_VAR, numfsetdim, - fsetvardim, num_fset, fset_ids, VAR_NAME_FSET_VAR, VAR_FSET_TAB, fset_stat, - vp->fset_var_tab, fset_varid); - EX_DEFINE_VARS(EX_SIDE_SET, "sideset", "side set", vp->num_sset, DIM_NUM_SSET_VAR, numssetdim, - ssetvardim, num_sset, sset_ids, VAR_NAME_SSET_VAR, VAR_SSET_TAB, sset_stat, - vp->sset_var_tab, sset_varid); - EX_DEFINE_VARS(EX_ELEM_SET, "elemset", "element set", vp->num_elset, DIM_NUM_ELSET_VAR, - numelsetdim, elsetvardim, num_elset, elset_ids, VAR_NAME_ELSET_VAR, VAR_ELSET_TAB, - elset_stat, vp->elset_var_tab, elset_varid); /* leave define mode */ @@ -346,8 +350,7 @@ int ex_put_all_var_param_ext(int exoid, const ex_var_params *vp) /* Fatal error: exit definition mode and return */ error_ret: if (in_define == 1) { - if ((status = nc_enddef(exoid)) != NC_NOERR) /* exit define mode */ - { + if ((status = nc_enddef(exoid)) != NC_NOERR) { /* exit define mode */ snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to complete definition for file id %d", exoid); ex_err(__func__, errmsg, status); @@ -370,6 +373,7 @@ error_ret: free(fset_stat); free(sset_stat); free(elset_stat); + EX_FUNC_LEAVE(EX_FATAL); } @@ -554,3 +558,49 @@ static int define_truth_table(ex_entity_type obj_type, int exoid, int num_ent, i } /* for i */ return NC_NOERR; } + +static int ex_define_vars(int exoid, ex_entity_type obj_type, const char *entity_name, + const char *entity_blk_name, int numvar, const char *DNAME, int dimid1, + int dimid2, int DVAL, void_int **entity_ids, const char *VNOV, + const char *VTV, int **status_var, int *truth_table, int *truth_table_var) +{ + int status = 0; + int dims[2]; + char errmsg[MAX_ERR_LENGTH]; + + if (numvar > 0) { + if ((status = define_dimension(exoid, DNAME, numvar, entity_name, &dimid2)) != NC_NOERR) { + return status; + } + + /* Now define entity_name variable name variable */ + if ((status = define_variable_name_variable(exoid, VNOV, dimid2, entity_name)) != NC_NOERR) { + return status; + } + + if ((status = define_truth_table(obj_type, exoid, DVAL, numvar, truth_table, *status_var, + *entity_ids, entity_blk_name)) != NC_NOERR) { + return status; + } + + free(*status_var); + *status_var = NULL; + free(*entity_ids); + *entity_ids = NULL; + + /* create a variable array in which to store the entity_name variable truth + * table + */ + + dims[0] = dimid1; + dims[1] = dimid2; + + if ((status = nc_def_var(exoid, VTV, NC_INT, 2, dims, truth_table_var)) != NC_NOERR) { + snprintf(errmsg, MAX_ERR_LENGTH, + "ERROR: failed to define %s variable truth table in file id %d", entity_name, exoid); + ex_err(__func__, errmsg, status); + return status; + } + } + return NC_NOERR; +} diff --git a/src/ex_put_block_params.c b/src/ex_put_block_params.c index fa26746a09a..f1f34aa6e84 100644 --- a/src/ex_put_block_params.c +++ b/src/ex_put_block_params.c @@ -64,7 +64,7 @@ int ex_put_block_params(int exoid, size_t block_count, const struct ex_block *bl int nnodperentdim = -1; int nedgperentdim = -1; int nfacperentdim = -1; - int connid; + int connid = 0; int npeid; char errmsg[MAX_ERR_LENGTH]; char * entity_type1 = NULL; @@ -350,7 +350,7 @@ int ex_put_block_params(int exoid, size_t block_count, const struct ex_block *bl */ if (blocks[i].num_attribute > 1) { struct ex_file_item *file = ex_find_file_item(exoid); - if (file->is_parallel && file->is_mpiio) { + if (file->is_parallel && file->is_hdf5) { nc_var_par_access(exoid, varid, NC_INDEPENDENT); } } @@ -475,26 +475,30 @@ int ex_put_block_params(int exoid, size_t block_count, const struct ex_block *bl } } else { - /* "Normal" (non-polyhedra) element block type */ - dims[0] = numblkdim; - dims[1] = nnodperentdim; + if (blocks[i].num_nodes_per_entry > 0) { + /* "Normal" (non-polyhedra) element block type */ + dims[0] = numblkdim; + dims[1] = nnodperentdim; - if ((status = nc_def_var(exoid, vnodcon, conn_int_type, 2, dims, &connid)) != NC_NOERR) { - snprintf(errmsg, MAX_ERR_LENGTH, - "ERROR: failed to create connectivity array for %s %" PRId64 " in file id %d", - ex_name_of_object(blocks[i].type), blocks[i].id, exoid); - ex_err(__func__, errmsg, status); - goto error_ret; /* exit define mode and return */ + if ((status = nc_def_var(exoid, vnodcon, conn_int_type, 2, dims, &connid)) != NC_NOERR) { + snprintf(errmsg, MAX_ERR_LENGTH, + "ERROR: failed to create connectivity array for %s %" PRId64 " in file id %d", + ex_name_of_object(blocks[i].type), blocks[i].id, exoid); + ex_err(__func__, errmsg, status); + goto error_ret; /* exit define mode and return */ + } + ex_compress_variable(exoid, connid, 1); } - ex_compress_variable(exoid, connid, 1); } /* store element type as attribute of connectivity variable */ - if ((status = nc_put_att_text(exoid, connid, ATT_NAME_ELB, strlen(blocks[i].topology) + 1, - blocks[i].topology)) != NC_NOERR) { - snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to store %s type name %s in file id %d", - ex_name_of_object(blocks[i].type), blocks[i].topology, exoid); - ex_err(__func__, errmsg, status); - goto error_ret; /* exit define mode and return */ + if (connid > 0) { + if ((status = nc_put_att_text(exoid, connid, ATT_NAME_ELB, strlen(blocks[i].topology) + 1, + blocks[i].topology)) != NC_NOERR) { + snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to store %s type name %s in file id %d", + ex_name_of_object(blocks[i].type), blocks[i].topology, exoid); + ex_err(__func__, errmsg, status); + goto error_ret; /* exit define mode and return */ + } } if (arbitrary_polyhedra == 0) { @@ -543,8 +547,7 @@ int ex_put_block_params(int exoid, size_t block_count, const struct ex_block *bl case EX_EDGE_BLOCK: vblkids = VAR_ID_ED_BLK; break; case EX_FACE_BLOCK: vblkids = VAR_ID_FA_BLK; break; case EX_ELEM_BLOCK: vblkids = VAR_ID_EL_BLK; break; - default: - EX_FUNC_LEAVE(EX_FATAL); /* should have been handled earlier; quiet compiler here */ + default: EX_FUNC_LEAVE(EX_FATAL); /* should have been handled earlier; quiet compiler here */ } nc_inq_varid(exoid, vblkids, &att_name_varid); diff --git a/src/ex_put_info.c b/src/ex_put_info.c index ff08044145b..1d18dd0da80 100644 --- a/src/ex_put_info.c +++ b/src/ex_put_info.c @@ -123,14 +123,6 @@ int ex_put_info(int exoid, int num_info, char *info[]) status = nc_inq_dimid(rootid, DIM_NUM_INFO, &num_info_dim); if (status != NC_NOERR) { - /* inquire previously defined dimensions */ - if ((status = nc_inq_dimid(rootid, DIM_LIN, &lindim)) != NC_NOERR) { - snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get line string length in file id %d", - rootid); - ex_err(__func__, errmsg, status); - EX_FUNC_LEAVE(EX_FATAL); - } - /* put file into define mode */ if ((status = nc_redef(rootid)) != NC_NOERR) { snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed put file id %d into define mode", rootid); @@ -154,6 +146,14 @@ int ex_put_info(int exoid, int num_info, char *info[]) goto error_ret; /* exit define mode and return */ } + /* create line length dimension */ + if ((status = nc_def_dim(rootid, DIM_LIN, (MAX_LINE_LENGTH + 1), &lindim)) != NC_NOERR) { + snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define line length in file id %d", + rootid); + ex_err(__func__, errmsg, status); + goto error_ret; /* exit define mode and return */ + } + /* define variable */ dims[0] = num_info_dim; dims[1] = lindim; diff --git a/src/ex_put_init_ext.c b/src/ex_put_init_ext.c index 75553543a06..c38f34f5458 100644 --- a/src/ex_put_init_ext.c +++ b/src/ex_put_init_ext.c @@ -307,11 +307,13 @@ int ex_put_init_ext(int exoid, const ex_init_params *model) } ex_compress_variable(exoid, temp, 2); - if ((status = nc_def_dim(exoid, DIM_NUM_DIM, model->num_dim, &numdimdim)) != NC_NOERR) { - snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define number of dimensions in file id %d", - exoid); - ex_err(__func__, errmsg, status); - goto error_ret; /* exit define mode and return */ + if (model->num_dim > 0) { + if ((status = nc_def_dim(exoid, DIM_NUM_DIM, model->num_dim, &numdimdim)) != NC_NOERR) { + snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define number of dimensions in file id %d", + exoid); + ex_err(__func__, errmsg, status); + goto error_ret; /* exit define mode and return */ + } } /* @@ -520,9 +522,11 @@ int ex_put_init_ext(int exoid, const ex_init_params *model) model->num_elem_maps) != NC_NOERR) { goto error_ret; } - if (ex_write_object_names(exoid, "coordinate", VAR_NAME_COOR, numdimdim, dim_str_name, - model->num_dim) != NC_NOERR) { - goto error_ret; + if (model->num_dim > 0) { + if (ex_write_object_names(exoid, "coordinate", VAR_NAME_COOR, numdimdim, dim_str_name, + model->num_dim) != NC_NOERR) { + goto error_ret; + } } /* leave define mode */ diff --git a/src/ex_put_map.c b/src/ex_put_map.c index 19a838b3bd7..e8456848715 100644 --- a/src/ex_put_map.c +++ b/src/ex_put_map.c @@ -55,8 +55,7 @@ /*! The function ex_put_map() writes out the optional element order map to -the database. See #ElementOrderMap for a description of the element -order map. The function ex_put_init() must be invoked before this call +the database. The function ex_put_init() must be invoked before this call is made. In case of an error, ex_put_map() returns a negative number; a warning diff --git a/src/ex_put_names.c b/src/ex_put_names.c index abe66bbfd1c..15b0c4e177c 100644 --- a/src/ex_put_names.c +++ b/src/ex_put_names.c @@ -81,26 +81,20 @@ int ex_put_names(int exoid, ex_entity_type obj_type, char *names[]) /* ======== BLOCKS ========= */ case EX_EDGE_BLOCK: vname = VAR_NAME_ED_BLK; break; case EX_FACE_BLOCK: vname = VAR_NAME_FA_BLK; break; - case EX_ELEM_BLOCK: - vname = VAR_NAME_EL_BLK; - break; + case EX_ELEM_BLOCK: vname = VAR_NAME_EL_BLK; break; /* ======== SETS ========= */ case EX_NODE_SET: vname = VAR_NAME_NS; break; case EX_EDGE_SET: vname = VAR_NAME_ES; break; case EX_FACE_SET: vname = VAR_NAME_FS; break; case EX_SIDE_SET: vname = VAR_NAME_SS; break; - case EX_ELEM_SET: - vname = VAR_NAME_ELS; - break; + case EX_ELEM_SET: vname = VAR_NAME_ELS; break; /* ======== MAPS ========= */ case EX_NODE_MAP: vname = VAR_NAME_NM; break; case EX_EDGE_MAP: vname = VAR_NAME_EDM; break; case EX_FACE_MAP: vname = VAR_NAME_FAM; break; - case EX_ELEM_MAP: - vname = VAR_NAME_EM; - break; + case EX_ELEM_MAP: vname = VAR_NAME_EM; break; /* ======== ERROR (Invalid type) ========= */ default: diff --git a/src/ex_put_partial_set.c b/src/ex_put_partial_set.c index e3f38aadd0d..b3b020dcd3f 100644 --- a/src/ex_put_partial_set.c +++ b/src/ex_put_partial_set.c @@ -108,8 +108,7 @@ int ex_put_partial_set(int exoid, ex_entity_type set_type, ex_entity_id set_id, ex_err(__func__, errmsg, EX_NULLENTITY); EX_FUNC_LEAVE(EX_WARN); } - snprintf(errmsg, MAX_ERR_LENGTH, - "ERROR: failed to locate %s id %" PRId64 " in VAR_*S_IDS array in file id %d", + snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate %s id %" PRId64 " in file id %d", ex_name_of_object(set_type), set_id, exoid); ex_err(__func__, errmsg, status); EX_FUNC_LEAVE(EX_FATAL); diff --git a/src/ex_put_partial_var.c b/src/ex_put_partial_var.c index 37b6be9bae0..ccec3acb935 100644 --- a/src/ex_put_partial_var.c +++ b/src/ex_put_partial_var.c @@ -74,21 +74,6 @@ int ex_put_partial_var(int exoid, int time_step, ex_entity_type var_type, int va ex_check_valid_file_id(exoid, __func__); -#if !defined EXODUS_IN_SIERRA - /* Verify that time_step is within bounds */ - { - int num_time_steps = ex_inquire_int(exoid, EX_INQ_TIME); - if (time_step <= 0 || time_step > num_time_steps) { - snprintf(errmsg, MAX_ERR_LENGTH, - "ERROR: time_step is out-of-range. Value = %d, valid " - "range is 1 to %d in file id %d", - time_step, num_time_steps, exoid); - ex_err(__func__, errmsg, EX_BADPARAM); - EX_FUNC_LEAVE(EX_FATAL); - } - } -#endif - #define EX_LOOK_UP_VAR(VOBJID, VVAR, VOBJTAB, DNUMOBJ, DNUMOBJVAR) \ /* Determine index of obj_id in VOBJID array */ \ obj_id_ndx = ex_id_lkup(exoid, var_type, obj_id); \ diff --git a/src/ex_put_prop.c b/src/ex_put_prop.c index 520e4758263..1a79b01f33c 100644 --- a/src/ex_put_prop.c +++ b/src/ex_put_prop.c @@ -48,8 +48,7 @@ a single element block, node set, or side set. Although it is not necessary to invoke ex_put_prop_names(), since ex_put_prop() will allocate space within the data file if it hasn't been previously allocated, it is more efficient to use ex_put_prop_names() if there is -more than one property to store. \see Efficiency for a discussion of -efficiency issues. +more than one property to store. It should be noted that the interpretation of the values of the integers stored as properties is left to the application code. In diff --git a/src/ex_put_prop_array.c b/src/ex_put_prop_array.c index 7df076aa49f..ada177d5702 100644 --- a/src/ex_put_prop_array.c +++ b/src/ex_put_prop_array.c @@ -61,8 +61,7 @@ ex_put_prop(). Although it is not necessary to invoke ex_put_prop_names(), since ex_put_prop_array() will allocate space within the data file if it hasn't been previously allocated, it is more efficient to use -ex_put_prop_names() if there is more than one property to store. \see -See Efficiency for a discussion of efficiency issues. +ex_put_prop_names() if there is more than one property to store. \return In case of an error, ex_put_prop_array() returns a negative number; a warning will return a positive number. Possible causes of diff --git a/src/ex_put_prop_names.c b/src/ex_put_prop_names.c index 475251cbc9b..e1e3bd3a1f6 100644 --- a/src/ex_put_prop_names.c +++ b/src/ex_put_prop_names.c @@ -48,8 +48,7 @@ properties to element blocks, node sets, or side sets. The property arrays are initialized to zero (0). Although this function is optional, since ex_put_prop() will allocate space within the data file if it hasn't been previously allocated, it is more efficient to use -ex_put_prop_names() if there is more than one property to store. \see -Efficiency for a discussion of efficiency issues. +ex_put_prop_names() if there is more than one property to store. \return In case of an error, ex_put_prop_names() returns a negative number; a warning will return a positive number. Possible causes of errors diff --git a/src/ex_put_qa.c b/src/ex_put_qa.c index 1a7690bb09f..fb01d7b0c2b 100644 --- a/src/ex_put_qa.c +++ b/src/ex_put_qa.c @@ -113,21 +113,6 @@ int ex_put_qa(int exoid, int num_qa_records, char *qa_record[][4]) status = nc_inq_dimid(rootid, DIM_NUM_QA, &num_qa_dim); if (status != NC_NOERR) { - /* inquire previously defined dimensions */ - if ((status = nc_inq_dimid(rootid, DIM_STR, &strdim)) != NC_NOERR) { - snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate string length in file id %d", - rootid); - ex_err(__func__, errmsg, status); - EX_FUNC_LEAVE(EX_FATAL); - } - - if ((status = nc_inq_dimid(rootid, DIM_N4, &n4dim)) != NC_NOERR) { - snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate record length in file id %d", - rootid); - ex_err(__func__, errmsg, status); - EX_FUNC_LEAVE(EX_FATAL); - } - /* put file into define mode */ if ((status = nc_redef(rootid)) != NC_NOERR) { snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to put file id %d into define mode", @@ -151,6 +136,27 @@ int ex_put_qa(int exoid, int num_qa_records, char *qa_record[][4]) goto error_ret; /* exit define mode and return */ } + /* create number "4" dimension; must be of type long */ + if ((status = nc_def_dim(rootid, DIM_N4, 4L, &n4dim)) != NC_NOERR) { + snprintf(errmsg, MAX_ERR_LENGTH, + "ERROR: failed to define number \"4\" dimension in file id %d", rootid); + ex_err(__func__, errmsg, status); + goto error_ret; /* exit define mode and return */ + } + + /* create string length dimension -- only used for QA records */ + if ((status = nc_def_dim(rootid, DIM_STR, (MAX_STR_LENGTH + 1), &strdim)) != NC_NOERR) { + if (status == NC_ENAMEINUSE) { /* already defined */ + nc_inq_dimid(rootid, DIM_STR, &strdim); + } + else { + snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define string length in file id %d", + rootid); + ex_err(__func__, errmsg, status); + goto error_ret; /* exit define mode and return */ + } + } + /* define variable */ dims[0] = num_qa_dim; dims[1] = n4dim; diff --git a/src/ex_put_var.c b/src/ex_put_var.c index eade87d8f6a..e893521154c 100644 --- a/src/ex_put_var.c +++ b/src/ex_put_var.c @@ -211,21 +211,6 @@ int ex_put_var(int exoid, int time_step, ex_entity_type var_type, int var_index, ex_check_valid_file_id(exoid, __func__); -#if !defined EXODUS_IN_SIERRA - /* Verify that time_step is within bounds */ - { - int num_time_steps = ex_inquire_int(exoid, EX_INQ_TIME); - if (time_step <= 0 || time_step > num_time_steps) { - snprintf(errmsg, MAX_ERR_LENGTH, - "ERROR: time_step is out-of-range. Value = %d, valid " - "range is 1 to %d in file id %d", - time_step, num_time_steps, exoid); - ex_err(__func__, errmsg, EX_BADPARAM); - EX_FUNC_LEAVE(EX_FATAL); - } - } -#endif - switch (var_type) { case EX_GLOBAL: if (num_entries_this_obj <= 0) { diff --git a/src/ex_utils.c b/src/ex_utils.c index 5f82b1f145b..e8b6741d708 100644 --- a/src/ex_utils.c +++ b/src/ex_utils.c @@ -84,14 +84,14 @@ static char *cur_string = &ret_string[0]; int ex_check_file_type(const char *path, int *type) { -/* Based on (stolen from?) NC_check_file_type from netcdf sources. + /* Based on (stolen from?) NC_check_file_type from netcdf sources. -Type is set to: -1 if this is a netcdf classic file, -2 if this is a netcdf 64-bit offset file, -4 pnetcdf cdf5 file. -5 if this is an hdf5 file -*/ + Type is set to: + 1 if this is a netcdf classic file, + 2 if this is a netcdf 64-bit offset file, + 4 pnetcdf cdf5 file. + 5 if this is an hdf5 file + */ #define MAGIC_NUMBER_LEN 4 @@ -492,7 +492,7 @@ char *ex_dim_num_entries_in_object(ex_entity_type obj_type, int idx) case EX_FACE_SET: return DIM_NUM_FACE_FS(idx); case EX_SIDE_SET: return DIM_NUM_SIDE_SS(idx); case EX_ELEM_SET: return DIM_NUM_ELE_ELS(idx); - default: return 0; + default: return NULL; } } @@ -507,7 +507,7 @@ char *ex_name_var_of_object(ex_entity_type obj_type, int i, int j) case EX_FACE_SET: return VAR_FS_VAR(i, j); case EX_SIDE_SET: return VAR_SS_VAR(i, j); case EX_ELEM_SET: return VAR_ELS_VAR(i, j); - default: return 0; + default: return NULL; } } @@ -518,7 +518,7 @@ char *ex_name_of_map(ex_entity_type map_type, int map_index) case EX_EDGE_MAP: return VAR_EDGE_MAP(map_index); case EX_FACE_MAP: return VAR_FACE_MAP(map_index); case EX_ELEM_MAP: return VAR_ELEM_MAP(map_index); - default: return 0; + default: return NULL; } } @@ -1145,23 +1145,23 @@ static void ex_swap64(int64_t v[], int64_t i, int64_t j) v[j] = temp; } - /*! - * The following 'indexed qsort' routine is modified from Sedgewicks - * algorithm It selects the pivot based on the median of the left, - * right, and center values to try to avoid degenerate cases ocurring - * when a single value is chosen. It performs a quicksort on - * intervals down to the EX_QSORT_CUTOFF size and then performs a final - * insertion sort on the almost sorted final array. Based on data in - * Sedgewick, the EX_QSORT_CUTOFF value should be between 5 and 20. - * - * See Sedgewick for further details - * Define DEBUG_QSORT at the top of this file and recompile to compile - * in code that verifies that the array is sorted. - * - * NOTE: The 'int' implementation below assumes that *both* the items - * being sorted and the *number* of items being sorted are both - * representable as 'int'. - */ +/*! + * The following 'indexed qsort' routine is modified from Sedgewicks + * algorithm It selects the pivot based on the median of the left, + * right, and center values to try to avoid degenerate cases ocurring + * when a single value is chosen. It performs a quicksort on + * intervals down to the EX_QSORT_CUTOFF size and then performs a final + * insertion sort on the almost sorted final array. Based on data in + * Sedgewick, the EX_QSORT_CUTOFF value should be between 5 and 20. + * + * See Sedgewick for further details + * Define DEBUG_QSORT at the top of this file and recompile to compile + * in code that verifies that the array is sorted. + * + * NOTE: The 'int' implementation below assumes that *both* the items + * being sorted and the *number* of items being sorted are both + * representable as 'int'. + */ #define EX_QSORT_CUTOFF 12 @@ -1411,27 +1411,30 @@ int ex_get_dimension(int exoid, const char *DIMENSION, const char *label, size_t if ((status = nc_inq_dimid(exoid, DIMENSION, dimid)) != NC_NOERR) { if (routine != NULL) { if (status == NC_EBADDIM) { - snprintf(errmsg, MAX_ERR_LENGTH, "Warning: no %s defined in file id %d", label, exoid); + snprintf(errmsg, MAX_ERR_LENGTH, "Warning: no dimension defining '%s' found in file id %d", + label, exoid); ex_err(__func__, errmsg, status); } else { - snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate number of %s in file id %d", - label, exoid); + snprintf(errmsg, MAX_ERR_LENGTH, + "ERROR: failed to locate dimension defining number of '%s' in file id %d", label, + exoid); ex_err(__func__, errmsg, status); } } - return (status); + return status; } if ((status = nc_inq_dimlen(exoid, *dimid, count)) != NC_NOERR) { if (routine != NULL) { - snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get number of %s in file id %d", label, - exoid); + snprintf(errmsg, MAX_ERR_LENGTH, + "ERROR: failed to get length of dimension defining number of '%s' in file id %d", + label, exoid); ex_err(__func__, errmsg, status); - return -1; } + return status; } - return (status); + return status; } /* Deprecated. do not use */ @@ -1458,7 +1461,7 @@ void ex_compress_variable(int exoid, int varid, int type) nc_def_var_deflate(exoid, varid, shuffle, compress, deflate_level); } #if defined(PARALLEL_AWARE_EXODUS) - if (type != 3 && file->is_parallel && file->is_mpiio) { + if (type != 3 && file->is_parallel && file->is_hdf5) { nc_var_par_access(exoid, varid, NC_COLLECTIVE); } #endif -- GitLab