From bf920645a851b837b5152afba0dedd48e2b38bbf Mon Sep 17 00:00:00 2001
From: Seacas Upstream <kwrobot@kitware.com>
Date: Thu, 20 Jun 2019 10:05:42 -0400
Subject: [PATCH] exodusII 2019-06-20 (a55da39b)

Code extracted from:

    https://gitlab.kitware.com/third-party/seacas.git

at commit a55da39b610540f4ba730a83c5ba18a9e8234ee4 (for/vtk-20190620-7.21f-master).
---
 COPYRIGHT                                    |   2 +-
 README                                       |   6 +-
 README.kitware.md                            |   2 +-
 include/exodusII.h                           |  29 +-
 include/exodusII_cfg.h.in                    |  45 +-
 include/exodusII_int.h                       |  16 +
 src/deprecated/ex_get_concat_node_sets.c     |   1 -
 src/deprecated/ex_get_elem_block.c           |   2 +-
 src/deprecated/ex_get_elem_var.c             |   1 -
 src/deprecated/ex_get_elem_var_time.c        |   1 -
 src/deprecated/ex_get_n_attr.c               |   1 -
 src/deprecated/ex_get_n_conn.c               |   1 -
 src/deprecated/ex_get_n_coord.c              |   1 -
 src/deprecated/ex_get_n_elem_attr.c          |   1 -
 src/deprecated/ex_get_n_elem_conn.c          |   2 -
 src/deprecated/ex_get_n_elem_num_map.c       |   9 +-
 src/deprecated/ex_get_n_elem_var.c           |   1 -
 src/deprecated/ex_get_n_nodal_var.c          |   1 -
 src/deprecated/ex_get_n_node_num_map.c       |   7 +-
 src/deprecated/ex_get_n_node_set.c           |   2 -
 src/deprecated/ex_get_n_node_set_df.c        |   1 -
 src/deprecated/ex_get_n_one_attr.c           |   1 -
 src/deprecated/ex_get_n_side_set.c           |   1 -
 src/deprecated/ex_get_n_side_set_df.c        |   1 -
 src/deprecated/ex_get_n_var.c                |   1 -
 src/deprecated/ex_get_nodal_var.c            |   1 -
 src/deprecated/ex_get_nodal_var_time.c       |   1 -
 src/deprecated/ex_get_node_set.c             |   1 -
 src/deprecated/ex_get_nset_var.c             |   1 -
 src/deprecated/ex_get_partial_elem_attr.c    |   1 -
 src/deprecated/ex_get_partial_elem_conn.c    |   2 -
 src/deprecated/ex_get_partial_elem_map.c     |   1 -
 src/deprecated/ex_get_partial_elem_num_map.c |   9 +-
 src/deprecated/ex_get_partial_elem_var.c     |   1 -
 src/deprecated/ex_get_partial_nodal_var.c    |  13 +-
 src/deprecated/ex_get_partial_node_num_map.c |   5 +-
 src/deprecated/ex_get_partial_node_set.c     |   2 -
 src/deprecated/ex_get_partial_node_set_df.c  |   1 -
 src/deprecated/ex_get_partial_side_set.c     |   1 -
 src/deprecated/ex_get_partial_side_set_df.c  |   1 -
 src/deprecated/ex_get_sset_var.c             |   1 -
 src/deprecated/ex_put_concat_node_sets.c     |   1 -
 src/deprecated/ex_put_elem_block.c           |   1 -
 src/deprecated/ex_put_elem_var.c             |   1 -
 src/deprecated/ex_put_elem_var_slab.c        |   1 -
 src/deprecated/ex_put_n_attr.c               |   1 -
 src/deprecated/ex_put_n_coord.c              |   1 -
 src/deprecated/ex_put_n_elem_attr.c          |   1 -
 src/deprecated/ex_put_n_elem_conn.c          |   2 -
 src/deprecated/ex_put_n_elem_num_map.c       |   7 +-
 src/deprecated/ex_put_n_nodal_var.c          |   1 -
 src/deprecated/ex_put_n_node_num_map.c       |   7 +-
 src/deprecated/ex_put_n_node_set.c           |   2 -
 src/deprecated/ex_put_n_node_set_df.c        |   1 -
 src/deprecated/ex_put_n_one_attr.c           |   1 -
 src/deprecated/ex_put_n_side_set.c           |   1 -
 src/deprecated/ex_put_n_side_set_df.c        |   1 -
 src/deprecated/ex_put_n_var.c                |   1 -
 src/deprecated/ex_put_nodal_var_slab.c       |   1 -
 src/deprecated/ex_put_node_set.c             |   1 -
 src/deprecated/ex_put_node_set_param.c       |   1 -
 src/deprecated/ex_put_nset_var.c             |   1 -
 src/deprecated/ex_put_partial_elem_attr.c    |   1 -
 src/deprecated/ex_put_partial_elem_conn.c    |   2 -
 src/deprecated/ex_put_partial_elem_map.c     |   1 -
 src/deprecated/ex_put_partial_elem_num_map.c |   7 +-
 src/deprecated/ex_put_partial_nodal_var.c    |   1 -
 src/deprecated/ex_put_partial_node_num_map.c |   7 +-
 src/deprecated/ex_put_partial_node_set.c     |   2 -
 src/deprecated/ex_put_partial_node_set_df.c  |   1 -
 src/deprecated/ex_put_partial_side_set.c     |   1 -
 src/deprecated/ex_put_partial_side_set_df.c  |   1 -
 src/deprecated/ex_put_side_set_param.c       |   1 -
 src/deprecated/ex_put_sset_var.c             |   1 -
 src/ex_add_attr.c                            |  34 +-
 src/ex_close.c                               |   8 +-
 src/ex_conv.c                                |  61 +-
 src/ex_copy.c                                |  41 +-
 src/ex_create.c                              | 354 +----------
 src/ex_create_group.c                        |  10 +-
 src/ex_create_par.c                          | 440 +------------
 src/ex_cvt_nodes_to_sides.c                  |  59 +-
 src/ex_err.c                                 | 120 +++-
 src/ex_get_all_times.c                       |   6 +-
 src/ex_get_attr.c                            |  13 +-
 src/ex_get_attr_names.c                      |  14 +-
 src/ex_get_attr_param.c                      |  10 +-
 src/ex_get_block.c                           |   4 +-
 src/ex_get_block_param.c                     |  37 +-
 src/ex_get_block_params.c                    |   1 -
 src/ex_get_cmap_params.c                     |  45 +-
 src/ex_get_concat_sets.c                     |  14 +-
 src/ex_get_concat_side_set_node_count.c      |  40 +-
 src/ex_get_conn.c                            |  29 +-
 src/ex_get_coord.c                           |  17 +-
 src/ex_get_coord_names.c                     |   9 +-
 src/ex_get_coordinate_frames.c               |  14 +-
 src/ex_get_eb_info_global.c                  |  10 +-
 src/ex_get_elem_cmap.c                       |  27 +-
 src/ex_get_elem_type.c                       |  14 +-
 src/ex_get_entity_count_per_polyhedra.c      |  13 +-
 src/ex_get_glob_var_time_int.c               |  18 +-
 src/ex_get_glob_vars_int.c                   |   7 +-
 src/ex_get_group_id.c                        |  16 +-
 src/ex_get_group_ids.c                       |   6 +-
 src/ex_get_id_map.c                          |  10 +-
 src/ex_get_ids.c                             |  10 +-
 src/ex_get_info.c                            |  11 +-
 src/ex_get_init.c                            |   4 +-
 src/ex_get_init_ext.c                        |  16 +-
 src/ex_get_init_global.c                     |  20 +-
 src/ex_get_init_info.c                       |  11 +-
 src/ex_get_loadbal_param.c                   |  64 +-
 src/ex_get_map.c                             |   8 +-
 src/ex_get_map_param.c                       |   7 +-
 src/ex_get_name.c                            |   4 +-
 src/ex_get_names.c                           |   5 +-
 src/ex_get_nodal_var_int.c                   |  10 +-
 src/ex_get_nodal_var_time_int.c              |  21 +-
 src/ex_get_node_cmap.c                       |  23 +-
 src/ex_get_ns_param_global.c                 |  14 +-
 src/ex_get_num_map.c                         |  13 +-
 src/ex_get_object_truth_vector.c             |  13 +-
 src/ex_get_one_attr.c                        |  16 +-
 src/ex_get_partial_attr.c                    |  17 +-
 src/ex_get_partial_conn.c                    |  33 +-
 src/ex_get_partial_coord.c                   |  21 +-
 src/ex_get_partial_coord_component.c         |  19 +-
 src/ex_get_partial_id_map.c                  |  33 +-
 src/ex_get_partial_nodal_var_int.c           |  10 +-
 src/ex_get_partial_num_map.c                 |  23 +-
 src/ex_get_partial_one_attr.c                |  19 +-
 src/ex_get_partial_set.c                     |  41 +-
 src/ex_get_partial_set_dist_fact.c           |  17 +-
 src/ex_get_partial_var.c                     |  13 +-
 src/ex_get_processor_elem_maps.c             |  34 +-
 src/ex_get_processor_node_maps.c             |  48 +-
 src/ex_get_prop.c                            |  20 +-
 src/ex_get_prop_array.c                      |  13 +-
 src/ex_get_prop_names.c                      |  13 +-
 src/ex_get_qa.c                              |  11 +-
 src/ex_get_set.c                             |  19 +-
 src/ex_get_set_dist_fact.c                   |  15 +-
 src/ex_get_set_param.c                       |  15 +-
 src/ex_get_sets.c                            |   1 -
 src/ex_get_side_set_node_count.c             |  38 +-
 src/ex_get_side_set_node_list.c              |  74 +--
 src/ex_get_side_set_node_list_len.c          |  38 +-
 src/ex_get_ss_param_global.c                 |  14 +-
 src/ex_get_time.c                            |  32 +-
 src/ex_get_truth_table.c                     |  12 +-
 src/ex_get_var.c                             |  13 +-
 src/ex_get_var_time.c                        |  36 +-
 src/ex_get_variable_name.c                   |   6 +-
 src/ex_get_variable_names.c                  |   6 +-
 src/ex_get_variable_param.c                  |   9 +-
 src/ex_inquire.c                             |  68 +-
 src/ex_int_get_block_param.c                 |  42 +-
 src/ex_ne_util.c                             |  45 +-
 src/ex_open.c                                |  82 +--
 src/ex_open_par.c                            | 112 ++--
 src/ex_put_all_var_param_ext.c               |  62 +-
 src/ex_put_attr.c                            |  13 +-
 src/ex_put_attr_names.c                      |  18 +-
 src/ex_put_attr_param.c                      |  33 +-
 src/ex_put_block.c                           |   5 +-
 src/ex_put_block_params.c                    |  70 +--
 src/ex_put_cmap_params.c                     |  52 +-
 src/ex_put_cmap_params_cc.c                  |  65 +-
 src/ex_put_concat_all_blocks.c               |  83 ++-
 src/ex_put_concat_elem_block.c               |  53 +-
 src/ex_put_concat_sets.c                     |  66 +-
 src/ex_put_conn.c                            |  79 ++-
 src/ex_put_coord.c                           |  21 +-
 src/ex_put_coord_names.c                     |   9 +-
 src/ex_put_coordinate_frames.c               |  29 +-
 src/ex_put_eb_info_global.c                  |  11 +-
 src/ex_put_elem_cmap.c                       |  30 +-
 src/ex_put_entity_count_per_polyhedra.c      |  13 +-
 src/ex_put_id_map.c                          |  22 +-
 src/ex_put_info.c                            |  28 +-
 src/ex_put_init.c                            |   6 +-
 src/ex_put_init_ext.c                        |  74 +--
 src/ex_put_init_global.c                     |  31 +-
 src/ex_put_init_info.c                       |  28 +-
 src/ex_put_loadbal_param.c                   |  85 ++-
 src/ex_put_loadbal_param_cc.c                | 112 ++--
 src/ex_put_map.c                             |  20 +-
 src/ex_put_map_param.c                       |  55 +-
 src/ex_put_name.c                            |   9 +-
 src/ex_put_names.c                           |   8 +-
 src/ex_put_nodal_var.c                       |   4 -
 src/ex_put_nodal_var_int.c                   |   8 +-
 src/ex_put_node_cmap.c                       |  27 +-
 src/ex_put_ns_param_global.c                 |  14 +-
 src/ex_put_num_map.c                         |  35 +-
 src/ex_put_one_attr.c                        |  16 +-
 src/ex_put_partial_attr.c                    |  19 +-
 src/ex_put_partial_conn.c                    |  33 +-
 src/ex_put_partial_coord.c                   |  21 +-
 src/ex_put_partial_coord_component.c         |  19 +-
 src/ex_put_partial_id_map.c                  |  26 +-
 src/ex_put_partial_nodal_var_int.c           |   8 +-
 src/ex_put_partial_num_map.c                 |  33 +-
 src/ex_put_partial_one_attr.c                |  19 +-
 src/ex_put_partial_set.c                     |  21 +-
 src/ex_put_partial_set_dist_fact.c           |  17 +-
 src/ex_put_partial_var.c                     |  47 +-
 src/ex_put_processor_elem_maps.c             |  34 +-
 src/ex_put_processor_node_maps.c             |  48 +-
 src/ex_put_prop.c                            |  40 +-
 src/ex_put_prop_array.c                      |  31 +-
 src/ex_put_prop_names.c                      |  25 +-
 src/ex_put_qa.c                              |  30 +-
 src/ex_put_set.c                             |  19 +-
 src/ex_put_set_dist_fact.c                   |  15 +-
 src/ex_put_set_param.c                       |   2 -
 src/ex_put_sets.c                            |  49 +-
 src/ex_put_ss_param_global.c                 |  15 +-
 src/ex_put_time.c                            |   8 +-
 src/ex_put_truth_table.c                     |  36 +-
 src/ex_put_var.c                             |  46 +-
 src/ex_put_variable_name.c                   |   6 +-
 src/ex_put_variable_names.c                  |  12 +-
 src/ex_put_variable_param.c                  |  45 +-
 src/ex_threadsafe.c                          |   3 -
 src/ex_update.c                              |   4 +-
 src/ex_utils.c                               | 619 ++++++++++++++++++-
 228 files changed, 2470 insertions(+), 3246 deletions(-)

diff --git a/COPYRIGHT b/COPYRIGHT
index b26b08ec753..61251c21118 100644
--- a/COPYRIGHT
+++ b/COPYRIGHT
@@ -12,7 +12,7 @@ met:
     * Redistributions in binary form must reproduce the above
       copyright notice, this list of conditions and the following
       disclaimer in the documentation and/or other materials provided
-      with the distribution.  
+      with the distribution.
 
     * Neither the name of NTESS nor the names of its
       contributors may be used to endorse or promote products derived
diff --git a/README b/README
index 9db9eef34dd..f3609197a34 100644
--- a/README
+++ b/README
@@ -3,7 +3,7 @@ CONTACT:
 
 Greg Sjaardema,
 Sandia National Laboratories,
-gdsjaar@sandia.gov
+gdsjaar@sandia.gov, gsjaardema@gmail.com
 
 ========================================================================
 LICENSE:
@@ -12,12 +12,12 @@ The Exodus library is licensed under the terms of the BSD License.
 Legal stuff (copyright, licensing restrictions, etc.) can be found in
 the file COPYRIGHT which contains:
 
-1. The Sandia Corporation Copyright Notice.
+1. The NTESS Copyright Notice.
 2. The BSD License.
 
 We appreciate feedback from users of this package.  Please send
 comments, suggestions, and bug reports to Greg Sjaardema
-<gdsjaar@sandia.gov>.
+<gdsjaar@sandia.gov>, <gsjaardema@gmail.com>
 
 Please identify the version of the package.
 
diff --git a/README.kitware.md b/README.kitware.md
index 02887b9bae3..0132142d587 100644
--- a/README.kitware.md
+++ b/README.kitware.md
@@ -7,6 +7,6 @@ symbols to avoid conflicts with other copies of the library within a single
 process.
 
   * Add attributes to pass commit checks within VTK.
-  * Use VTK's netcdf library.
   * CMake code to integrate with VTK's module system.
   * Mangle all exported symbols to have a `vtkexodusII_` prefix.
+  * Use VTK's netcdf library
diff --git a/include/exodusII.h b/include/exodusII.h
index 6ba6fd6ce97..fc7ef67dd60 100644
--- a/include/exodusII.h
+++ b/include/exodusII.h
@@ -57,11 +57,11 @@
 #endif
 #endif
 #endif
+#endif
 
 #if defined(PARALLEL_AWARE_EXODUS)
 #include "netcdf_par.h"
 #endif
-#endif
 
 #include <stddef.h>
 #include <stdint.h>
@@ -72,8 +72,8 @@
 #endif
 
 /* EXODUS version number */
-#define EX_API_VERS 7.15f
-#define EX_API_VERS_NODOT 715
+#define EX_API_VERS 7.21f
+#define EX_API_VERS_NODOT 721
 #define EX_VERS EX_API_VERS
 #define NEMESIS_API_VERSION EX_API_VERS
 #define NEMESIS_API_VERSION_NODOT EX_API_VERS_NODOT
@@ -236,9 +236,9 @@ sufficient.
 enum ex_option_type {
   EX_OPT_MAX_NAME_LENGTH =
       1, /**< Maximum length of names that will be returned/passed via api call. */
-  EX_OPT_COMPRESSION_TYPE,    /**<  Not currently used; default is gzip	*/
+  EX_OPT_COMPRESSION_TYPE,    /**<  Not currently used; default is gzip */
   EX_OPT_COMPRESSION_LEVEL,   /**<  In the range [0..9]. A value of 0 indicates no compression */
-  EX_OPT_COMPRESSION_SHUFFLE, /**<  1 if enabled, 0 if disabled	*/
+  EX_OPT_COMPRESSION_SHUFFLE, /**<  1 if enabled, 0 if disabled */
   EX_OPT_INTEGER_SIZE_API, /**<  4 or 8 indicating byte size of integers used in api functions. */
   EX_OPT_INTEGER_SIZE_DB /**<  Query only, returns 4 or 8 indicating byte size of integers stored on
                             the database. */
@@ -621,8 +621,9 @@ EXODUS_EXPORT int ex_get_num_props(int exoid, ex_entity_type obj_type);
 EXODUS_EXPORT int ex_large_model(int exoid);
 EXODUS_EXPORT size_t ex_header_size(int exoid);
 
-EXODUS_EXPORT void        ex_err(const char *module_name, const char *message, int err_num);
-EXODUS_EXPORT void        ex_set_err(const char *module_name, const char *message, int err_num);
+EXODUS_EXPORT void ex_err(const char *module_name, const char *message, int err_num);
+EXODUS_EXPORT void ex_err_fn(int exoid, const char *module_name, const char *message, int err_num);
+EXODUS_EXPORT void ex_set_err(const char *module_name, const char *message, int err_num);
 EXODUS_EXPORT const char *ex_strerror(int err_num);
 EXODUS_EXPORT void        ex_get_err(const char **msg, const char **func, int *err_num);
 EXODUS_EXPORT int         ex_opts(int options);
@@ -632,10 +633,8 @@ EXODUS_EXPORT int64_t ex_inquire_int(int exoid, int req_info);
 EXODUS_EXPORT int     ex_int64_status(int exoid);
 EXODUS_EXPORT int     ex_set_int64_status(int exoid, int mode);
 
-/** Note that the max name length setting is global at this time; not specific
- * to a particular database; however, the exoid option is passed to give
- * flexibility in the future to implement this on a database-by-database basis.
- */
+EXODUS_EXPORT void ex_print_config(void);
+
 EXODUS_EXPORT int ex_set_max_name_length(int exoid, int length);
 
 EXODUS_EXPORT int ex_set_option(int exoid, ex_option_type option, int option_value);
@@ -1002,11 +1001,11 @@ EXODUS_EXPORT int ex_put_cmap_params_cc(int       exoid,               /* NetCDF
                                         void_int *node_cmap_ids,       /* Node map IDs */
                                         void_int *node_cmap_node_cnts, /* Nodes in nodal comm */
                                         void_int *node_proc_ptrs,      /* Pointer into array for */
-                                                                       /* node maps		  */
+                                                                       /* node maps               */
                                         void_int *elem_cmap_ids,       /* Elem map IDs */
                                         void_int *elem_cmap_elem_cnts, /* Elems in elemental comm */
                                         void_int *elem_proc_ptrs       /* Pointer into array for */
-                                                                       /* elem maps		  */
+                                                                       /* elem maps               */
 );
 
 EXODUS_EXPORT int ex_get_node_cmap(int          exoid,    /* NetCDF/Exodus file ID */
@@ -1039,6 +1038,9 @@ EXODUS_EXPORT int ex_put_elem_cmap(int          exoid,    /* NetCDF/Exodus file
                                    int          processor /* This processor ID */
 );
 
+/* Utility function to replace strncpy, strcpy -- guarantee null termination */
+char *ex_copy_string(char *dest, char const *source, size_t elements);
+
 /* Deprecated Code Handling Options:
  * 1. Ignore -- treat deprecated functions as normal non-deprecated functions (default)
  * 2. Delete -- the deprecated functions are not defined or compiled (SEACAS_HIDE_DEPRECATED_CODE is
@@ -1639,6 +1641,7 @@ EXODUS_EXPORT int exerrval; /**< shared error return value                */
 
 EXODUS_EXPORT char *ex_name_of_object(ex_entity_type obj_type);
 EXODUS_EXPORT ex_entity_type ex_var_type_to_ex_entity_type(char var_type);
+EXODUS_EXPORT int            ex_set_parallel(int exoid, int is_parallel);
 
 /* Should be internal use only, but was in external include file for
    nemesis and some codes are using the function
diff --git a/include/exodusII_cfg.h.in b/include/exodusII_cfg.h.in
index 40a7d46c016..2b31992ef31 100644
--- a/include/exodusII_cfg.h.in
+++ b/include/exodusII_cfg.h.in
@@ -1,23 +1,56 @@
 // Copyright (c) 2005-2017 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.
-// 
+//
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are
 // met:
-// 
+//
 //     * Redistributions of source code must retain the above copyright
 //       notice, this list of conditions and the following disclaimer.
-// 
+//
 //     * Redistributions in binary form must reproduce the above
 //       copyright notice, this list of conditions and the following
 //       disclaimer in the documentation and/or other materials provided
-//       with the distribution.  
-// 
+//       with the distribution.
+//
 //     * Neither the name of NTESS nor the names of its
 //       contributors may be used to endorse or promote products derived
 //       from this software without specific prior written permission.
-// 
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+//|||||| parent of b406f69b6... cmake: use exodusII_cfg.h
+// Copyright (c) 2005-2017 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.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+//       notice, this list of conditions and the following disclaimer.
+//
+//     * Redistributions in binary form must reproduce the above
+//       copyright notice, this list of conditions and the following
+//       disclaimer in the documentation and/or other materials provided
+//       with the distribution.
+//
+//     * Neither the name of NTESS nor the names of its
+//       contributors may be used to endorse or promote products derived
+//       from this software without specific prior written permission.
+//
 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
diff --git a/include/exodusII_int.h b/include/exodusII_int.h
index 305a0872135..a13cac5ef65 100644
--- a/include/exodusII_int.h
+++ b/include/exodusII_int.h
@@ -60,6 +60,10 @@
 #include <inttypes.h>
 #endif
 
+#include <assert.h>
+#include <ctype.h>
+#include <string.h>
+
 #ifndef __APPLE__
 #if defined __STDC__ || defined __cplusplus
 #include <stdlib.h>
@@ -83,6 +87,8 @@
 #define snprintf _snprintf
 #endif
 
+#define snprintf_nowarn(...) (snprintf(__VA_ARGS__) < 0 ? abort() : (void)0)
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -212,6 +218,12 @@ EXODUS_EXPORT int indent;
 #define EX_FUNC_VOID() return
 #endif
 #endif
+
+#define EX_UNUSED(A)                                                                               \
+  do {                                                                                             \
+    (void)(A);                                                                                     \
+  } while (0)
+
 /*
  * This file contains defined constants that are used internally in the
  * EXODUS API.
@@ -847,6 +859,10 @@ int  ex_leavedef(int         exoid,    /* NemesisI file ID         */
                  const char *call_rout /* Name of calling function */
  );
 
+int ex_int_handle_mode(unsigned int my_mode, int is_parallel, int run_version);
+int ex_int_populate_header(int exoid, const char *path, int my_mode, int is_parallel, int *comp_ws,
+                           int *io_ws);
+
 int ex_int_get_block_param(int exoid, ex_entity_id id, int ndim,
                            struct elem_blk_parm *elem_blk_parm);
 
diff --git a/src/deprecated/ex_get_concat_node_sets.c b/src/deprecated/ex_get_concat_node_sets.c
index c97cdb21635..b624ca7b112 100644
--- a/src/deprecated/ex_get_concat_node_sets.c
+++ b/src/deprecated/ex_get_concat_node_sets.c
@@ -34,7 +34,6 @@
  */
 
 #include "exodusII.h" // for ex_set_specs, void_int, etc
-#include <stddef.h>   // for NULL
 
 /*!
 \deprecated Use ex_get_concat_sets()(exoid, EX_NODE_SET, set_specs) instead
diff --git a/src/deprecated/ex_get_elem_block.c b/src/deprecated/ex_get_elem_block.c
index 95db3172095..a7ad275aa01 100644
--- a/src/deprecated/ex_get_elem_block.c
+++ b/src/deprecated/ex_get_elem_block.c
@@ -36,7 +36,7 @@
 
 /**
 \deprecated Use ex_get_block()(exoid, EX_ELEM_BLOCK, elem_blk_id, elem_type,
-num_elem_this_blk, num_nodes_per_elem, num_attr) instead
+num_elem_this_blk, num_nodes_per_elem, NULL, NULL, num_attr) instead
 
 The function ex_get_elem_block() reads the parameters used to describe
 an element block. IDs of all element blocks stored can be determined
diff --git a/src/deprecated/ex_get_elem_var.c b/src/deprecated/ex_get_elem_var.c
index 7c976eacabb..e176733ae99 100644
--- a/src/deprecated/ex_get_elem_var.c
+++ b/src/deprecated/ex_get_elem_var.c
@@ -34,7 +34,6 @@
  */
 
 #include "exodusII.h" // for ex_get_var, ex_entity_id, etc
-#include <stdint.h>   // for int64_t
 
 /*!
 \deprecated Use ex_get_var()(exoid, time_step, EX_ELEM_BLOCK, elem_var_index,
diff --git a/src/deprecated/ex_get_elem_var_time.c b/src/deprecated/ex_get_elem_var_time.c
index 51302e78ef1..92d72f39613 100644
--- a/src/deprecated/ex_get_elem_var_time.c
+++ b/src/deprecated/ex_get_elem_var_time.c
@@ -53,7 +53,6 @@
  *****************************************************************************/
 
 #include "exodusII.h" // for ex_get_var_time, etc
-#include <stdint.h>   // for int64_t
 
 /*!
 \deprecated Use ex_get_var_time()(exoid, EX_ELEM_BLOCK, elem_var_index,
diff --git a/src/deprecated/ex_get_n_attr.c b/src/deprecated/ex_get_n_attr.c
index af287930703..d8dfc2df9be 100644
--- a/src/deprecated/ex_get_n_attr.c
+++ b/src/deprecated/ex_get_n_attr.c
@@ -34,7 +34,6 @@
  */
 
 #include "exodusII.h" // for ex_get_partial_attr, etc
-#include <stdint.h>   // for int64_t
 
 /*!
  * \deprecated Use ex_get_partial_attr()(exoid, obj_type, obj_id, start_num, num_ent, attrib)
diff --git a/src/deprecated/ex_get_n_conn.c b/src/deprecated/ex_get_n_conn.c
index 0d4d15bb8d9..4083f328776 100644
--- a/src/deprecated/ex_get_n_conn.c
+++ b/src/deprecated/ex_get_n_conn.c
@@ -34,7 +34,6 @@
  */
 
 #include "exodusII.h" // for void_int, etc
-#include <stdint.h>   // for int64_t
 
 /*!
  * \deprecated Use ex_get_partial_conn()(exoid, blk_type, blk_id, start_num, num_ent, nodeconn,
diff --git a/src/deprecated/ex_get_n_coord.c b/src/deprecated/ex_get_n_coord.c
index 7dd0d569937..2139dea2527 100644
--- a/src/deprecated/ex_get_n_coord.c
+++ b/src/deprecated/ex_get_n_coord.c
@@ -54,7 +54,6 @@
  *****************************************************************************/
 
 #include "exodusII.h" // for ex_get_partial_coord
-#include <stdint.h>   // for int64_t
 
 /*!
  *       \deprecated Use ex_get_partial_coord()(exoid, start_node_num, num_nodes, x_coor, y_coor,
diff --git a/src/deprecated/ex_get_n_elem_attr.c b/src/deprecated/ex_get_n_elem_attr.c
index 110c88f2daa..155ff0707c5 100644
--- a/src/deprecated/ex_get_n_elem_attr.c
+++ b/src/deprecated/ex_get_n_elem_attr.c
@@ -54,7 +54,6 @@
 /*****************************************************************************/
 /*****************************************************************************/
 #include "exodusII.h" // for ex_get_partial_attr, etc
-#include <stdint.h>   // for int64_t
 
 /*!
  * \deprecated Use ex_get_partial_attr()(exoid, EX_ELEM_BLOCK, elem_blk_id, start_elem_num,
diff --git a/src/deprecated/ex_get_n_elem_conn.c b/src/deprecated/ex_get_n_elem_conn.c
index f8f001e2211..0b70c29cbd4 100644
--- a/src/deprecated/ex_get_n_elem_conn.c
+++ b/src/deprecated/ex_get_n_elem_conn.c
@@ -54,8 +54,6 @@
 /*****************************************************************************/
 /*****************************************************************************/
 #include "exodusII.h" // for ex_get_partial_conn, etc
-#include <stddef.h>   // for NULL
-#include <stdint.h>   // for int64_t
 
 /*!
  * \deprecated use ex_get_partial_conn()(exoid, EX_ELEM_BLOCK, elem_blk_id, start_elem_num,
diff --git a/src/deprecated/ex_get_n_elem_num_map.c b/src/deprecated/ex_get_n_elem_num_map.c
index 1ffeab3813c..0476addf1d6 100644
--- a/src/deprecated/ex_get_n_elem_num_map.c
+++ b/src/deprecated/ex_get_n_elem_num_map.c
@@ -40,19 +40,18 @@
  *
  * entry conditions -
  *   input parameters:
- *	int	exoid			exodus file id
- *	int	start_ent		starting location for read
- *	int	num_ents		number of elemental points
+ *      int     exoid                   exodus file id
+ *      int     start_ent               starting location for read
+ *      int     num_ents                number of elemental points
  *
  * exit conditions -
- *	int*	elem_map		element number map array
+ *      int*    elem_map                element number map array
  *
  * revision history -
  *
  *****************************************************************************/
 
 #include "exodusII.h" // for ex_get_partial_id_map, etc
-#include <stdint.h>   // for int64_t
 
 /*!
  * \deprecated Use ex_get_partial_id_map()(exoid, EX_ELEM_MAP, start_ent, num_ents, elem_map)
diff --git a/src/deprecated/ex_get_n_elem_var.c b/src/deprecated/ex_get_n_elem_var.c
index bac54d9b570..99ac6234de9 100644
--- a/src/deprecated/ex_get_n_elem_var.c
+++ b/src/deprecated/ex_get_n_elem_var.c
@@ -34,7 +34,6 @@
  */
 
 #include "exodusII.h" // for ex_get_partial_var, etc
-#include <stdint.h>   // for int64_t
 
 /*!
 \ingroup ResultsData
diff --git a/src/deprecated/ex_get_n_nodal_var.c b/src/deprecated/ex_get_n_nodal_var.c
index 4b9fda4db9b..967301449f8 100644
--- a/src/deprecated/ex_get_n_nodal_var.c
+++ b/src/deprecated/ex_get_n_nodal_var.c
@@ -34,7 +34,6 @@
  */
 
 #include <exodusII.h> // for ex_get_partial_var, etc
-#include <stdint.h>   // for int64_t
 
 /*!
 \ingroup ResultsData
diff --git a/src/deprecated/ex_get_n_node_num_map.c b/src/deprecated/ex_get_n_node_num_map.c
index 9a5bd21e5f7..10c01d92008 100644
--- a/src/deprecated/ex_get_n_node_num_map.c
+++ b/src/deprecated/ex_get_n_node_num_map.c
@@ -40,10 +40,10 @@
  *
  * entry conditions -
  *   input parameters:
- *	int	exoid			nemesis file id
+ *      int     exoid                   nemesis file id
  *
  * exit conditions -
- *	int*	node_map		node numbering map array
+ *      int*    node_map                node numbering map array
  *
  * revision history -
  *
@@ -51,10 +51,9 @@
  *****************************************************************************/
 
 #include "exodusII.h" // for ex_get_partial_id_map, etc
-#include <stdint.h>   // for int64_t
 
 /*!
- *  \deprecated Use ex_get_partial_num_map()(exoid, EX_NODE_MAP, start_ent, num_ents, node_map)
+ *  \deprecated Use ex_get_partial_id_map()(exoid, EX_NODE_MAP, start_ent, num_ents, node_map)
  * instead
  */
 
diff --git a/src/deprecated/ex_get_n_node_set.c b/src/deprecated/ex_get_n_node_set.c
index b1141892ad1..a7a33ed409d 100644
--- a/src/deprecated/ex_get_n_node_set.c
+++ b/src/deprecated/ex_get_n_node_set.c
@@ -53,8 +53,6 @@
 /*****************************************************************************/
 
 #include "exodusII.h" // for ex_get_partial_set, etc
-#include <stddef.h>   // for NULL
-#include <stdint.h>   // for int64_t
 
 /*!
  * \deprecated Use ex_get_partial_set()(exoid, EX_NODE_SET, node_set_id, start_node_num, num_nodes,
diff --git a/src/deprecated/ex_get_n_node_set_df.c b/src/deprecated/ex_get_n_node_set_df.c
index e50ee34a234..23b6443afdc 100644
--- a/src/deprecated/ex_get_n_node_set_df.c
+++ b/src/deprecated/ex_get_n_node_set_df.c
@@ -34,7 +34,6 @@
  */
 
 #include "exodusII.h"
-#include <stdint.h> // for int64_t
 
 /*!
  * \deprecated Use ex_get_partial_set_dist_fact()(exoid, EX_NODE_SET, node_set_id, start_num,
diff --git a/src/deprecated/ex_get_n_one_attr.c b/src/deprecated/ex_get_n_one_attr.c
index 814baf1b837..5f7431b9230 100644
--- a/src/deprecated/ex_get_n_one_attr.c
+++ b/src/deprecated/ex_get_n_one_attr.c
@@ -34,7 +34,6 @@
  */
 
 #include "exodusII.h" // for ex_get_partial_one_attr, etc
-#include <stdint.h>   // for int64_t
 
 /*!
  * \deprecated Use ex_get_partial_one_attr()(exoid, obj_type, obj_id, start_num, num_ent,
diff --git a/src/deprecated/ex_get_n_side_set.c b/src/deprecated/ex_get_n_side_set.c
index 85aaf52d02b..aca86aa33b2 100644
--- a/src/deprecated/ex_get_n_side_set.c
+++ b/src/deprecated/ex_get_n_side_set.c
@@ -34,7 +34,6 @@
  */
 
 #include "exodusII.h" // for ex_get_partial_set, etc
-#include <stdint.h>   // for int64_t
 
 /*!
  * \deprecated Use ex_get_partial_side_set()(exoid, EX_SIDE_SET, side_set_id, start_side_num,
diff --git a/src/deprecated/ex_get_n_side_set_df.c b/src/deprecated/ex_get_n_side_set_df.c
index 2d19044f699..1bfbe2e9b99 100644
--- a/src/deprecated/ex_get_n_side_set_df.c
+++ b/src/deprecated/ex_get_n_side_set_df.c
@@ -53,7 +53,6 @@
 /*****************************************************************************/
 /*****************************************************************************/
 #include "exodusII.h"
-#include <stdint.h> // for int64_t
 
 /*!
  * \deprecated Use ex_get_partial_set_dist_fact()(exoid, EX_SIDE_SET, side_set_id, start_num,
diff --git a/src/deprecated/ex_get_n_var.c b/src/deprecated/ex_get_n_var.c
index e4f8853aad9..495a6682ed6 100644
--- a/src/deprecated/ex_get_n_var.c
+++ b/src/deprecated/ex_get_n_var.c
@@ -34,7 +34,6 @@
  */
 
 #include "exodusII.h" // for ex_get_partial_var, etc
-#include <stdint.h>   // for int64_t
 
 /*
  * reads the values of a single element variable for one element block at
diff --git a/src/deprecated/ex_get_nodal_var.c b/src/deprecated/ex_get_nodal_var.c
index e4219aece93..9c1e0d6d700 100644
--- a/src/deprecated/ex_get_nodal_var.c
+++ b/src/deprecated/ex_get_nodal_var.c
@@ -34,7 +34,6 @@
  */
 
 #include "exodusII.h" // for ex_get_var, etc
-#include <stdint.h>   // for int64_t
 
 /*!
 \deprecated Use ex_get_var()(exoid, time_step, EX_NODAL, nodal_var_index, 1, num_nodes,
diff --git a/src/deprecated/ex_get_nodal_var_time.c b/src/deprecated/ex_get_nodal_var_time.c
index 7d502e57122..5345686c5a6 100644
--- a/src/deprecated/ex_get_nodal_var_time.c
+++ b/src/deprecated/ex_get_nodal_var_time.c
@@ -34,7 +34,6 @@
  */
 
 #include "exodusII.h" // for ex_get_var_time, etc
-#include <stdint.h>   // for int64_t
 
 /*!
 \deprecated Use ex_get_var_time()(exoid, EX_NODAL, nodal_var_index,
diff --git a/src/deprecated/ex_get_node_set.c b/src/deprecated/ex_get_node_set.c
index 84ee6f87fb4..e4ca0ba4f5d 100644
--- a/src/deprecated/ex_get_node_set.c
+++ b/src/deprecated/ex_get_node_set.c
@@ -50,7 +50,6 @@
  *****************************************************************************/
 
 #include "exodusII.h" // for ex_get_set, ex_entity_id, etc
-#include <stdlib.h>   // for NULL
 
 /*!
  * reads the node list for a single node set
diff --git a/src/deprecated/ex_get_nset_var.c b/src/deprecated/ex_get_nset_var.c
index 4fd42d4ddab..bad78896cdb 100644
--- a/src/deprecated/ex_get_nset_var.c
+++ b/src/deprecated/ex_get_nset_var.c
@@ -55,7 +55,6 @@
  *****************************************************************************/
 
 #include "exodusII.h" // for ex_get_var, ex_entity_id, etc
-#include <stdint.h>   // for int64_t
 
 /*!
  * reads the values of a single nodeset variable for one nodeset at
diff --git a/src/deprecated/ex_get_partial_elem_attr.c b/src/deprecated/ex_get_partial_elem_attr.c
index f1a4ec672f7..d2b9c42bc6a 100644
--- a/src/deprecated/ex_get_partial_elem_attr.c
+++ b/src/deprecated/ex_get_partial_elem_attr.c
@@ -54,7 +54,6 @@
 /*****************************************************************************/
 /*****************************************************************************/
 #include "exodusII.h" // for ex_get_partial_attr, etc
-#include <stdint.h>   // for int64_t
 
 /*!
  * \deprecated use ex_get_partial_attr()(exoid, EX_ELEM_BLOCK, elem_blk_id, start_elem_num,
diff --git a/src/deprecated/ex_get_partial_elem_conn.c b/src/deprecated/ex_get_partial_elem_conn.c
index fec1347b6d0..04fbaed77ee 100644
--- a/src/deprecated/ex_get_partial_elem_conn.c
+++ b/src/deprecated/ex_get_partial_elem_conn.c
@@ -54,8 +54,6 @@
 /*****************************************************************************/
 /*****************************************************************************/
 #include "exodusII.h" // for ex_get_partial_conn, etc
-#include <stddef.h>   // for NULL
-#include <stdint.h>   // for int64_t
 
 /*!
  * \deprecated use ex_get_partial_conn()(exoid, EX_ELEM_BLOCK, elem_blk_id, start_elem_num,
diff --git a/src/deprecated/ex_get_partial_elem_map.c b/src/deprecated/ex_get_partial_elem_map.c
index 5615c63d4bc..af2b265f06a 100644
--- a/src/deprecated/ex_get_partial_elem_map.c
+++ b/src/deprecated/ex_get_partial_elem_map.c
@@ -34,7 +34,6 @@
  */
 
 #include "exodusII.h" // for ex_get_partial_num_map, etc
-#include <stdint.h>   // for int64_t
 
 /*
  * reads the element map with specified ID
diff --git a/src/deprecated/ex_get_partial_elem_num_map.c b/src/deprecated/ex_get_partial_elem_num_map.c
index 06208219c06..c7accb325c4 100644
--- a/src/deprecated/ex_get_partial_elem_num_map.c
+++ b/src/deprecated/ex_get_partial_elem_num_map.c
@@ -40,19 +40,18 @@
  *
  * entry conditions -
  *   input parameters:
- *	int	exoid			exodus file id
- *	int	start_ent		starting location for read
- *	int	num_ents		number of elemental points
+ *      int     exoid                   exodus file id
+ *      int     start_ent               starting location for read
+ *      int     num_ents                number of elemental points
  *
  * exit conditions -
- *	int*	elem_map		element number map array
+ *      int*    elem_map                element number map array
  *
  * revision history -
  *
  *****************************************************************************/
 
 #include "exodusII.h" // for ex_get_partial_id_map, etc
-#include <stdint.h>   // for int64_t
 
 /*
  *  reads the element numbering map from the database; allows element numbers
diff --git a/src/deprecated/ex_get_partial_elem_var.c b/src/deprecated/ex_get_partial_elem_var.c
index 74e8961828c..c462823bc97 100644
--- a/src/deprecated/ex_get_partial_elem_var.c
+++ b/src/deprecated/ex_get_partial_elem_var.c
@@ -57,7 +57,6 @@
 /*****************************************************************************/
 
 #include "exodusII.h" // for ex_get_partial_var, etc
-#include <stdint.h>   // for int64_t
 
 /*!
 \ingroup ResultsData
diff --git a/src/deprecated/ex_get_partial_nodal_var.c b/src/deprecated/ex_get_partial_nodal_var.c
index 88320236f39..ea73be7d732 100644
--- a/src/deprecated/ex_get_partial_nodal_var.c
+++ b/src/deprecated/ex_get_partial_nodal_var.c
@@ -40,14 +40,14 @@
  *
  * entry conditions -
  *   input parameters:
- *	int	exoid			exodus file id
- *	int	time_step		whole time step number
- *	int	nodeal_var_index	index of desired nodal variable
- *       int     start_node		starting location for read
- *	int	num_nodes		number of nodal points
+ *      int     exoid                   exodus file id
+ *      int     time_step               whole time step number
+ *      int     nodeal_var_index        index of desired nodal variable
+ *       int     start_node             starting location for read
+ *      int     num_nodes               number of nodal points
  *
  * exit conditions -
- *	float*	var_vals		array of nodal variable values
+ *      float*  var_vals                array of nodal variable values
  *
  * revision history -
  *
@@ -56,7 +56,6 @@
  *****************************************************************************/
 
 #include <exodusII.h> // for ex_get_partial_var, etc
-#include <stdint.h>   // for int64_t
 
 /*!
 \ingroup ResultsData
diff --git a/src/deprecated/ex_get_partial_node_num_map.c b/src/deprecated/ex_get_partial_node_num_map.c
index 1d08eb5b8fe..d4260c26c5c 100644
--- a/src/deprecated/ex_get_partial_node_num_map.c
+++ b/src/deprecated/ex_get_partial_node_num_map.c
@@ -40,17 +40,16 @@
  *
  * entry conditions -
  *   input parameters:
- *	int	exoid			nemesis file id
+ *      int     exoid                   nemesis file id
  *
  * exit conditions -
- *	int*	node_map		node numbering map array
+ *      int*    node_map                node numbering map array
  *
  * revision history -
  *
  *
  *****************************************************************************/
 #include "exodusII.h" // for ex_get_partial_id_map, etc
-#include <stdint.h>   // for int64_t
 
 /*
  *  reads the node numbering map from the database
diff --git a/src/deprecated/ex_get_partial_node_set.c b/src/deprecated/ex_get_partial_node_set.c
index f0a14897d9a..ea8d6424ef2 100644
--- a/src/deprecated/ex_get_partial_node_set.c
+++ b/src/deprecated/ex_get_partial_node_set.c
@@ -52,8 +52,6 @@
 /*****************************************************************************/
 /*****************************************************************************/
 #include "exodusII.h" // for ex_get_partial_set, etc
-#include <stddef.h>   // for NULL
-#include <stdint.h>   // for int64_t
 
 /*!
  * \deprecated use ex_get_partial_set()(exoid, EX_NODE_SET, node_set_id, start_node_num, num_nodes,
diff --git a/src/deprecated/ex_get_partial_node_set_df.c b/src/deprecated/ex_get_partial_node_set_df.c
index 96e41ad4494..8aa407c8da8 100644
--- a/src/deprecated/ex_get_partial_node_set_df.c
+++ b/src/deprecated/ex_get_partial_node_set_df.c
@@ -53,7 +53,6 @@
 /*****************************************************************************/
 /*****************************************************************************/
 #include "exodusII.h"
-#include <stdint.h> // for int64_t
 
 /*!
  * \deprecated use ex_get_partial_set_dist_fact()(exoid, EX_NODE_SET, node_set_id, start_num,
diff --git a/src/deprecated/ex_get_partial_side_set.c b/src/deprecated/ex_get_partial_side_set.c
index 4b3d9a8f77a..6d6121ceea9 100644
--- a/src/deprecated/ex_get_partial_side_set.c
+++ b/src/deprecated/ex_get_partial_side_set.c
@@ -54,7 +54,6 @@
 /*****************************************************************************/
 /*****************************************************************************/
 #include "exodusII.h" // for ex_get_partial_set, etc
-#include <stdint.h>   // for int64_t
 
 /*!
  * \deprecated use ex_get_partial_set()(exoid, EX_SIDE_SET, side_set_id, start_side_num, num_sides,
diff --git a/src/deprecated/ex_get_partial_side_set_df.c b/src/deprecated/ex_get_partial_side_set_df.c
index 8015bca9a14..ed90db22861 100644
--- a/src/deprecated/ex_get_partial_side_set_df.c
+++ b/src/deprecated/ex_get_partial_side_set_df.c
@@ -53,7 +53,6 @@
 /*****************************************************************************/
 /*****************************************************************************/
 #include "exodusII.h"
-#include <stdint.h> // for int64_t
 
 /*!
  * \deprecated Use ex_get_partial_set_dist_fact()(exoid, EX_SIDE_SET, side_set_id, start_num,
diff --git a/src/deprecated/ex_get_sset_var.c b/src/deprecated/ex_get_sset_var.c
index f8eebb4068a..9bc97e93676 100644
--- a/src/deprecated/ex_get_sset_var.c
+++ b/src/deprecated/ex_get_sset_var.c
@@ -55,7 +55,6 @@
  *****************************************************************************/
 
 #include "exodusII.h" // for ex_get_var, ex_entity_id, etc
-#include <stdint.h>   // for int64_t
 
 /*!
  * reads the values of a single sideset variable for one sideset at
diff --git a/src/deprecated/ex_put_concat_node_sets.c b/src/deprecated/ex_put_concat_node_sets.c
index 0720cc92b2d..62c21ec67d2 100644
--- a/src/deprecated/ex_put_concat_node_sets.c
+++ b/src/deprecated/ex_put_concat_node_sets.c
@@ -34,7 +34,6 @@
  */
 
 #include "exodusII.h" // for ex_set_specs, void_int, etc
-#include <stddef.h>   // for NULL
 
 /*!
 \deprecated Use ex_put_concat_sets()(exoid, EX_NODE_SET, &set_specs)
diff --git a/src/deprecated/ex_put_elem_block.c b/src/deprecated/ex_put_elem_block.c
index 8433790b171..58bd577eebb 100644
--- a/src/deprecated/ex_put_elem_block.c
+++ b/src/deprecated/ex_put_elem_block.c
@@ -51,7 +51,6 @@
  *****************************************************************************/
 
 #include "exodusII.h" // for ex_put_block, ex_entity_id, etc
-#include <stdint.h>   // for int64_t
 
 /*!
 \deprecated Use ex_put_block()(exoid, EX_ELEM_BLOCK, elem_blk_id, elem_type,
diff --git a/src/deprecated/ex_put_elem_var.c b/src/deprecated/ex_put_elem_var.c
index 70a2e5b5d5a..eecbd15ead8 100644
--- a/src/deprecated/ex_put_elem_var.c
+++ b/src/deprecated/ex_put_elem_var.c
@@ -55,7 +55,6 @@
  *****************************************************************************/
 
 #include "exodusII.h" // for ex_put_var, ex_entity_id, etc
-#include <stdint.h>   // for int64_t
 
 /*!
 \deprecated Use ex_put_var()(exoid, time_step, EX_ELEM_BLOCK, elem_var_index,
diff --git a/src/deprecated/ex_put_elem_var_slab.c b/src/deprecated/ex_put_elem_var_slab.c
index 4390fb4a2a9..84acc7ab118 100644
--- a/src/deprecated/ex_put_elem_var_slab.c
+++ b/src/deprecated/ex_put_elem_var_slab.c
@@ -56,7 +56,6 @@
 /*****************************************************************************/
 /*****************************************************************************/
 #include "exodusII.h" // for ex_put_partial_var, etc
-#include <stdint.h>   // for int64_t
 
 /*
  * writes the values of a single element variable for one element block,
diff --git a/src/deprecated/ex_put_n_attr.c b/src/deprecated/ex_put_n_attr.c
index a2298819185..8395e8405ef 100644
--- a/src/deprecated/ex_put_n_attr.c
+++ b/src/deprecated/ex_put_n_attr.c
@@ -51,7 +51,6 @@
  *****************************************************************************/
 
 #include "exodusII.h" // for ex_put_partial_attr, etc
-#include <stdint.h>   // for int64_t
 
 /*!
  * \deprecated use ex_put_partial_attr()(exoid, blk_type, blk_id, start_entity, num_entity, attrib)
diff --git a/src/deprecated/ex_put_n_coord.c b/src/deprecated/ex_put_n_coord.c
index 24e6cd991f6..4b45017d0ad 100644
--- a/src/deprecated/ex_put_n_coord.c
+++ b/src/deprecated/ex_put_n_coord.c
@@ -55,7 +55,6 @@
  *****************************************************************************/
 
 #include "exodusII.h" // for ex_put_partial_coord
-#include <stdint.h>   // for int64_t
 
 /*!
  * \deprecated Use ex_put_partial_coord()(exoid, start_node_num, num_nodes, x_coor, y_coor, z_coor)
diff --git a/src/deprecated/ex_put_n_elem_attr.c b/src/deprecated/ex_put_n_elem_attr.c
index 599a8b2ebbf..d76bd5cfb25 100644
--- a/src/deprecated/ex_put_n_elem_attr.c
+++ b/src/deprecated/ex_put_n_elem_attr.c
@@ -54,7 +54,6 @@
 /*****************************************************************************/
 /*****************************************************************************/
 #include "exodusII.h" // for ex_put_partial_attr, etc
-#include <stdint.h>   // for int64_t
 
 /*
  * \deprecated Use ex_put_partial_attr()(exoid, EX_ELEM_BLOCK, elem_blk_id, start_elem_num,
diff --git a/src/deprecated/ex_put_n_elem_conn.c b/src/deprecated/ex_put_n_elem_conn.c
index b4757410b68..ec6c13aecec 100644
--- a/src/deprecated/ex_put_n_elem_conn.c
+++ b/src/deprecated/ex_put_n_elem_conn.c
@@ -54,8 +54,6 @@
 /*****************************************************************************/
 /*****************************************************************************/
 #include "exodusII.h" // for ex_put_partial_conn, etc
-#include <stddef.h>   // for NULL
-#include <stdint.h>   // for int64_t
 
 /*!
  * \deprecated Use ex_put_partial_conn()(exoid, EX_ELEM_BLOCK, elem_blk_id, start_elem_num,
diff --git a/src/deprecated/ex_put_n_elem_num_map.c b/src/deprecated/ex_put_n_elem_num_map.c
index 5d1c786dfe8..36fb0ef37a9 100644
--- a/src/deprecated/ex_put_n_elem_num_map.c
+++ b/src/deprecated/ex_put_n_elem_num_map.c
@@ -40,9 +40,9 @@
  *
  * entry conditions -
  *   input parameters:
- *	int	exoid			exodus file id
- *	int	start_ent		first entry in elem_map
- *	int	num_ents		number of entries in node_map
+ *      int     exoid                   exodus file id
+ *      int     start_ent               first entry in elem_map
+ *      int     num_ents                number of entries in node_map
  *       int*    elem_map                element numbering map array
  *
  * exit conditions -
@@ -53,7 +53,6 @@
  *****************************************************************************/
 
 #include "exodusII.h" // for ex_put_partial_id_map, etc
-#include <stdint.h>   // for int64_t
 
 /*!
  * \deprecated Use ex_put_partial_id_map()(exoid, EX_ELEM_MAP, start_ent, num_ents, elem_map)
diff --git a/src/deprecated/ex_put_n_nodal_var.c b/src/deprecated/ex_put_n_nodal_var.c
index 4373ca0f21d..956ad636323 100644
--- a/src/deprecated/ex_put_n_nodal_var.c
+++ b/src/deprecated/ex_put_n_nodal_var.c
@@ -53,7 +53,6 @@
  *****************************************************************************/
 
 #include "exodusII.h" // for ex_put_partial_var, etc
-#include <stdint.h>   // for int64_t
 
 /*!
 \ingroup ResultsData
diff --git a/src/deprecated/ex_put_n_node_num_map.c b/src/deprecated/ex_put_n_node_num_map.c
index 33056106a04..91d558da5a6 100644
--- a/src/deprecated/ex_put_n_node_num_map.c
+++ b/src/deprecated/ex_put_n_node_num_map.c
@@ -39,9 +39,9 @@
  *
  * entry conditions -
  *   input parameters:
- *	int	exoid			exodus file id
- *	int	start_ent		first entry in node_map
- *	int	num_ents		number of entries in node_map
+ *      int     exoid                   exodus file id
+ *      int     start_ent               first entry in node_map
+ *      int     num_ents                number of entries in node_map
  *       int*    node_map                node numbering map
  *
  * exit conditions -
@@ -52,7 +52,6 @@
  *****************************************************************************/
 
 #include "exodusII.h" // for ex_put_partial_id_map, etc
-#include <stdint.h>   // for int64_t
 
 /*!
  * \deprecated Use ex_put_partial_id_map()(exoid, EX_NODE_MAP, start_ent, num_ents, node_map)
diff --git a/src/deprecated/ex_put_n_node_set.c b/src/deprecated/ex_put_n_node_set.c
index 99d22cb4a99..ea438407fb9 100644
--- a/src/deprecated/ex_put_n_node_set.c
+++ b/src/deprecated/ex_put_n_node_set.c
@@ -54,8 +54,6 @@
 /*****************************************************************************/
 
 #include "exodusII.h" // for ex_put_partial_set, etc
-#include <stddef.h>   // for NULL
-#include <stdint.h>   // for int64_t
 
 /*
  * \deprecated Use ex_put_partial_set()(exoid, EX_NODE_SET, node_set_id, start_node_num, num_nodes,
diff --git a/src/deprecated/ex_put_n_node_set_df.c b/src/deprecated/ex_put_n_node_set_df.c
index 940b795b2be..28361174cfc 100644
--- a/src/deprecated/ex_put_n_node_set_df.c
+++ b/src/deprecated/ex_put_n_node_set_df.c
@@ -54,7 +54,6 @@
 /*****************************************************************************/
 /*****************************************************************************/
 #include "exodusII.h"
-#include <stdint.h> // for int64_t
 
 /*!
  * \deprecated Use ex_put_partial_set_dist_fact()(exoid, EX_NODE_SET, node_set_id, start_num,
diff --git a/src/deprecated/ex_put_n_one_attr.c b/src/deprecated/ex_put_n_one_attr.c
index 601ac861fd9..c1038a433d1 100644
--- a/src/deprecated/ex_put_n_one_attr.c
+++ b/src/deprecated/ex_put_n_one_attr.c
@@ -50,7 +50,6 @@
  *****************************************************************************/
 
 #include "exodusII.h" // for ex_put_partial_one_attr, etc
-#include <stdint.h>   // for int64_t
 
 /*!
  * \deprecated Use ex_put_partial_one_attr()(exoid, obj_type, obj_id, start_num, num_ent,
diff --git a/src/deprecated/ex_put_n_side_set.c b/src/deprecated/ex_put_n_side_set.c
index 30d827a3413..517f0d0999c 100644
--- a/src/deprecated/ex_put_n_side_set.c
+++ b/src/deprecated/ex_put_n_side_set.c
@@ -55,7 +55,6 @@
 /*****************************************************************************/
 /*****************************************************************************/
 #include "exodusII.h" // for ex_put_partial_set, etc
-#include <stdint.h>   // for int64_t
 
 /*!
  * \deprecated use ex_put_partial_set()(exoid, EX_SIDE_SET, side_set_id, start_side_num, num_sides,
diff --git a/src/deprecated/ex_put_n_side_set_df.c b/src/deprecated/ex_put_n_side_set_df.c
index f1a541d4e86..3aade9196e0 100644
--- a/src/deprecated/ex_put_n_side_set_df.c
+++ b/src/deprecated/ex_put_n_side_set_df.c
@@ -54,7 +54,6 @@
 /*****************************************************************************/
 /*****************************************************************************/
 #include "exodusII.h"
-#include <stdint.h> // for int64_t
 
 /*!
  * \deprecated use ex_put_partial_set_dist_fact()(exoid, EX_SIDE_SET, side_set_id, start_num,
diff --git a/src/deprecated/ex_put_n_var.c b/src/deprecated/ex_put_n_var.c
index 8e595628033..4af6d15ea19 100644
--- a/src/deprecated/ex_put_n_var.c
+++ b/src/deprecated/ex_put_n_var.c
@@ -60,7 +60,6 @@
  *****************************************************************************/
 
 #include "exodusII.h" // for ex_put_partial_var, etc
-#include <stdint.h>   // for int64_t
 
 /*!
 \ingroup ResultsData
diff --git a/src/deprecated/ex_put_nodal_var_slab.c b/src/deprecated/ex_put_nodal_var_slab.c
index c3d83ad0f2e..b89740cc2f9 100644
--- a/src/deprecated/ex_put_nodal_var_slab.c
+++ b/src/deprecated/ex_put_nodal_var_slab.c
@@ -56,7 +56,6 @@
 /*****************************************************************************/
 /*****************************************************************************/
 #include "exodusII.h" // for ex_put_partial_var, etc
-#include <stdint.h>   // for int64_t
 
 /*
  * writes the values of a single nodal variable for a single time step to
diff --git a/src/deprecated/ex_put_node_set.c b/src/deprecated/ex_put_node_set.c
index 48bb8a9b14e..77d1c6658bb 100644
--- a/src/deprecated/ex_put_node_set.c
+++ b/src/deprecated/ex_put_node_set.c
@@ -34,7 +34,6 @@
  */
 
 #include "exodusII.h" // for ex_put_set, ex_entity_id, etc
-#include <stddef.h>   // for NULL
 
 /*!
 \deprecated Use ex_put_set()(exoid, EX_NODE_SET, node_set_id,
diff --git a/src/deprecated/ex_put_node_set_param.c b/src/deprecated/ex_put_node_set_param.c
index d0ee20d06f1..e5f2f8a9026 100644
--- a/src/deprecated/ex_put_node_set_param.c
+++ b/src/deprecated/ex_put_node_set_param.c
@@ -34,7 +34,6 @@
  */
 
 #include "exodusII.h" // for ex_put_set_param, etc
-#include <stdint.h>   // for int64_t
 
 /*!
 \deprecated Use ex_put_set_param()(exoid, EX_NODE_SET, node_set_id,
diff --git a/src/deprecated/ex_put_nset_var.c b/src/deprecated/ex_put_nset_var.c
index c7acdbcceb2..c77d403c7ba 100644
--- a/src/deprecated/ex_put_nset_var.c
+++ b/src/deprecated/ex_put_nset_var.c
@@ -55,7 +55,6 @@
  *****************************************************************************/
 
 #include "exodusII.h" // for ex_put_var, ex_entity_id, etc
-#include <stdint.h>   // for int64_t
 
 /*!
  * writes the values of a single nodeset variable for one nodeset at
diff --git a/src/deprecated/ex_put_partial_elem_attr.c b/src/deprecated/ex_put_partial_elem_attr.c
index 89ff5e700a8..ce44cd72eb5 100644
--- a/src/deprecated/ex_put_partial_elem_attr.c
+++ b/src/deprecated/ex_put_partial_elem_attr.c
@@ -54,7 +54,6 @@
 /*****************************************************************************/
 /*****************************************************************************/
 #include "exodusII.h" // for ex_put_partial_attr, etc
-#include <stdint.h>   // for int64_t
 
 /*!
  * \deprecated Use ex_put_partial_attr()(exoid, EX_ELEM_BLOCK, elem_blk_id, start_elem_num,
diff --git a/src/deprecated/ex_put_partial_elem_conn.c b/src/deprecated/ex_put_partial_elem_conn.c
index 292e86a6ced..5e613840262 100644
--- a/src/deprecated/ex_put_partial_elem_conn.c
+++ b/src/deprecated/ex_put_partial_elem_conn.c
@@ -54,8 +54,6 @@
 /*****************************************************************************/
 /*****************************************************************************/
 #include "exodusII.h" // for ex_put_partial_conn, etc
-#include <stddef.h>   // for NULL
-#include <stdint.h>   // for int64_t
 
 /*!
  * \deprecated Use ex_put_partial_conn()(exoid, EX_ELEM_BLOCK, elem_blk_id, start_elem_num,
diff --git a/src/deprecated/ex_put_partial_elem_map.c b/src/deprecated/ex_put_partial_elem_map.c
index 54176470cac..722710373f7 100644
--- a/src/deprecated/ex_put_partial_elem_map.c
+++ b/src/deprecated/ex_put_partial_elem_map.c
@@ -52,7 +52,6 @@
  *****************************************************************************/
 
 #include "exodusII.h" // for ex_put_partial_num_map, etc
-#include <stdint.h>   // for int64_t
 
 /*!
  * writes an element map; this is a vector of integers of length number
diff --git a/src/deprecated/ex_put_partial_elem_num_map.c b/src/deprecated/ex_put_partial_elem_num_map.c
index 77be9760f28..16d8a13ff3b 100644
--- a/src/deprecated/ex_put_partial_elem_num_map.c
+++ b/src/deprecated/ex_put_partial_elem_num_map.c
@@ -40,9 +40,9 @@
  *
  * entry conditions -
  *   input parameters:
- *	int	exoid			exodus file id
- *	int	start_ent		first entry in elem_map
- *	int	num_ents		number of entries in node_map
+ *      int     exoid                   exodus file id
+ *      int     start_ent               first entry in elem_map
+ *      int     num_ents                number of entries in node_map
  *       int*    elem_map                element numbering map array
  *
  * exit conditions -
@@ -53,7 +53,6 @@
  *****************************************************************************/
 
 #include "exodusII.h" // for ex_put_partial_id_map, etc
-#include <stdint.h>   // for int64_t
 
 /*!
  * \deprecated Use ex_put_partial_id_map()(exoid, EX_ELEM_MAP, start_ent, num_ents, elem_map)
diff --git a/src/deprecated/ex_put_partial_nodal_var.c b/src/deprecated/ex_put_partial_nodal_var.c
index a734b4426da..7fafbac702f 100644
--- a/src/deprecated/ex_put_partial_nodal_var.c
+++ b/src/deprecated/ex_put_partial_nodal_var.c
@@ -53,7 +53,6 @@
  *****************************************************************************/
 
 #include "exodusII.h" // for ex_put_partial_var, etc
-#include <stdint.h>   // for int64_t
 
 /*!
 \ingroup ResultsData
diff --git a/src/deprecated/ex_put_partial_node_num_map.c b/src/deprecated/ex_put_partial_node_num_map.c
index af0495889b2..97033fa1574 100644
--- a/src/deprecated/ex_put_partial_node_num_map.c
+++ b/src/deprecated/ex_put_partial_node_num_map.c
@@ -39,9 +39,9 @@
  *
  * entry conditions -
  *   input parameters:
- *	int	exoid			exodus file id
- *	int	start_ent		first entry in node_map
- *	int	num_ents		number of entries in node_map
+ *      int     exoid                   exodus file id
+ *      int     start_ent               first entry in node_map
+ *      int     num_ents                number of entries in node_map
  *       int*    node_map                node numbering map
  *
  * exit conditions -
@@ -52,7 +52,6 @@
  *****************************************************************************/
 
 #include "exodusII.h" // for ex_put_partial_id_map, etc
-#include <stdint.h>   // for int64_t
 
 /*!
  * \deprecated Use ex_put_partial_id_map()(exoid, EX_NODE_MAP, start_ent, num_ents, node_map)
diff --git a/src/deprecated/ex_put_partial_node_set.c b/src/deprecated/ex_put_partial_node_set.c
index c2bd08eea82..ab4e5c8a8f3 100644
--- a/src/deprecated/ex_put_partial_node_set.c
+++ b/src/deprecated/ex_put_partial_node_set.c
@@ -53,8 +53,6 @@
 /*****************************************************************************/
 /*****************************************************************************/
 #include "exodusII.h" // for ex_put_partial_set, etc
-#include <stddef.h>   // for NULL
-#include <stdint.h>   // for int64_t
 
 /*!
  * \deprecated Use ex_put_partial_set()(exoid, EX_NODE_SET, node_set_id, start_node_num, num_nodes,
diff --git a/src/deprecated/ex_put_partial_node_set_df.c b/src/deprecated/ex_put_partial_node_set_df.c
index 4c0d55854f2..7d25f239c19 100644
--- a/src/deprecated/ex_put_partial_node_set_df.c
+++ b/src/deprecated/ex_put_partial_node_set_df.c
@@ -54,7 +54,6 @@
 /*****************************************************************************/
 /*****************************************************************************/
 #include "exodusII.h"
-#include <stdint.h> // for int64_t
 
 /*!
  * \deprecated Use ex_put_partial_set_dist_fact()(exoid, EX_NODE_SET, node_set_id, start_num,
diff --git a/src/deprecated/ex_put_partial_side_set.c b/src/deprecated/ex_put_partial_side_set.c
index d6e2857d998..897c62fc606 100644
--- a/src/deprecated/ex_put_partial_side_set.c
+++ b/src/deprecated/ex_put_partial_side_set.c
@@ -55,7 +55,6 @@
 /*****************************************************************************/
 /*****************************************************************************/
 #include "exodusII.h" // for ex_put_partial_set, etc
-#include <stdint.h>   // for int64_t
 
 /*
  * writes the side set element list and side set side list for a single side set
diff --git a/src/deprecated/ex_put_partial_side_set_df.c b/src/deprecated/ex_put_partial_side_set_df.c
index 7953f650093..44e63aa1203 100644
--- a/src/deprecated/ex_put_partial_side_set_df.c
+++ b/src/deprecated/ex_put_partial_side_set_df.c
@@ -54,7 +54,6 @@
 /*****************************************************************************/
 /*****************************************************************************/
 #include "exodusII.h"
-#include <stdint.h> // for int64_t
 
 /*
  * writes the distribution factors for a single side set
diff --git a/src/deprecated/ex_put_side_set_param.c b/src/deprecated/ex_put_side_set_param.c
index 9b0a1be82be..d4274ab330f 100644
--- a/src/deprecated/ex_put_side_set_param.c
+++ b/src/deprecated/ex_put_side_set_param.c
@@ -52,7 +52,6 @@
  *****************************************************************************/
 
 #include "exodusII.h" // for ex_put_set_param, etc
-#include <stdint.h>   // for int64_t
 
 /*!
  * writes the side set id and the number of sides (edges or faces)
diff --git a/src/deprecated/ex_put_sset_var.c b/src/deprecated/ex_put_sset_var.c
index c4aef652f38..d83107be3a6 100644
--- a/src/deprecated/ex_put_sset_var.c
+++ b/src/deprecated/ex_put_sset_var.c
@@ -55,7 +55,6 @@
  *****************************************************************************/
 
 #include "exodusII.h" // for ex_put_var, ex_entity_id, etc
-#include <stdint.h>   // for int64_t
 
 /*!
  * writes the values of a single sideset variable for one sideset at
diff --git a/src/ex_add_attr.c b/src/ex_add_attr.c
index a634105c974..946314b1213 100644
--- a/src/ex_add_attr.c
+++ b/src/ex_add_attr.c
@@ -34,12 +34,6 @@
  */
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, EX_NOERR, EX_WARN, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_def_var, etc
-#include <inttypes.h>     // for PRId64
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <string.h>    // for strlen
-#include <sys/types.h> // for int64_t
 
 int ex_add_attr(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, int64_t num_attr_per_entry)
 {
@@ -78,13 +72,13 @@ int ex_add_attr(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, int64_t
           snprintf(errmsg, MAX_ERR_LENGTH,
                    "Warning: no attributes found for NULL %s %" PRId64 " in file id %d",
                    ex_name_of_object(obj_type), obj_id, exoid);
-          ex_err(__func__, errmsg, EX_NULLENTITY);
+          ex_err_fn(exoid, __func__, errmsg, EX_NULLENTITY);
           EX_FUNC_LEAVE(EX_WARN); /* no attributes for this object */
         }
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "Warning: failed to locate %s id %" PRId64 " in id array in file id %d",
                  ex_name_of_object(obj_type), obj_id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_WARN);
       }
     }
@@ -148,7 +142,7 @@ int ex_add_attr(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, int64_t
   default:
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: Bad block type (%d) specified for file id %d",
              obj_type, exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -156,7 +150,7 @@ int ex_add_attr(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, int64_t
   /* put netcdf file into define mode  */
   if ((status = nc_redef(exoid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to place file id %d into define mode", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -164,7 +158,7 @@ int ex_add_attr(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, int64_t
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to define number of attributes in %s %" PRId64 " in file id %d",
              ex_name_of_object(obj_type), obj_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     goto error_ret; /* exit define mode and return */
   }
 
@@ -177,7 +171,7 @@ int ex_add_attr(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, int64_t
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR:  failed to define attributes for %s %" PRId64 " in file id %d",
              ex_name_of_object(obj_type), obj_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     goto error_ret; /* exit define mode and return */
   }
   ex_compress_variable(exoid, varid, 2);
@@ -185,7 +179,7 @@ int ex_add_attr(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, int64_t
   /* inquire previously defined dimensions  */
   if ((status = nc_inq_dimid(exoid, DIM_STR_NAME, &strdim)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get string length in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -197,16 +191,13 @@ int ex_add_attr(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, int64_t
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to define %s attribute name array in file id %d",
              ex_name_of_object(obj_type), exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     goto error_ret; /* exit define mode and return */
   }
 
   /* leave define mode  */
 
-  if ((status = nc_enddef(exoid)) != NC_NOERR) {
-    snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to complete %s definition in file id %d",
-             ex_name_of_object(obj_type), exoid);
-    ex_err(__func__, errmsg, status);
+  if ((status = ex_leavedef(exoid, __func__)) != NC_NOERR) {
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -223,7 +214,7 @@ int ex_add_attr(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, int64_t
     start[1] = 0;
     count[1] = strlen(text) + 1;
 
-    for (i = 0; i < num_attr_per_entry; i++) {
+    for (i = 0; i < (size_t)num_attr_per_entry; i++) {
       start[0] = i;
       nc_put_vara_text(exoid, att_name_varid, start, count, text);
     }
@@ -233,9 +224,6 @@ int ex_add_attr(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, int64_t
 
 /* Fatal error: exit definition mode and return */
 error_ret:
-  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);
-  }
+  ex_leavedef(exoid, __func__);
   EX_FUNC_LEAVE(EX_FATAL);
 }
diff --git a/src/ex_close.c b/src/ex_close.c
index 4109a944279..aa1326cb82a 100644
--- a/src/ex_close.c
+++ b/src/ex_close.c
@@ -49,8 +49,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for ex_get_counter_list, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_close, etc
-#include <stdio.h>
 
 /*!
 
@@ -98,19 +96,19 @@ int ex_close(int exoid)
    */
   if ((status = nc_inq_grp_parent(exoid, &parent_id)) != NC_ENOGRP) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: file id %d does not refer to root group.", exoid);
-    ex_err(__func__, errmsg, EX_NOTROOTID);
+    ex_err_fn(exoid, __func__, errmsg, EX_NOTROOTID);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 #endif
 
   if ((status1 = nc_sync(exoid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to update file id %d", exoid);
-    ex_err(__func__, errmsg, status1);
+    ex_err_fn(exoid, __func__, errmsg, status1);
   }
 
   if ((status2 = nc_close(exoid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to close file id %d", exoid);
-    ex_err(__func__, errmsg, status2);
+    ex_err_fn(exoid, __func__, errmsg, status2);
   }
 
   /* Even if we have failures above due to nc_sync() or nc_close(), we still need to clean up our
diff --git a/src/ex_conv.c b/src/ex_conv.c
index e61d39e3bab..2ce9f965c7f 100644
--- a/src/ex_conv.c
+++ b/src/ex_conv.c
@@ -47,9 +47,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for ex_file_item, EX_FATAL, etc
-#include "vtk_netcdf.h"       // for nc_inq_format, nc_type, etc
-#include <stdio.h>
-#include <stdlib.h> // for NULL, free, malloc
 
 /*! \file
  * this file contains code needed to support the various floating point word
@@ -87,7 +84,7 @@ void ex_check_valid_file_id(int exoid, const char *func)
   if (exoid <= 0) {
     error = 1;
   }
-#if !defined EXODUS_IN_SIERRA
+#if !defined BUILT_IN_SIERRA
   else {
     struct ex_file_item *file = ex_find_file_item(exoid);
 
@@ -159,11 +156,14 @@ int ex_conv_ini(int exoid, int *comp_wordsize, int *io_wordsize, int file_wordsi
   EX_FUNC_ENTER();
 
   /* check to make sure machine word sizes are sane */
-  if ((sizeof(float) != 4 && sizeof(float) != 8) || (sizeof(double) != 4 && sizeof(double) != 8)) {
-    snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: unsupported compute word size for file id: %d", exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
-    EX_FUNC_LEAVE(EX_FATAL);
-  }
+/* If the following line causes a compile-time error, then there is a problem
+ * which will cause exodus to not work correctly on this platform.
+ *
+ * Contact Greg Sjaardema, gdsjaar@sandia.gov for asisstance.
+ */
+#define CT_ASSERT(e) extern char(*ct_assert(void))[sizeof(char[1 - 2 * !(e)])]
+  CT_ASSERT((sizeof(float) == 4 || sizeof(float) == 8) &&
+            (sizeof(double) == 4 || sizeof(double) == 8));
 
   /* check to see if requested word sizes are valid */
   if (!*io_wordsize) {
@@ -177,7 +177,7 @@ int ex_conv_ini(int exoid, int *comp_wordsize, int *io_wordsize, int file_wordsi
 
   else if (*io_wordsize != 4 && *io_wordsize != 8) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: unsupported I/O word size for file id: %d", exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -187,14 +187,14 @@ int ex_conv_ini(int exoid, int *comp_wordsize, int *io_wordsize, int file_wordsi
              "ERROR: invalid I/O word size specified for existing file id: "
              "%d, Requested I/O word size overridden.",
              exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
   }
 
   if (!*comp_wordsize) {
     *comp_wordsize = sizeof(float);
   }
   else if (*comp_wordsize != 4 && *comp_wordsize != 8) {
-    ex_err(__func__, "ERROR: invalid compute wordsize specified", EX_BADPARAM);
+    ex_err_fn(exoid, __func__, "ERROR: invalid compute wordsize specified", EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -206,7 +206,7 @@ int ex_conv_ini(int exoid, int *comp_wordsize, int *io_wordsize, int file_wordsi
                "Warning: invalid int64_status flag (%d) specified for "
                "existing file id: %d. Ignoring invalids",
                int64_status, exoid);
-      ex_err(__func__, errmsg, EX_BADPARAM);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     }
     int64_status &= valid_int64;
   }
@@ -225,7 +225,7 @@ int ex_conv_ini(int exoid, int *comp_wordsize, int *io_wordsize, int file_wordsi
              "ERROR: failed to allocate memory for internal file "
              "structure storage file id %d",
              exoid);
-    ex_err(__func__, errmsg, EX_MEMFAIL);
+    ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -411,7 +411,7 @@ int ex_set_option(int exoid, ex_option_type option, int option_value)
   case EX_OPT_COMPRESSION_TYPE: /* Currently not used. GZip by default */ break;
   case EX_OPT_COMPRESSION_LEVEL: /* 0 (disabled/fastest) ... 9 (best/slowest) */
     /* Check whether file type supports compression... */
-    if (file->file_type == 2 || file->file_type == 3) {
+    if (file->is_hdf5) {
       int value = option_value;
       if (value > 9) {
         value = 9;
@@ -435,7 +435,7 @@ int ex_set_option(int exoid, ex_option_type option, int option_value)
   default: {
     char errmsg[MAX_ERR_LENGTH];
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: invalid option %d for ex_set_option().", (int)option);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
   }
@@ -482,3 +482,32 @@ int ex_is_parallel(int exoid)
   /* Stored as 1 for parallel, 0 for serial or file-per-processor */
   EX_FUNC_LEAVE(file->is_parallel);
 }
+
+/*! ex_set_parallel() sets the parallel setting for a file.
+ * returns 1 (true) or 0 (false) depending on the current setting.
+ * Do not use this unless you know what you are doing and why you
+ * are doing it.  One use is if calling ex_get_partial_set() in a
+ * serial mode (proc 0 only) on a file opened in parallel.
+ * Make sure to reset the value to original value after done with
+ * special case...
+ * \param exoid  integer which uniquely identifies the file of interest.
+ * \param is_parallel 1 if parallel, 0 if serial.
+ */
+int ex_set_parallel(int exoid, int is_parallel)
+{
+  EX_FUNC_ENTER();
+  int                  old_value = 0;
+  struct ex_file_item *file      = ex_find_file_item(exoid);
+
+  if (!file) {
+    char errmsg[MAX_ERR_LENGTH];
+    snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: unknown file id %d", exoid);
+    ex_err(__func__, errmsg, EX_BADFILEID);
+    EX_FUNC_LEAVE(EX_FATAL);
+  }
+
+  old_value         = file->is_parallel;
+  file->is_parallel = is_parallel;
+  /* Stored as 1 for parallel, 0 for serial or file-per-processor */
+  EX_FUNC_LEAVE(old_value);
+}
diff --git a/src/ex_copy.c b/src/ex_copy.c
index 649fbf268c3..043a582bc69 100644
--- a/src/ex_copy.c
+++ b/src/ex_copy.c
@@ -35,13 +35,6 @@
 
 #include "exodusII.h"     // for EX_FATAL, exerrval, ex_err, etc
 #include "exodusII_int.h" // for ex_get_counter_list, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_inq_varid, etc
-#include <assert.h>       // for assert
-#include <stddef.h>       // for size_t
-#include <stdint.h>       // for int64_t
-#include <stdio.h>        // for fprintf, stderr, snprintf
-#include <stdlib.h>       // for free, calloc, malloc
-#include <string.h>       // for strcmp, strncmp, NULL
 
 #define STRINGIFY(x) #x
 #define TOSTRING(x) STRINGIFY(x)
@@ -170,9 +163,9 @@ int ex_copy(int in_exoid, int out_exoid)
    * Currently they should both match or there will be an error.
    */
   if (ex_int64_status(in_exoid) != ex_int64_status(out_exoid)) {
-    snprintf(errmsg, MAX_ERR_LENGTH,
-             "ERROR: integer sizes do not match for input and output databases.");
-    ex_err(__func__, errmsg, EX_WRONGFILETYPE);
+    snprintf_nowarn(errmsg, MAX_ERR_LENGTH,
+                    "ERROR: integer sizes do not match for input and output databases.");
+    ex_err_fn(in_exoid, __func__, errmsg, EX_WRONGFILETYPE);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -189,10 +182,7 @@ int ex_copy(int in_exoid, int out_exoid)
   EXCHECK(cpy_variables(in_exoid, out_exoid, in_large, mesh_only));
 
   /* take the output file out of define mode */
-  if ((status = nc_enddef(out_exoid)) != NC_NOERR) {
-    snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to complete definition in file id %d",
-             out_exoid);
-    ex_err(__func__, errmsg, status);
+  if ((status = ex_leavedef(out_exoid, __func__)) != NC_NOERR) {
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -229,9 +219,9 @@ int ex_copy_transient(int in_exoid, int out_exoid)
    * Currently they should both match or there will be an error.
    */
   if (ex_int64_status(in_exoid) != ex_int64_status(out_exoid)) {
-    snprintf(errmsg, MAX_ERR_LENGTH,
-             "ERROR: integer sizes do not match for input and output databases.");
-    ex_err(__func__, errmsg, EX_WRONGFILETYPE);
+    snprintf_nowarn(errmsg, MAX_ERR_LENGTH,
+                    "ERROR: integer sizes do not match for input and output databases.");
+    ex_err_fn(in_exoid, __func__, errmsg, EX_WRONGFILETYPE);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -248,10 +238,7 @@ int ex_copy_transient(int in_exoid, int out_exoid)
   EXCHECK(cpy_variables(in_exoid, out_exoid, in_large, mesh_only));
 
   /* take the output file out of define mode */
-  if ((status = nc_enddef(out_exoid)) != NC_NOERR) {
-    snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to complete definition in file id %d",
-             out_exoid);
-    ex_err(__func__, errmsg, status);
+  if ((status = ex_leavedef(out_exoid, __func__)) != NC_NOERR) {
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -400,9 +387,9 @@ int cpy_dimension(int in_exoid, int out_exoid, int mesh_only)
           status = nc_def_dim(out_exoid, dim_nm, NC_UNLIMITED, &dim_out_id);
         }
         if (status != NC_NOERR) {
-          snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define %s dimension in file id %d",
-                   dim_nm, out_exoid);
-          ex_err(__func__, errmsg, status);
+          snprintf_nowarn(errmsg, MAX_ERR_LENGTH,
+                          "ERROR: failed to define %s dimension in file id %d", dim_nm, out_exoid);
+          ex_err_fn(out_exoid, __func__, errmsg, status);
           EX_FUNC_LEAVE(EX_FATAL);
         }
       }
@@ -425,9 +412,9 @@ int cpy_dimension(int in_exoid, int out_exoid, int mesh_only)
       /* Not found; set to default value of 32+1. */
 
       if ((status = nc_def_dim(out_exoid, DIM_STR_NAME, 33, &dim_out_id)) != NC_NOERR) {
-        snprintf(errmsg, MAX_ERR_LENGTH,
-                 "ERROR: failed to define string name dimension in file id %d", out_exoid);
-        ex_err(__func__, errmsg, status);
+        snprintf_nowarn(errmsg, MAX_ERR_LENGTH,
+                        "ERROR: failed to define string name dimension in file id %d", out_exoid);
+        ex_err_fn(out_exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
     }
diff --git a/src/ex_create.c b/src/ex_create.c
index d3a4b60eab2..3572a1d5019 100644
--- a/src/ex_create.c
+++ b/src/ex_create.c
@@ -92,7 +92,7 @@ alias.
 
 \arg EX_NORMAL_MODEL Create a standard model.
 
-\arg EX_64BIT_DATA	To create a model using the CDF5 format which uses the
+\arg EX_64BIT_DATA      To create a model using the CDF5 format which uses the
                         classic model but has 64-bit dimensions and sizes.
                         This type will also be created if the
                         environment variable EXODUS_NETCDF5 is defined in the
@@ -100,7 +100,7 @@ alias.
                         output if
                         this environment variable is found.
 
-\arg EX_NETCDF4	To create a model using the HDF5-based NetCDF-4
+\arg EX_NETCDF4 To create a model using the HDF5-based NetCDF-4
                         output. An HDF5-based NetCDF-4 file will also be created
 if the
                         environment variable EXODUS_NETCDF4 is defined in the
@@ -108,11 +108,11 @@ if the
 output if
                         this environment variable is found.
 
-\arg EX_NOSHARE	Do not open the underlying NetCDF file in \e share
+\arg EX_NOSHARE Do not open the underlying NetCDF file in \e share
 mode. See the
                         NetCDF documentation for more details.
 
-\arg EX_SHARE	Do open the underlying NetCDF file in \e share mode. See
+\arg EX_SHARE   Do open the underlying NetCDF file in \e share mode. See
 the NetCDF
                         documentation for more details.
 
@@ -150,9 +150,6 @@ exoid = ex_create ("test.exo"       \comment{filename path}
 */
 #include "exodusII.h"
 #include "exodusII_int.h"
-#include <stdlib.h>
-
-static int warning_output = 0;
 
 /* NOTE: Do *not* call `ex_create_int()` directly.  The public API
  *       function name is `ex_create()` which is a wrapper that calls
@@ -161,352 +158,39 @@ static int warning_output = 0;
  */
 int ex_create_int(const char *path, int cmode, int *comp_ws, int *io_ws, int run_version)
 {
-  int   exoid;
-  int   status;
-  int   old_fill;
-  int   lio_ws;
-  int   filesiz = 1;
-  float vers;
-  char  errmsg[MAX_ERR_LENGTH];
-  char *mode_name;
-  int   nc_mode = 0;
-#if NC_HAS_HDF5
-  static int netcdf4_mode = -1;
-#endif /* NC_NETCDF4 */
-#if defined(NC_64BIT_DATA)
-  static int netcdf5_mode = -1;
-#endif
-  int          int64_status;
-  unsigned int my_mode = cmode;
+  int  exoid;
+  int  status;
+  char errmsg[MAX_ERR_LENGTH];
+  int  nc_mode = 0;
 
-  /* Contains a 1 in all bits corresponding to file modes */
-  static unsigned int all_modes = EX_NORMAL_MODEL | EX_64BIT_OFFSET | EX_64BIT_DATA | EX_NETCDF4;
+  unsigned int my_mode     = cmode;
+  int          is_parallel = 0;
 
   EX_FUNC_ENTER();
 
-  if (run_version != EX_API_VERS_NODOT && warning_output == 0) {
-    int run_version_major = run_version / 100;
-    int run_version_minor = run_version % 100;
-    int lib_version_major = EX_API_VERS_NODOT / 100;
-    int lib_version_minor = EX_API_VERS_NODOT % 100;
-    fprintf(stderr,
-            "EXODUS: Warning: This code was compiled with exodusII "
-            "version %d.%02d,\n          but was linked with exodusII "
-            "library version %d.%02d\n          This is probably an "
-            "error in the build process of this code.\n",
-            run_version_major, run_version_minor, lib_version_major, lib_version_minor);
-    warning_output = 1;
-  }
-
-/*
- * See if specified mode is supported in the version of netcdf we
- * are using
- */
-#if !NC_HAS_HDF5
-  if (my_mode & EX_NETCDF4) {
-    snprintf(errmsg, MAX_ERR_LENGTH,
-             "EXODUS: ERROR: File format specified as netcdf-4, but the "
-             "NetCDF library being used was not configured to enable "
-             "this format\n");
-    ex_err(__func__, errmsg, EX_BADPARAM);
-    EX_FUNC_LEAVE(EX_FATAL);
-  }
-#endif
-
-#if !defined(NC_64BIT_DATA)
-  if (my_mode & EX_64BIT_DATA) {
-    snprintf(errmsg, MAX_ERR_LENGTH,
-             "EXODUS: ERROR: File format specified as 64bit_data, but "
-             "the NetCDF library being used does not support this "
-             "format\n");
-    ex_err(__func__, errmsg, EX_BADPARAM);
-    EX_FUNC_LEAVE(EX_FATAL);
-  }
-#endif
-
-  /* Check that one and only one format mode is specified... */
-  {
-    unsigned int set_modes = all_modes & my_mode;
-
-    if (set_modes == 0) {
-      my_mode |= EX_64BIT_OFFSET; /* Default if nothing specified */
-    }
-    else {
-      /* Checks that only a single bit is set */
-      set_modes = set_modes && !(set_modes & (set_modes - 1));
-      if (!set_modes) {
-        snprintf(errmsg, MAX_ERR_LENGTH,
-                 "EXODUS: ERROR: More than 1 file format "
-                 "(EX_NORMAL_MODEL, EX_LARGE_MODEL, EX_64BIT_OFFSET, "
-                 "EX_64BIT_DATA, or EX_NETCDF4)\nwas specified in the "
-                 "mode argument of the ex_create call. Only a single "
-                 "format can be specified.\n");
-        ex_err(__func__, errmsg, EX_BADPARAM);
-        EX_FUNC_LEAVE(EX_FATAL);
-      }
-    }
-  }
-
-  /*
-   * See if any integer data is to be stored as int64 (long long). If
-   * so, then need to set NC_NETCDF4 and unset NC_CLASSIC_MODEL (or
-   * set EX_NOCLASSIC.  Output meaningful error message if the library
-   * is not NetCDF-4 enabled...
-   *
-   * As of netcdf-4.4.0, can also use NC_64BIT_DATA (CDF5) mode for this...
-   */
-  int64_status = my_mode & (EX_ALL_INT64_DB | EX_ALL_INT64_API);
-
-  if ((int64_status & EX_ALL_INT64_DB) != 0) {
-#if NC_HAS_HDF5 || defined(NC_64BIT_DATA)
-    /* Library DOES support netcdf4 and/or cdf5 ... See if user
-     * specified either of these and use that one; if not, pick
-     * netcdf4, non-classic as default.
-     */
-    if (my_mode & EX_NETCDF4) {
-      my_mode |= EX_NOCLASSIC;
-    }
-#if defined(NC_64BIT_DATA)
-    else if (my_mode & EX_64BIT_DATA) {
-      ; /* Do nothing, already set */
-    }
-#endif
-    else {
-      /* Unset the current mode so we don't have multiples specified */
-      /* ~all_modes sets to 1 all bits not associated with file format */
-      my_mode &= ~all_modes;
-#if NC_HAS_HDF5
-      /* Pick netcdf4 as default mode for 64-bit integers */
-      my_mode |= EX_NOCLASSIC;
-      my_mode |= EX_NETCDF4;
-#else
-      /* Pick 64bit_data as default mode for 64-bit integers */
-      my_mode |= EX_64BIT_DATA;
-#endif
-    }
-#else
-    /* Library does NOT support netcdf4 or cdf5 */
-    snprintf(errmsg, MAX_ERR_LENGTH,
-             "EXODUS: ERROR: 64-bit integer storage requested, but the "
-             "netcdf library does not support the required netcdf-4 or "
-             "64BIT_DATA extensions.\n");
-    ex_err(__func__, errmsg, EX_BADPARAM);
-    EX_FUNC_LEAVE(EX_FATAL);
-#endif
-  }
-
-#if NC_HAS_HDF5
-  if (my_mode & EX_NETCDF4) {
-    nc_mode |= (NC_NETCDF4);
-  }
-  else {
-    if (netcdf4_mode == -1) {
-      char *option = getenv("EXODUS_NETCDF4");
-      if (option != NULL) {
-        netcdf4_mode = NC_NETCDF4;
-        if (option[0] != 'q') {
-          fprintf(stderr, "EXODUS: Using netcdf version 4 selected via "
-                          "EXODUS_NETCDF4 environment variable\n");
-        }
-      }
-      else {
-        netcdf4_mode = 0;
-      }
-    }
-    nc_mode |= netcdf4_mode;
-  }
-  if (!(my_mode & EX_NOCLASSIC)) {
-    nc_mode |= NC_CLASSIC_MODEL;
-  }
-#endif
-
-#if defined(NC_64BIT_DATA)
-  if (my_mode & EX_64BIT_DATA) {
-    nc_mode |= (NC_64BIT_DATA);
-  }
-  else {
-    if (netcdf5_mode == -1) {
-      char *option = getenv("EXODUS_NETCDF5");
-      if (option != NULL) {
-        netcdf5_mode = NC_64BIT_DATA;
-        if (option[0] != 'q') {
-          fprintf(stderr, "EXODUS: Using netcdf version 5 (CDF5) selected via "
-                          "EXODUS_NETCDF5 environment variable\n");
-        }
-      }
-      else {
-        netcdf5_mode = 0;
-      }
-    }
-    nc_mode |= netcdf5_mode;
-  }
-#endif
-
-  /*
-   * Hardwire filesiz to 1 for all created files. Reduce complexity in nodal output routines.
-   * has been default for a decade or so, but still support it on read...
-   */
-  if (
-#if NC_HAS_HDF5
-      !(nc_mode & NC_NETCDF4) &&
-#endif
-#if defined(NC_64BIT_DATA)
-      !(nc_mode & NC_64BIT_DATA) &&
-#endif
-      filesiz == 1) {
-    nc_mode |= NC_64BIT_OFFSET;
-  }
-
-  if (my_mode & EX_SHARE) {
-    nc_mode |= NC_SHARE;
-  }
-
-  /*
-   * set error handling mode to no messages, non-fatal errors
-   */
-  ex_opts(exoptval); /* call required to set ncopts first time through */
-
-  if (my_mode & EX_CLOBBER) {
-    nc_mode |= NC_CLOBBER;
-    mode_name = "CLOBBER";
-  }
-  else {
-    nc_mode |= NC_NOCLOBBER;
-    mode_name = "NOCLOBBER";
-  }
-
-#if NC_HAS_DISKLESS
-  if (my_mode & EX_DISKLESS) {
-    nc_mode |= NC_DISKLESS;
-    nc_mode |= NC_WRITE;
-  }
-#endif
+  nc_mode = ex_int_handle_mode(my_mode, is_parallel, run_version);
 
   if ((status = nc_create(path, nc_mode, &exoid)) != NC_NOERR) {
 #if NC_HAS_HDF5
-    snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: file create failed for %s, mode: %s", path, mode_name);
+    snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: file create failed for %s", path);
 #else
     if (my_mode & EX_NETCDF4) {
       snprintf(errmsg, MAX_ERR_LENGTH,
-               "ERROR: file create failed for %s in NETCDF4 and %s "
+               "ERROR: file create failed for %s in NETCDF4 "
                "mode.\n\tThis library does not support netcdf-4 files.",
-               path, mode_name);
+               path);
     }
     else {
-      snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: file create failed for %s, mode: %s", path,
-               mode_name);
+      snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: file create failed for %s", path);
     }
 #endif
-    ex_err(__func__, errmsg, status);
-    EX_FUNC_LEAVE(EX_FATAL);
-  }
-
-  /* turn off automatic filling of netCDF variables */
-  if ((status = nc_set_fill(exoid, NC_NOFILL, &old_fill)) != NC_NOERR) {
-    snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to set nofill mode in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
-  /* Verify that there is not an existing file_item struct for this
-     exoid This could happen (and has) when application calls
-     ex_open(), but then closes file using nc_close() and then reopens
-     file.  NetCDF will possibly reuse the exoid which results in
-     internal corruption in exodus data structures since exodus does
-     not know that file was closed and possibly new file opened for
-     this exoid
-  */
-  if (ex_find_file_item(exoid) != NULL) {
-    snprintf(errmsg, MAX_ERR_LENGTH,
-             "ERROR: There is an existing file already using the file "
-             "id %d which was also assigned to file %s.\n\tWas "
-             "nc_close() called instead of ex_close() on an open Exodus "
-             "file?\n",
-             exoid, path);
-    ex_err(__func__, errmsg, EX_BADFILEID);
-    nc_close(exoid);
-    EX_FUNC_LEAVE(EX_FATAL);
-  }
-
-  /* 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, 0, 0, 0) != EX_NOERR) {
-    snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to init conversion routines in file id %d",
-             exoid);
-    ex_err(__func__, errmsg, EX_LASTERR);
-    EX_FUNC_LEAVE(EX_FATAL);
-  }
-
-  /* put the EXODUS version number, and i/o floating point word size as
-   * netcdf global attributes
-   */
-
-  /* store Exodus API version # as an attribute */
-  vers = EX_API_VERS;
-  if ((status = nc_put_att_float(exoid, NC_GLOBAL, ATT_API_VERSION, NC_FLOAT, 1, &vers)) !=
-      NC_NOERR) {
-    snprintf(errmsg, MAX_ERR_LENGTH,
-             "ERROR: failed to store Exodus II API version attribute in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
-    EX_FUNC_LEAVE(EX_FATAL);
-  }
-
-  /* store Exodus file version # as an attribute */
-  vers = EX_VERS;
-  if ((status = nc_put_att_float(exoid, NC_GLOBAL, ATT_VERSION, NC_FLOAT, 1, &vers)) != NC_NOERR) {
-    snprintf(errmsg, MAX_ERR_LENGTH,
-             "ERROR: failed to store Exodus II file version attribute in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
-    EX_FUNC_LEAVE(EX_FATAL);
-  }
-
-  /* store Exodus file float word size  as an attribute */
-  lio_ws = (*io_ws);
-  if ((status = nc_put_att_int(exoid, NC_GLOBAL, ATT_FLT_WORDSIZE, NC_INT, 1, &lio_ws)) !=
-      NC_NOERR) {
-    snprintf(errmsg, MAX_ERR_LENGTH,
-             "ERROR: failed to store Exodus II file float word size "
-             "attribute in file id %d",
-             exoid);
-    ex_err(__func__, errmsg, status);
-    EX_FUNC_LEAVE(EX_FATAL);
-  }
-
-  /* store Exodus file size (1=large, 0=normal) as an attribute */
-  if ((status = nc_put_att_int(exoid, NC_GLOBAL, ATT_FILESIZE, NC_INT, 1, &filesiz)) != NC_NOERR) {
-    snprintf(errmsg, MAX_ERR_LENGTH,
-             "ERROR: failed to store Exodus II file size attribute in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
-    EX_FUNC_LEAVE(EX_FATAL);
-  }
-
-  {
-    int max_so_far = 32;
-    if ((status = nc_put_att_int(exoid, NC_GLOBAL, ATT_MAX_NAME_LENGTH, NC_INT, 1, &max_so_far)) !=
-        NC_NOERR) {
-      snprintf(errmsg, MAX_ERR_LENGTH,
-               "ERROR: failed to add maximum_name_length attribute 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,
-                                 &int64_db_status)) != NC_NOERR) {
-      snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to add int64_status attribute in file id %d",
-               exoid);
-      ex_err(__func__, errmsg, status);
-      EX_FUNC_LEAVE(EX_FATAL);
-    }
-  }
-
-  if ((status = nc_enddef(exoid)) != NC_NOERR) {
-    snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to complete definition for file id %d", exoid);
-    ex_err(__func__, errmsg, status);
-    EX_FUNC_LEAVE(EX_FATAL);
+  status = ex_int_populate_header(exoid, path, my_mode, is_parallel, comp_ws, io_ws);
+  if (status != EX_NOERR) {
+    EX_FUNC_LEAVE(status);
   }
 
   EX_FUNC_LEAVE(exoid);
diff --git a/src/ex_create_group.c b/src/ex_create_group.c
index ab6a6e6bbc5..bbcae8c502e 100644
--- a/src/ex_create_group.c
+++ b/src/ex_create_group.c
@@ -35,8 +35,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_def_grp, etc
-#include <stdio.h>
 
 int ex_create_group(int parent_id, const char *group_name)
 {
@@ -50,20 +48,18 @@ int ex_create_group(int parent_id, const char *group_name)
 
   if ((status = nc_redef(parent_id)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to put file id %d into define mode", parent_id);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
   if ((status = nc_def_grp(parent_id, group_name, &exoid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: group create failed for %s in file id %d", group_name,
              parent_id);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
-  if ((status = nc_enddef(parent_id)) != NC_NOERR) {
-    snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to complete definition for file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+  if ((status = ex_leavedef(parent_id, __func__)) != NC_NOERR) {
     EX_FUNC_LEAVE(EX_FATAL);
   }
   EX_FUNC_LEAVE(exoid);
diff --git a/src/ex_create_par.c b/src/ex_create_par.c
index 3fbb38f943e..0b726cb9b73 100644
--- a/src/ex_create_par.c
+++ b/src/ex_create_par.c
@@ -92,7 +92,7 @@ alias.
 
 \arg EX_NORMAL_MODEL Create a standard model.
 
-\arg EX_64BIT_DATA	To create a model using the CDF5 format which uses the
+\arg EX_64BIT_DATA      To create a model using the CDF5 format which uses the
                         classic model but has 64-bit dimensions and sizes.
                         This type will also be created if the
                         environment variable EXODUS_NETCDF5 is defined in the
@@ -100,7 +100,7 @@ alias.
                         output if
                         this environment variable is found.
 
-\arg EX_NETCDF4	To create a model using the HDF5-based NetCDF-4
+\arg EX_NETCDF4 To create a model using the HDF5-based NetCDF-4
                         output. An HDF5-based NetCDF-4 file will also be created
 if the
                         environment variable EXODUS_NETCDF4 is defined in the
@@ -108,11 +108,11 @@ if the
 output if
                         this environment variable is found.
 
-\arg EX_NOSHARE	Do not open the underlying NetCDF file in \e share
+\arg EX_NOSHARE Do not open the underlying NetCDF file in \e share
 mode. See the
                         NetCDF documentation for more details.
 
-\arg EX_SHARE	Do open the underlying NetCDF file in \e share mode. See
+\arg EX_SHARE   Do open the underlying NetCDF file in \e share mode. See
 the NetCDF
                         documentation for more details.
 
@@ -155,9 +155,6 @@ exoid = ex_create ("test.exo"       \comment{filename path}
 
 #include "exodusII_int.h"
 #include <mpi.h>
-#include <stdlib.h>
-
-static int warning_output = 0;
 
 /* NOTE: Do *not* call `ex_create_par_int()` directly.  The public API
  *       function name is `ex_create_par()` which is a wrapper that calls
@@ -167,31 +164,13 @@ static int warning_output = 0;
 int ex_create_par_int(const char *path, int cmode, int *comp_ws, int *io_ws, MPI_Comm comm,
                       MPI_Info info, int run_version)
 {
-  int   exoid;
-  int   status;
-  int   old_fill;
-  int   lio_ws;
-  int   filesiz = 1;
-  float vers;
-  char  errmsg[MAX_ERR_LENGTH];
-  char *mode_name;
-  int   nc_mode = 0;
-#if NC_HAS_HDF5
-  static int netcdf4_mode = -1;
-#endif /* NC_NETCDF4 */
-#if defined(NC_64BIT_DATA)
-  static int netcdf5_mode = -1;
-#endif
-
-  int int64_status;
-  int pariomode  = 0;
-  int is_hdf5    = 0;
-  int is_pnetcdf = 0;
+  int  exoid;
+  int  status;
+  char errmsg[MAX_ERR_LENGTH];
+  int  nc_mode = 0;
 
-  unsigned int my_mode = cmode;
-
-  /* Contains a 1 in all bits corresponding to file modes */
-  static unsigned int all_modes = EX_NORMAL_MODEL | EX_64BIT_OFFSET | EX_64BIT_DATA | EX_NETCDF4;
+  unsigned int my_mode     = cmode;
+  int          is_parallel = 1;
 
   EX_FUNC_ENTER();
 
@@ -201,411 +180,34 @@ int ex_create_par_int(const char *path, int cmode, int *comp_ws, int *io_ws, MPI
            "EXODUS: ERROR: Parallel output requires the netcdf-4 and/or "
            "pnetcdf library format, but this netcdf library does not "
            "support either.\n");
-  ex_err(__func__, errmsg, EX_BADPARAM);
+  ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
   EX_FUNC_LEAVE(EX_FATAL);
 #endif
 
-  if (run_version != EX_API_VERS_NODOT && warning_output == 0) {
-    int run_version_major = run_version / 100;
-    int run_version_minor = run_version % 100;
-    int lib_version_major = EX_API_VERS_NODOT / 100;
-    int lib_version_minor = EX_API_VERS_NODOT % 100;
-    fprintf(stderr,
-            "EXODUS: Warning: This code was compiled with exodusII "
-            "version %d.%02d,\n          but was linked with exodusII "
-            "library version %d.%02d\n          This is probably an "
-            "error in the build process of this code.\n",
-            run_version_major, run_version_minor, lib_version_major, lib_version_minor);
-    warning_output = 1;
-  }
-
-/*
- * See if specified mode is supported in the version of netcdf we
- * are using
- */
-#if !NC_HAS_HDF5
-  if (my_mode & EX_NETCDF4) {
-    snprintf(errmsg, MAX_ERR_LENGTH,
-             "EXODUS: ERROR: File format specified as netcdf-4, but the "
-             "NetCDF library being used was not configured to enable "
-             "this format\n");
-    ex_err(__func__, errmsg, EX_BADPARAM);
-    EX_FUNC_LEAVE(EX_FATAL);
-  }
-#endif
-
-#if !defined(NC_64BIT_DATA)
-  if (my_mode & EX_64BIT_DATA) {
-    snprintf(errmsg, MAX_ERR_LENGTH,
-             "EXODUS: ERROR: File format specified as 64bit_data, but "
-             "the NetCDF library being used does not support this "
-             "format\n");
-    ex_err(__func__, errmsg, EX_BADPARAM);
-    EX_FUNC_LEAVE(EX_FATAL);
-  }
-#endif
-
-  /* Check that one and only one format mode is specified... */
-  {
-    unsigned int set_modes = all_modes & my_mode;
-
-    if (set_modes == 0) {
-      my_mode |= EX_64BIT_OFFSET; /* Default if nothing specified */
-    }
-    else {
-      /* Checks that only a single bit is set */
-      set_modes = set_modes && !(set_modes & (set_modes - 1));
-      if (!set_modes) {
-        snprintf(errmsg, MAX_ERR_LENGTH,
-                 "EXODUS: ERROR: More than 1 file format "
-                 "(EX_NORMAL_MODEL, EX_LARGE_MODEL, EX_64BIT_OFFSET, "
-                 "EX_64BIT_DATA, or EX_NETCDF4)\nwas specified in the "
-                 "mode argument of the ex_create call. Only a single "
-                 "format can be specified.\n");
-        ex_err(__func__, errmsg, EX_BADPARAM);
-        EX_FUNC_LEAVE(EX_FATAL);
-      }
-    }
-  }
-
-  /*
-   * See if any integer data is to be stored as int64 (long long). If
-   * so, then need to set NC_NETCDF4 and unset NC_CLASSIC_MODEL (or
-   * set EX_NOCLASSIC.  Output meaningful error message if the library
-   * is not NetCDF-4 enabled...
-   *
-   * As of netcdf-4.4.0, can also use NC_64BIT_DATA (CDF5) mode for this...
-   */
-  int64_status = my_mode & (EX_ALL_INT64_DB | EX_ALL_INT64_API);
+  nc_mode = ex_int_handle_mode(my_mode, is_parallel, run_version);
 
-  if ((int64_status & EX_ALL_INT64_DB) != 0) {
-#if NC_HAS_HDF5 || defined(NC_64BIT_DATA)
-    /* Library DOES support netcdf4 and/or cdf5 ... See if user
-     * specified either of these and use that one; if not, pick
-     * netcdf4, non-classic as default.
-     */
-    if (my_mode & EX_NETCDF4) {
-      my_mode |= EX_NOCLASSIC;
-    }
-#if defined(NC_64BIT_DATA)
-    else if (my_mode & EX_64BIT_DATA) {
-      ; /* Do nothing, already set */
-    }
-#endif
-    else {
-      /* Unset the current mode so we don't have multiples specified */
-      /* ~all_modes sets to 1 all bits not associated with file format */
-      my_mode &= ~all_modes;
+  if ((status = nc_create_par(path, nc_mode, comm, info, &exoid)) != NC_NOERR) {
 #if NC_HAS_HDF5
-      /* Pick netcdf4 as default mode for 64-bit integers */
-      my_mode |= EX_NOCLASSIC;
-      my_mode |= EX_NETCDF4;
-#else
-      /* Pick 64bit_data as default mode for 64-bit integers */
-      my_mode |= EX_64BIT_DATA;
-#endif
-    }
-#else
-    /* Library does NOT support netcdf4 or cdf5 */
-    snprintf(errmsg, MAX_ERR_LENGTH,
-             "EXODUS: ERROR: 64-bit integer storage requested, but the "
-             "netcdf library does not support the required netcdf-4 or "
-             "64BIT_DATA extensions.\n");
-    ex_err(__func__, errmsg, EX_BADPARAM);
-    EX_FUNC_LEAVE(EX_FATAL);
-#endif
-  }
-
-  /* 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_MPIIO;
-      is_hdf5   = 1;
-      tmp_mode  = EX_NETCDF4;
-#if !NC_HAS_HDF5
-      snprintf(errmsg, MAX_ERR_LENGTH,
-               "EXODUS: ERROR: EX_MPIPOSIX 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_MPIIO) {
-      pariomode = NC_MPIIO;
-      is_hdf5   = 1;
-      tmp_mode  = EX_NETCDF4;
-#if !NC_HAS_HDF5
-      snprintf(errmsg, MAX_ERR_LENGTH,
-               "EXODUS: ERROR: EX_MPIIO 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_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) {
-      pariomode  = NC_PNETCDF;
-      is_pnetcdf = 1;
-      /* See if client specified 64-bit or not... */
-      if ((int64_status & EX_ALL_INT64_DB) != 0) {
-        tmp_mode = EX_64BIT_DATA;
-      }
-      else {
-        tmp_mode = EX_64BIT_OFFSET;
-      }
-#if !NC_HAS_PNETCDF
-      snprintf(errmsg, MAX_ERR_LENGTH,
-               "EXODUS: ERROR: EX_PNETCDF parallel output requested "
-               "which requires PNetCDF support, but the library does "
-               "not have that option enabled.\n");
-      ex_err(__func__, errmsg, EX_BADPARAM);
-      EX_FUNC_LEAVE(EX_FATAL);
-#endif
-    }
-
-    /* If tmp_mode was set here, then need to clear any other mode that
-       was potentially already set in my_mode... */
-    my_mode &= ~all_modes;
-    my_mode |= tmp_mode;
-  }
-
-  if (my_mode & EX_NETCDF4) {
-    nc_mode |= NC_NETCDF4;
-  }
-  else {
-    if (netcdf4_mode == -1) {
-      char *option = getenv("EXODUS_NETCDF4");
-      if (option != NULL) {
-        netcdf4_mode = NC_NETCDF4;
-        if (option[0] != 'q') {
-          fprintf(stderr, "EXODUS: Using netcdf version 4 selected via "
-                          "EXODUS_NETCDF4 environment variable\n");
-        }
-      }
-      else {
-        netcdf4_mode = 0;
-      }
-    }
-    nc_mode |= netcdf4_mode;
-  }
-
-  if (!(my_mode & EX_NOCLASSIC)) {
-    nc_mode |= NC_CLASSIC_MODEL;
-  }
-
-#if defined(NC_64BIT_DATA)
-  if (my_mode & EX_64BIT_DATA) {
-    nc_mode |= (NC_64BIT_DATA);
-  }
-  else {
-    if (netcdf5_mode == -1) {
-      char *option = getenv("EXODUS_NETCDF5");
-      if (option != NULL) {
-        netcdf5_mode = NC_64BIT_DATA;
-        if (option[0] != 'q') {
-          fprintf(stderr, "EXODUS: Using netcdf version 5 (CDF5) selected via "
-                          "EXODUS_NETCDF5 environment variable\n");
-        }
-      }
-      else {
-        netcdf5_mode = 0;
-      }
-    }
-    nc_mode |= netcdf5_mode;
-  }
-#endif
-
-  /*
-   * Hardwire filesiz to 1 for all created files. Reduce complexity in nodal output routines.
-   * has been default for a decade or so, but still support it on read...
-   */
-  if (
-#if NC_HAS_HDF5
-      !(nc_mode & NC_NETCDF4) &&
-#endif
-#if defined(NC_64BIT_DATA)
-      !(nc_mode & NC_64BIT_DATA) &&
-#endif
-      filesiz == 1) {
-    nc_mode |= NC_64BIT_OFFSET;
-  }
-
-  if (my_mode & EX_SHARE) {
-    nc_mode |= NC_SHARE;
-  }
-
-  /*
-   * set error handling mode to no messages, non-fatal errors
-   */
-  ex_opts(exoptval); /* call required to set ncopts first time through */
-
-  if (my_mode & EX_CLOBBER) {
-    nc_mode |= NC_CLOBBER;
-    mode_name = "CLOBBER";
-  }
-  else {
-    nc_mode |= NC_NOCLOBBER;
-    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);
+    snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: file create failed for %s", path);
 #else
     if (my_mode & EX_NETCDF4) {
       snprintf(errmsg, MAX_ERR_LENGTH,
-               "ERROR: file create failed for %s in NETCDF4 and %s "
+               "ERROR: file create failed for %s in NETCDF4 "
                "mode.\n\tThis library does not support netcdf-4 files.",
-               path, mode_name);
+               path);
     }
     else {
-      snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: file create failed for %s, mode: %s", path,
-               mode_name);
+      snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: file create failed for %s", path);
     }
 #endif
-    ex_err(__func__, errmsg, status);
-    EX_FUNC_LEAVE(EX_FATAL);
-  }
-
-  /* turn off automatic filling of netCDF variables */
-
-  if ((status = nc_set_fill(exoid, NC_NOFILL, &old_fill)) != NC_NOERR) {
-    snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to set nofill mode in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
-    EX_FUNC_LEAVE(EX_FATAL);
-  }
-
-  /* Verify that there is not an existing file_item struct for this
-     exoid This could happen (and has) when application calls
-     ex_open(), but then closes file using nc_close() and then reopens
-     file.  NetCDF will possibly reuse the exoid which results in
-     internal corruption in exodus data structures since exodus does
-     not know that file was closed and possibly new file opened for
-     this exoid
-  */
-  if (ex_find_file_item(exoid) != NULL) {
-    snprintf(errmsg, MAX_ERR_LENGTH,
-             "ERROR: There is an existing file already using the file "
-             "id %d which was also assigned to file %s.\n\tWas "
-             "nc_close() called instead of ex_close() on an open Exodus "
-             "file?\n",
-             exoid, path);
-    ex_err(__func__, errmsg, EX_BADFILEID);
-    nc_close(exoid);
-    EX_FUNC_LEAVE(EX_FATAL);
-  }
-
-  /* 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_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);
-    EX_FUNC_LEAVE(EX_FATAL);
-  }
-
-  /* put the EXODUS version number, and i/o floating point word size as
-   * netcdf global attributes
-   */
-
-  /* store Exodus API version # as an attribute */
-  vers = EX_API_VERS;
-  if ((status = nc_put_att_float(exoid, NC_GLOBAL, ATT_API_VERSION, NC_FLOAT, 1, &vers)) !=
-      NC_NOERR) {
-    snprintf(errmsg, MAX_ERR_LENGTH,
-             "ERROR: failed to store Exodus II API version attribute in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
-  /* store Exodus file version # as an attribute */
-  vers = EX_VERS;
-  if ((status = nc_put_att_float(exoid, NC_GLOBAL, ATT_VERSION, NC_FLOAT, 1, &vers)) != NC_NOERR) {
-    snprintf(errmsg, MAX_ERR_LENGTH,
-             "ERROR: failed to store Exodus II file version attribute in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
-    EX_FUNC_LEAVE(EX_FATAL);
+  status = ex_int_populate_header(exoid, path, my_mode, is_parallel, comp_ws, io_ws);
+  if (status != EX_NOERR) {
+    EX_FUNC_LEAVE(status);
   }
-
-  /* store Exodus file float word size  as an attribute */
-  lio_ws = (int)(*io_ws);
-  if ((status = nc_put_att_int(exoid, NC_GLOBAL, ATT_FLT_WORDSIZE, NC_INT, 1, &lio_ws)) !=
-      NC_NOERR) {
-    snprintf(errmsg, MAX_ERR_LENGTH,
-             "ERROR: failed to store Exodus II file float word size "
-             "attribute in file id %d",
-             exoid);
-    ex_err(__func__, errmsg, status);
-    EX_FUNC_LEAVE(EX_FATAL);
-  }
-
-  /* store Exodus file size (1=large, 0=normal) as an attribute */
-  if ((status = nc_put_att_int(exoid, NC_GLOBAL, ATT_FILESIZE, NC_INT, 1, &filesiz)) != NC_NOERR) {
-    snprintf(errmsg, MAX_ERR_LENGTH,
-             "ERROR: failed to store Exodus II file size attribute in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
-    EX_FUNC_LEAVE(EX_FATAL);
-  }
-
-  {
-    int max_so_far = 32;
-    if ((status = nc_put_att_int(exoid, NC_GLOBAL, ATT_MAX_NAME_LENGTH, NC_INT, 1, &max_so_far)) !=
-        NC_NOERR) {
-      snprintf(errmsg, MAX_ERR_LENGTH,
-               "ERROR: failed to add maximum_name_length attribute 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,
-                                 &int64_db_status)) != NC_NOERR) {
-      snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to add int64_status attribute in file id %d",
-               exoid);
-      ex_err(__func__, errmsg, status);
-      EX_FUNC_LEAVE(EX_FATAL);
-    }
-  }
-
-  if ((status = nc_enddef(exoid)) != NC_NOERR) {
-    snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to complete definition for file id %d", exoid);
-    ex_err(__func__, errmsg, status);
-    EX_FUNC_LEAVE(EX_FATAL);
-  }
-
   EX_FUNC_LEAVE(exoid);
 }
 #else
diff --git a/src/ex_cvt_nodes_to_sides.c b/src/ex_cvt_nodes_to_sides.c
index e7e3620c8cd..bc7039c38dd 100644
--- a/src/ex_cvt_nodes_to_sides.c
+++ b/src/ex_cvt_nodes_to_sides.c
@@ -35,13 +35,6 @@
 
 #include "exodusII.h"     // for ex_err, ex_block, etc
 #include "exodusII_int.h" // for elem_blk_parm, EX_FATAL, etc
-#include <ctype.h>        // for toupper
-#include <inttypes.h>     // for PRId64
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <stdlib.h>    // for malloc, NULL, free
-#include <string.h>    // for strncmp, strlen
-#include <sys/types.h> // for int64_t
 
 static int64_t get_node(void_int *connect, size_t index, size_t int_size)
 {
@@ -286,13 +279,13 @@ int ex_cvt_nodes_to_sides(int exoid, void_int *num_elem_per_set, void_int *num_n
   if (num_side_sets < 0) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get number of side sets in file id %d",
              exoid);
-    ex_err(__func__, errmsg, EX_LASTERR);
+    ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
   if (num_side_sets == 0) {
     snprintf(errmsg, MAX_ERR_LENGTH, "Warning: no side sets defined in file id %d", exoid);
-    ex_err(__func__, errmsg, EX_WARN);
+    ex_err_fn(exoid, __func__, errmsg, EX_WARN);
     EX_FUNC_LEAVE(EX_WARN);
   }
 
@@ -300,7 +293,7 @@ int ex_cvt_nodes_to_sides(int exoid, void_int *num_elem_per_set, void_int *num_n
   if (num_elem_blks < 0) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get number of element blocks in file id %d",
              exoid);
-    ex_err(__func__, errmsg, EX_LASTERR);
+    ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -308,7 +301,7 @@ int ex_cvt_nodes_to_sides(int exoid, void_int *num_elem_per_set, void_int *num_n
   if (tot_num_elem < 0) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get total number of elements in file id %d",
              exoid);
-    ex_err(__func__, errmsg, EX_LASTERR);
+    ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -339,7 +332,7 @@ int ex_cvt_nodes_to_sides(int exoid, void_int *num_elem_per_set, void_int *num_n
              "ERROR: failed to allocate space for side set elem sort "
              "array for file id %d",
              exoid);
-    ex_err(__func__, errmsg, EX_MEMFAIL);
+    ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
     err_stat = EX_FATAL;
     goto cleanup;
   }
@@ -370,14 +363,14 @@ int ex_cvt_nodes_to_sides(int exoid, void_int *num_elem_per_set, void_int *num_n
   if (!(elem_blk_ids = malloc(num_elem_blks * ids_size))) {
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to allocate space for element block ids for file id %d", exoid);
-    ex_err(__func__, errmsg, EX_MEMFAIL);
+    ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
     err_stat = EX_FATAL;
     goto cleanup;
   }
 
   if (ex_get_ids(exoid, EX_ELEM_BLOCK, elem_blk_ids)) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get element block ids in file id %d", exoid);
-    ex_err(__func__, errmsg, EX_MSG);
+    ex_err_fn(exoid, __func__, errmsg, EX_MSG);
     err_stat = EX_FATAL;
     goto cleanup;
   }
@@ -388,7 +381,7 @@ int ex_cvt_nodes_to_sides(int exoid, void_int *num_elem_per_set, void_int *num_n
              "ERROR: failed to allocate space for element block params "
              "for file id %d",
              exoid);
-    ex_err(__func__, errmsg, EX_MEMFAIL);
+    ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
     err_stat = EX_FATAL;
     goto cleanup;
   }
@@ -417,7 +410,7 @@ int ex_cvt_nodes_to_sides(int exoid, void_int *num_elem_per_set, void_int *num_n
              "ERROR: failed to allocate space for side set elem parms "
              "index for file id %d",
              exoid);
-    ex_err(__func__, errmsg, EX_MEMFAIL);
+    ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
     err_stat = EX_FATAL;
     goto cleanup;
   }
@@ -428,7 +421,7 @@ int ex_cvt_nodes_to_sides(int exoid, void_int *num_elem_per_set, void_int *num_n
              "ERROR: failed to allocate space for side set elem to node "
              "index for file id %d",
              exoid);
-    ex_err(__func__, errmsg, EX_MEMFAIL);
+    ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
     err_stat = EX_FATAL;
     goto cleanup;
   }
@@ -443,7 +436,7 @@ int ex_cvt_nodes_to_sides(int exoid, void_int *num_elem_per_set, void_int *num_n
              "ERROR: failed to allocate space for element type flag "
              "array for file id %d",
              exoid);
-    ex_err(__func__, errmsg, EX_MEMFAIL);
+    ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
     err_stat = EX_FATAL;
     goto cleanup;
   }
@@ -461,7 +454,7 @@ int ex_cvt_nodes_to_sides(int exoid, void_int *num_elem_per_set, void_int *num_n
 
       if (j >= num_elem_blks) {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: internal logic error for file id %d", exoid);
-        ex_err(__func__, errmsg, EX_INTERNAL);
+        ex_err_fn(exoid, __func__, errmsg, EX_INTERNAL);
         err_stat = EX_FATAL;
         goto cleanup;
       }
@@ -498,7 +491,7 @@ int ex_cvt_nodes_to_sides(int exoid, void_int *num_elem_per_set, void_int *num_n
       }
       if (j >= num_elem_blks) {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: internal logic error for file id %d", exoid);
-        ex_err(__func__, errmsg, EX_INTERNAL);
+        ex_err_fn(exoid, __func__, errmsg, EX_INTERNAL);
         err_stat = EX_FATAL;
         goto cleanup;
       }
@@ -539,7 +532,7 @@ int ex_cvt_nodes_to_sides(int exoid, void_int *num_elem_per_set, void_int *num_n
 
       if (j >= num_elem_blks) {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: internal logic error for file id %d", exoid);
-        ex_err(__func__, errmsg, EX_INTERNAL);
+        ex_err_fn(exoid, __func__, errmsg, EX_INTERNAL);
         err_stat = EX_FATAL;
         goto cleanup;
       }
@@ -576,7 +569,7 @@ int ex_cvt_nodes_to_sides(int exoid, void_int *num_elem_per_set, void_int *num_n
       }
       if (j >= num_elem_blks) {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: internal logic error for file id %d", exoid);
-        ex_err(__func__, errmsg, EX_INTERNAL);
+        ex_err_fn(exoid, __func__, errmsg, EX_INTERNAL);
         err_stat = EX_FATAL;
         goto cleanup;
       }
@@ -643,7 +636,7 @@ int ex_cvt_nodes_to_sides(int exoid, void_int *num_elem_per_set, void_int *num_n
                  "ERROR: failed to allocate space for connectivity "
                  "array for file id %d",
                  exoid);
-        ex_err(__func__, errmsg, EX_MEMFAIL);
+        ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
         err_stat = EX_FATAL;
         goto cleanup;
       }
@@ -654,7 +647,7 @@ int ex_cvt_nodes_to_sides(int exoid, void_int *num_elem_per_set, void_int *num_n
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to get connectivity array for elem blk %" PRId64 " for file id %d",
                  elem_blk_parms[p_ndx].elem_blk_id, exoid);
-        ex_err(__func__, errmsg, EX_LASTERR);
+        ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
         err_stat = EX_FATAL;
         goto cleanup;
       }
@@ -671,7 +664,7 @@ int ex_cvt_nodes_to_sides(int exoid, void_int *num_elem_per_set, void_int *num_n
                "ERROR: logic error. Connect pointer is null for elem blk %" PRId64
                " for file id %d",
                elem_blk_parms[p_ndx].elem_blk_id, exoid);
-      ex_err(__func__, errmsg, EX_LASTERR);
+      ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
       err_stat = EX_FATAL;
       goto cleanup;
     }
@@ -734,7 +727,7 @@ int ex_cvt_nodes_to_sides(int exoid, void_int *num_elem_per_set, void_int *num_n
                      "ERROR: failed to find TRIANGULAR SHELL element %" PRId64 ", node %" PRId64
                      " in connectivity array %" PRId64 " for file id %d",
                      elem_num + 1, ss_node1, elem_blk_parms[p_ndx].elem_blk_id, exoid);
-            ex_err(__func__, errmsg, EX_BADPARAM);
+            ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
             err_stat = EX_FATAL;
             goto cleanup;
           }
@@ -794,7 +787,7 @@ int ex_cvt_nodes_to_sides(int exoid, void_int *num_elem_per_set, void_int *num_n
                      "ERROR: failed to find SHELL element %" PRId64 ", node %" PRId64
                      " in connectivity array %" PRId64 " for file id %d",
                      elem_num + 1, ss_node1, elem_blk_parms[p_ndx].elem_blk_id, exoid);
-            ex_err(__func__, errmsg, EX_BADPARAM);
+            ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
             err_stat = EX_FATAL;
             goto cleanup;
           }
@@ -825,7 +818,7 @@ int ex_cvt_nodes_to_sides(int exoid, void_int *num_elem_per_set, void_int *num_n
                      "ERROR: failed to find HEX element %" PRId64 ", node %" PRId64
                      " in connectivity array %" PRId64 " for file id %d",
                      elem_num + 1, ss_node1, elem_blk_parms[p_ndx].elem_blk_id, exoid);
-            ex_err(__func__, errmsg, EX_BADPARAM);
+            ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
             err_stat = EX_FATAL;
             goto cleanup;
           }
@@ -856,7 +849,7 @@ int ex_cvt_nodes_to_sides(int exoid, void_int *num_elem_per_set, void_int *num_n
                      "ERROR: failed to find TETRA element %" PRId64 ", node %" PRId64
                      " in connectivity array %" PRId64 " for file id %d",
                      elem_num + 1, ss_node1, elem_blk_parms[p_ndx].elem_blk_id, exoid);
-            ex_err(__func__, errmsg, EX_BADPARAM);
+            ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
             err_stat = EX_FATAL;
             goto cleanup;
           }
@@ -869,7 +862,7 @@ int ex_cvt_nodes_to_sides(int exoid, void_int *num_elem_per_set, void_int *num_n
                    "ERROR: unsupported PYRAMID element found in side "
                    "set node list in file id %d",
                    exoid);
-          ex_err(__func__, errmsg, EX_BADPARAM);
+          ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
           err_stat = EX_FATAL;
           goto cleanup;
         }
@@ -880,14 +873,14 @@ int ex_cvt_nodes_to_sides(int exoid, void_int *num_elem_per_set, void_int *num_n
                    "ERROR: unsupported WEDGE element found in side set "
                    "node list in file id %d",
                    exoid);
-          ex_err(__func__, errmsg, EX_BADPARAM);
+          ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
           err_stat = EX_FATAL;
           goto cleanup;
         }
         default: {
           snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: %s is an unsupported element type",
                    elem_blk_parms[p_ndx].elem_type);
-          ex_err(__func__, errmsg, EX_BADPARAM);
+          ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
           err_stat = EX_FATAL;
           goto cleanup;
         }
@@ -901,7 +894,7 @@ int ex_cvt_nodes_to_sides(int exoid, void_int *num_elem_per_set, void_int *num_n
                "ERROR: failed to find element %" PRId64 ", node %" PRId64
                " in element block %" PRId64 " for file id %d",
                elem_num + 1, ss_node0, elem_blk_parms[p_ndx].elem_blk_id, exoid);
-      ex_err(__func__, errmsg, EX_BADPARAM);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
       err_stat = EX_FATAL;
       goto cleanup;
     }
diff --git a/src/ex_err.c b/src/ex_err.c
index b1ded48d215..863aff98ad7 100644
--- a/src/ex_err.c
+++ b/src/ex_err.c
@@ -28,22 +28,18 @@
  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE2 USE
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  */
 
 #include "exodusII.h" // for exoptval, MAX_ERR_LENGTH, etc
 #include "exodusII_int.h"
-#include "vtk_netcdf.h" // for NC_EAXISTYPE, NC_EBADDIM, etc
-#include <stdio.h>  // for fprintf, stderr, fflush
-#include <stdlib.h> // for exit
-#include <string.h> // for strcpy
 
 /*!
-\fn{void ex_err(const char *module_name, const char *message, int err_num)}
+\fn{void ex_err_fn(exoid, const char *module_name, const char *message, int err_num)}
 
-The function ex_err() logs an error to stderr. It is intended
+The function ex_err_fn(exoid, ) logs an error to stderr. It is intended
 to provide explanatory messages for error codes returned from other
 exodus routines.
 
@@ -92,7 +88,7 @@ if (exoid = ex_open ("test.exo", EX_READ, &CPU_word_size,
                      &IO_word_size, &version)) {
    errval = 999;
    snprintf(errmsg, MAX_ERR_LENGTH,"ERROR: cannot open file test.exo");
-   ex_err(__func__, errmsg, errval);
+   ex_err_fn(exoid, __func__, errmsg, errval);
 }
 ~~~
 
@@ -106,8 +102,8 @@ EX_errval_t *ex_errval = NULL;
 #else
 int exerrval = 0; /* clear initial global error code value */
 
-static char last_pname[MAX_ERR_LENGTH];
-static char last_errmsg[MAX_ERR_LENGTH];
+static char last_pname[MAX_ERR_LENGTH + 1];
+static char last_errmsg[MAX_ERR_LENGTH + 1];
 static int  last_err_num;
 
 #define EX_PNAME last_pname
@@ -133,17 +129,18 @@ void ex_err(const char *module_name, const char *message, int err_num)
 
   /* save the error message for replays */
   if (message != NULL) {
-    strncpy(EX_ERRMSG, message, MAX_ERR_LENGTH);
-    EX_ERRMSG[MAX_ERR_LENGTH - 1] = '\0';
+    ex_copy_string(EX_ERRMSG, message, MAX_ERR_LENGTH + 1);
   }
   if (module_name != NULL) {
-    strncpy(EX_PNAME, module_name, MAX_ERR_LENGTH);
-    EX_PNAME[MAX_ERR_LENGTH - 1] = '\0';
+    ex_copy_string(EX_PNAME, module_name, MAX_ERR_LENGTH + 1);
   }
 
   if (err_num == EX_PRTLASTMSG) {
     fprintf(stderr, "\n[%s] %s\n", EX_PNAME, EX_ERRMSG);
     fprintf(stderr, "    exerrval = %d\n", EX_ERR_NUM);
+    if (EX_ERR_NUM < 0) {
+      fprintf(stderr, "\t%s\n", ex_strerror(EX_ERR_NUM));
+    }
     EX_FUNC_VOID();
   }
 
@@ -177,14 +174,101 @@ void ex_err(const char *module_name, const char *message, int err_num)
   EX_FUNC_VOID();
 }
 
+void ex_err_fn(int exoid, const char *module_name, const char *message, int err_num)
+{
+  EX_FUNC_ENTER_INT();
+  if (err_num == 0) { /* zero is no error, ignore and return */
+    exerrval = err_num;
+    EX_FUNC_VOID();
+  }
+
+  /* save the error message for replays */
+  if (message != NULL) {
+    ex_copy_string(EX_ERRMSG, message, MAX_ERR_LENGTH + 1);
+  }
+  if (module_name != NULL) {
+    ex_copy_string(EX_PNAME, module_name, MAX_ERR_LENGTH + 1);
+  }
+
+  if (err_num == EX_PRTLASTMSG) {
+    fprintf(stderr, "\n[%s] %s\n", EX_PNAME, EX_ERRMSG);
+
+    struct ex_file_item *file = ex_find_file_item(exoid);
+    if (file) {
+      size_t pathlen = 0;
+      nc_inq_path(exoid, &pathlen, NULL);
+      char *path = NULL;
+      if (pathlen > 0) {
+        path = malloc(pathlen + 1);
+        if (path != NULL) {
+          nc_inq_path(exoid, NULL, path);
+          fprintf(stderr, "    in file '%s'", path);
+          free(path);
+        }
+      }
+    }
+
+    fprintf(stderr, "    exerrval = %d\n", EX_ERR_NUM);
+
+    if (EX_ERR_NUM < 0) {
+      fprintf(stderr, "\t%s\n", ex_strerror(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, "\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 */
+    char *               path = NULL;
+    struct ex_file_item *file = ex_find_file_item(exoid);
+    if (file) {
+      size_t pathlen = 0;
+      nc_inq_path(exoid, &pathlen, NULL);
+      if (pathlen > 0) {
+        path = malloc(pathlen + 1);
+        nc_inq_path(exoid, NULL, path);
+      }
+    }
+    if (path) {
+      fprintf(stderr, "\nExodus Library Warning/Error: [%s] in file '%s'\n\t%s\n", module_name,
+              path, message);
+      free(path);
+    }
+    else {
+      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));
+    }
+  }
+  fflush(stderr);
+
+  /* with netCDF 3.4, (fatal) system error codes are > 0;
+     so all EXODUS fatal error codes are > 0    */
+  if ((err_num > 0) && (exoptval & EX_ABORT)) {
+    exit(err_num);
+  }
+  EX_FUNC_VOID();
+}
+
 void ex_set_err(const char *module_name, const char *message, int err_num)
 {
   EX_FUNC_ENTER_INT();
   /* 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';
+  ex_copy_string(EX_ERRMSG, message, MAX_ERR_LENGTH + 1);
+  ex_copy_string(EX_PNAME, module_name, MAX_ERR_LENGTH + 1);
   if (err_num != EX_LASTERR) {
     /* Use last set error number, but add new function and message */
     EX_ERR_NUM = err_num;
diff --git a/src/ex_get_all_times.c b/src/ex_get_all_times.c
index 9825b75c2e2..72a99ed9f53 100644
--- a/src/ex_get_all_times.c
+++ b/src/ex_get_all_times.c
@@ -35,8 +35,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, VAR_WHOLE_TIME, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_get_var_double, etc
-#include <stdio.h>
 
 /*!
 
@@ -92,7 +90,7 @@ int ex_get_all_times(int exoid, void *time_values)
   if ((status = nc_inq_varid(exoid, VAR_WHOLE_TIME, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate time variable %s in file id %d",
              VAR_WHOLE_TIME, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -106,7 +104,7 @@ int ex_get_all_times(int exoid, void *time_values)
 
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get time values from file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
diff --git a/src/ex_get_attr.c b/src/ex_get_attr.c
index 7435633368c..121034d62ba 100644
--- a/src/ex_get_attr.c
+++ b/src/ex_get_attr.c
@@ -52,9 +52,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, EX_WARN, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_get_var_double, etc
-#include <inttypes.h>     // for PRId64
-#include <stdio.h>
 
 /*!
  * \undoc reads the attributes for an edge, face, or element block
@@ -85,13 +82,13 @@ int ex_get_attr(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, void *a
           snprintf(errmsg, MAX_ERR_LENGTH,
                    "Warning: no attributes found for NULL %s %" PRId64 " in file id %d",
                    ex_name_of_object(obj_type), obj_id, exoid);
-          ex_err(__func__, errmsg, EX_NULLENTITY);
+          ex_err_fn(exoid, __func__, errmsg, EX_NULLENTITY);
           EX_FUNC_LEAVE(EX_WARN); /* no attributes for this object */
         }
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "Warning: failed to locate %s id %" PRId64 " in id array in file id %d",
                  ex_name_of_object(obj_type), obj_id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_WARN);
       }
     }
@@ -111,7 +108,7 @@ int ex_get_attr(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, void *a
     snprintf(errmsg, MAX_ERR_LENGTH,
              "Internal ERROR: unrecognized object type in switch: %d in file id %d", obj_type,
              exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL); /* number of attributes not defined */
   }
 
@@ -120,7 +117,7 @@ int ex_get_attr(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, void *a
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to locate attributes for %s %" PRId64 " in file id %d",
              ex_name_of_object(obj_type), obj_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -136,7 +133,7 @@ int ex_get_attr(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, void *a
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to get attributes for %s %" PRId64 " in file id %d",
              ex_name_of_object(obj_type), obj_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
   EX_FUNC_LEAVE(EX_NOERR);
diff --git a/src/ex_get_attr_names.c b/src/ex_get_attr_names.c
index 11cea55f131..cc208e2eb56 100644
--- a/src/ex_get_attr_names.c
+++ b/src/ex_get_attr_names.c
@@ -52,10 +52,6 @@
 
 #include "exodusII.h"     // for ex_err, ex_name_of_object, etc
 #include "exodusII_int.h" // for EX_FATAL, EX_WARN, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_inq_dimid, etc
-#include <inttypes.h>     // for PRId64
-#include <stddef.h>       // for size_t
-#include <stdio.h>
 
 /*! \undoc */
 /*
@@ -84,13 +80,13 @@ int ex_get_attr_names(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, c
           snprintf(errmsg, MAX_ERR_LENGTH,
                    "Warning: no attributes found for NULL %s %" PRId64 " in file id %d",
                    ex_name_of_object(obj_type), obj_id, exoid);
-          ex_err(__func__, errmsg, EX_NULLENTITY);
+          ex_err_fn(exoid, __func__, errmsg, EX_NULLENTITY);
           EX_FUNC_LEAVE(EX_WARN); /* no attributes for this object */
         }
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "Warning: failed to locate %s id %" PRId64 " in id array in file id %d",
                  ex_name_of_object(obj_type), obj_id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_WARN);
       }
     }
@@ -137,7 +133,7 @@ int ex_get_attr_names(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, c
     snprintf(errmsg, MAX_ERR_LENGTH,
              "Internal ERROR: unrecognized object type in switch: %d in file id %d", obj_type,
              exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL); /* number of attributes not defined */
   }
   /* inquire id's of previously defined dimensions  */
@@ -146,7 +142,7 @@ int ex_get_attr_names(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, c
     snprintf(errmsg, MAX_ERR_LENGTH,
              "Warning: no attributes found for %s %" PRId64 " in file id %d",
              ex_name_of_object(obj_type), obj_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_WARN); /* no attributes for this object */
   }
 
@@ -154,7 +150,7 @@ int ex_get_attr_names(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, c
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to get number of attributes for %s %" PRId64 " in file id %d",
              ex_name_of_object(obj_type), obj_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
diff --git a/src/ex_get_attr_param.c b/src/ex_get_attr_param.c
index 94831f84d7d..e4e729dbb9c 100644
--- a/src/ex_get_attr_param.c
+++ b/src/ex_get_attr_param.c
@@ -50,10 +50,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, EX_NOERR, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_inq_dimid, etc
-#include <inttypes.h>     // for PRId64
-#include <stddef.h>       // for size_t
-#include <stdio.h>
 
 /*!
  * \undoc retrieves the number of attributes.
@@ -90,7 +86,7 @@ int ex_get_attr_param(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, i
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "Warning: failed to locate %s id %" PRId64 " in id array in file id %d",
                  ex_name_of_object(obj_type), obj_id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_WARN);
       }
     }
@@ -109,7 +105,7 @@ int ex_get_attr_param(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, i
   default:
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: Bad block type (%d) specified for file id %d",
              obj_type, exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -122,7 +118,7 @@ int ex_get_attr_param(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, i
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to get number of attributes in %s %" PRId64 " in file id %d",
                ex_name_of_object(obj_type), obj_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
     *num_attrs = lnum_attr_per_entry;
diff --git a/src/ex_get_block.c b/src/ex_get_block.c
index e237f8ece0f..ed76e668788 100644
--- a/src/ex_get_block.c
+++ b/src/ex_get_block.c
@@ -55,8 +55,6 @@
 
 #include "exodusII.h" // for ex_block, void_int, etc
 #include "exodusII_int.h"
-#include <string.h>    // for strcpy
-#include <sys/types.h> // for int64_t
 
 /*
  * reads the parameters used to describe an edge, face, or element block
@@ -125,7 +123,7 @@ int ex_get_block(int exoid, ex_entity_type blk_type, ex_entity_id blk_id, char *
   }
 
   if (elem_type) {
-    strcpy(elem_type, block.topology);
+    ex_copy_string(elem_type, block.topology, 33);
   }
 
   EX_FUNC_LEAVE(err);
diff --git a/src/ex_get_block_param.c b/src/ex_get_block_param.c
index 8180ea237f9..7aa5e49d9a4 100644
--- a/src/ex_get_block_param.c
+++ b/src/ex_get_block_param.c
@@ -55,11 +55,6 @@
 
 #include "exodusII.h"     // for ex_block, ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, ATT_NAME_ELB, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_inq_dimid, etc
-#include <inttypes.h>     // for PRId64
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <string.h> // for strcpy
 
 /*
  * reads the parameters used to describe an edge, face, or element block
@@ -86,7 +81,7 @@ int ex_get_block_param(int exoid, ex_block *block)
   file = ex_find_file_item(exoid);
   if (!file) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: unknown file id %d in ex_get_block_param().", exoid);
-    ex_err(__func__, errmsg, EX_BADFILEID);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADFILEID);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -95,9 +90,9 @@ int ex_get_block_param(int exoid, ex_block *block)
   if (blk_id_ndx <= 0) {
     ex_get_err(NULL, NULL, &status);
     if (status != 0) {
-      strcpy(block->topology, "NULL"); /* NULL element type name */
-      block->num_entry           = 0;  /* no elements            */
-      block->num_nodes_per_entry = 0;  /* no nodes               */
+      ex_copy_string(block->topology, "NULL", MAX_STR_LENGTH + 1); /* NULL element type name */
+      block->num_entry           = 0;                              /* no elements            */
+      block->num_nodes_per_entry = 0;                              /* no nodes               */
       block->num_edges_per_entry = 0;
       block->num_faces_per_entry = 0;
       block->num_attribute       = 0; /* no attributes          */
@@ -107,7 +102,7 @@ int ex_get_block_param(int exoid, ex_block *block)
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to locate %s id  %" PRId64 " in id array in file id %d",
                ex_name_of_object(block->type), block->id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -143,7 +138,7 @@ int ex_get_block_param(int exoid, ex_block *block)
   default:
     snprintf(errmsg, MAX_ERR_LENGTH, "Bad block type parameter (%d) specified for file id %d.",
              block->type, exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -152,7 +147,7 @@ int ex_get_block_param(int exoid, ex_block *block)
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to locate number of entities in %s  %" PRId64 " in file id %d",
              ex_name_of_object(block->type), block->id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -160,7 +155,7 @@ int ex_get_block_param(int exoid, ex_block *block)
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to get number of %ss in block  %" PRId64 " in file id %d",
              ex_name_of_object(block->type), block->id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
   block->num_entry = len;
@@ -174,7 +169,7 @@ int ex_get_block_param(int exoid, ex_block *block)
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to get number of nodes/entity in %s  %" PRId64 " in file id %d",
                ex_name_of_object(block->type), block->id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -193,7 +188,7 @@ int ex_get_block_param(int exoid, ex_block *block)
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to get number of edges/entry in %s  %" PRId64 " in file id %d",
                  ex_name_of_object(block->type), block->id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
     }
@@ -213,7 +208,7 @@ int ex_get_block_param(int exoid, ex_block *block)
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to get number of faces/entity in %s  %" PRId64 " in file id %d",
                  ex_name_of_object(block->type), block->id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
     }
@@ -229,7 +224,7 @@ int ex_get_block_param(int exoid, ex_block *block)
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to get number of attributes in %s  %" PRId64 " in file id %d",
                ex_name_of_object(block->type), block->id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
     block->num_attribute = len;
@@ -256,14 +251,14 @@ int ex_get_block_param(int exoid, ex_block *block)
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to locate connectivity array for %s  %" PRId64 " in file id %d",
                ex_name_of_object(block->type), block->id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
     if ((status = nc_inq_attlen(exoid, connid, ablknam, &len)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get %s  %" PRId64 " type in file id %d",
                ex_name_of_object(block->type), block->id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -272,7 +267,7 @@ int ex_get_block_param(int exoid, ex_block *block)
       snprintf(errmsg, MAX_ERR_LENGTH,
                "Warning: %s  %" PRId64 " type will be truncated to %ld chars",
                ex_name_of_object(block->type), block->id, (long)len);
-      ex_err(__func__, errmsg, EX_MSG);
+      ex_err_fn(exoid, __func__, errmsg, EX_MSG);
     }
 
     for (i = 0; i < MAX_STR_LENGTH + 1; i++) {
@@ -283,7 +278,7 @@ int ex_get_block_param(int exoid, ex_block *block)
     if ((status = nc_get_att_text(exoid, connid, ablknam, block->topology)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get %s  %" PRId64 " type in file id %d",
                ex_name_of_object(block->type), block->id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
diff --git a/src/ex_get_block_params.c b/src/ex_get_block_params.c
index 09aa5b53c96..87243990372 100644
--- a/src/ex_get_block_params.c
+++ b/src/ex_get_block_params.c
@@ -34,7 +34,6 @@
  */
 #include "exodusII.h" // for EX_NOERR, etc
 #include "exodusII_int.h"
-#include <stddef.h> // for size_t
 
 /*!
  * Reads the parameters describing element/face/edge blocks
diff --git a/src/ex_get_cmap_params.c b/src/ex_get_cmap_params.c
index c3580d3c160..73b29ea3e82 100644
--- a/src/ex_get_cmap_params.c
+++ b/src/ex_get_cmap_params.c
@@ -61,11 +61,6 @@
 
 #include <exodusII.h>     // for ex_err, etc
 #include <exodusII_int.h> // for EX_FATAL, VAR_E_COMM_IDS, etc
-#include <inttypes.h>     // for PRId64
-#include <vtk_netcdf.h>       // for NC_NOERR, nc_inq_dimid, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <sys/types.h> // for int64_t
 
 int ex_get_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_node_cnts,
                        void_int *elem_cmap_ids, void_int *elem_cmap_elem_cnts, int processor)
@@ -91,7 +86,7 @@ int ex_get_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_n
   if (ex_get_idx(exoid, VAR_N_COMM_INFO_IDX, cmap_info_idx, processor) == -1) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find index variable, \"%s\", in file ID %d",
              VAR_N_COMM_INFO_IDX, exoid);
-    ex_err(__func__, errmsg, EX_LASTERR);
+    ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -104,7 +99,7 @@ int ex_get_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_n
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to find length of dimension \"%s\" in file ID %d", DIM_NUM_N_CMAPS,
                  exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
 
@@ -122,7 +117,7 @@ int ex_get_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_n
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to get variable ID for \"%s\" in file ID %d", VAR_N_COMM_IDS,
                  exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
 
@@ -139,7 +134,7 @@ int ex_get_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_n
         if (status != NC_NOERR) {
           snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get variable \"%s\" from file ID %d",
                    VAR_N_COMM_IDS, exoid);
-          ex_err(__func__, errmsg, status);
+          ex_err_fn(exoid, __func__, errmsg, status);
           EX_FUNC_LEAVE(EX_FATAL);
         }
 
@@ -147,7 +142,7 @@ int ex_get_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_n
           snprintf(errmsg, MAX_ERR_LENGTH,
                    "ERROR: failed to find variable ID for \"%s\" from file ID %d", VAR_N_COMM_STAT,
                    exoid);
-          ex_err(__func__, errmsg, status);
+          ex_err_fn(exoid, __func__, errmsg, status);
           EX_FUNC_LEAVE(EX_FATAL);
         }
 
@@ -167,7 +162,7 @@ int ex_get_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_n
               snprintf(errmsg, MAX_ERR_LENGTH,
                        "ERROR: failed to find nodal comm map with ID %" PRId64 " in file ID %d",
                        cmap_id, exoid);
-              ex_err(__func__, errmsg, EX_LASTERR);
+              ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
               EX_FUNC_LEAVE(EX_FATAL);
             }
 
@@ -177,7 +172,7 @@ int ex_get_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_n
               snprintf(errmsg, MAX_ERR_LENGTH,
                        "ERROR: failed to get status for \"%s\" from file ID %d", VAR_N_COMM_STAT,
                        exoid);
-              ex_err(__func__, errmsg, status);
+              ex_err_fn(exoid, __func__, errmsg, status);
               EX_FUNC_LEAVE(EX_FATAL);
             }
 
@@ -189,7 +184,7 @@ int ex_get_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_n
                          "ERROR: failed to find index variable, \"%s\", "
                          "in file ID %d",
                          VAR_N_COMM_DATA_IDX, exoid);
-                ex_err(__func__, errmsg, status);
+                ex_err_fn(exoid, __func__, errmsg, status);
 
                 EX_FUNC_LEAVE(EX_FATAL);
               }
@@ -204,7 +199,7 @@ int ex_get_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_n
                            "ERROR: failed to find dimension ID for "
                            "\"%s\" in file ID %d",
                            DIM_NCNT_CMAP, exoid);
-                  ex_err(__func__, errmsg, status);
+                  ex_err_fn(exoid, __func__, errmsg, status);
                   EX_FUNC_LEAVE(EX_FATAL);
                 }
 
@@ -215,7 +210,7 @@ int ex_get_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_n
                            "ERROR: failed to find length of dimension "
                            "\"%s\" in file ID %d",
                            DIM_NCNT_CMAP, exoid);
-                  ex_err(__func__, errmsg, status);
+                  ex_err_fn(exoid, __func__, errmsg, status);
                   EX_FUNC_LEAVE(EX_FATAL);
                 }
 
@@ -251,7 +246,7 @@ int ex_get_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_n
   if (ex_get_idx(exoid, VAR_E_COMM_INFO_IDX, cmap_info_idx, processor) == -1) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find index variable, \"%s\", in file ID %d",
              VAR_E_COMM_INFO_IDX, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -264,7 +259,7 @@ int ex_get_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_n
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to find length of dimension \"%s\" in file ID %d", DIM_NUM_E_CMAPS,
                  exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
 
@@ -282,7 +277,7 @@ int ex_get_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_n
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to get variable ID for \"%s\" in file ID %d", VAR_E_COMM_IDS,
                  exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
 
@@ -298,7 +293,7 @@ int ex_get_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_n
         if (status != NC_NOERR) {
           snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get variable \"%s\" from file ID %d",
                    VAR_E_COMM_IDS, exoid);
-          ex_err(__func__, errmsg, status);
+          ex_err_fn(exoid, __func__, errmsg, status);
           EX_FUNC_LEAVE(EX_FATAL);
         }
 
@@ -306,7 +301,7 @@ int ex_get_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_n
           snprintf(errmsg, MAX_ERR_LENGTH,
                    "ERROR: failed to find variable ID for \"%s\" from file ID %d", VAR_E_COMM_STAT,
                    exoid);
-          ex_err(__func__, errmsg, status);
+          ex_err_fn(exoid, __func__, errmsg, status);
           EX_FUNC_LEAVE(EX_FATAL);
         }
 
@@ -328,7 +323,7 @@ int ex_get_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_n
               snprintf(errmsg, MAX_ERR_LENGTH,
                        "ERROR: failed to find elemental comm map with ID %" PRId64 " in file ID %d",
                        cmap_id, exoid);
-              ex_err(__func__, errmsg, EX_LASTERR);
+              ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
               EX_FUNC_LEAVE(EX_FATAL);
             }
 
@@ -338,7 +333,7 @@ int ex_get_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_n
               snprintf(errmsg, MAX_ERR_LENGTH,
                        "ERROR: failed to get status for \"%s\" from file ID %d", VAR_E_COMM_STAT,
                        exoid);
-              ex_err(__func__, errmsg, status);
+              ex_err_fn(exoid, __func__, errmsg, status);
               EX_FUNC_LEAVE(EX_FATAL);
             }
 
@@ -350,7 +345,7 @@ int ex_get_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_n
                          "ERROR: failed to find index variable, \"%s\", "
                          "in file ID %d",
                          VAR_E_COMM_DATA_IDX, exoid);
-                ex_err(__func__, errmsg, status);
+                ex_err_fn(exoid, __func__, errmsg, status);
 
                 EX_FUNC_LEAVE(EX_FATAL);
               }
@@ -365,7 +360,7 @@ int ex_get_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_n
                            "ERROR: failed to find dimension ID for "
                            "\"%s\" in file ID %d",
                            DIM_ECNT_CMAP, exoid);
-                  ex_err(__func__, errmsg, status);
+                  ex_err_fn(exoid, __func__, errmsg, status);
                   EX_FUNC_LEAVE(EX_FATAL);
                 }
 
@@ -378,7 +373,7 @@ int ex_get_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_n
                            "ERROR: failed to find length of dimension "
                            "\"%s\" in file ID %d",
                            DIM_ECNT_CMAP, exoid);
-                  ex_err(__func__, errmsg, status);
+                  ex_err_fn(exoid, __func__, errmsg, status);
                   EX_FUNC_LEAVE(EX_FATAL);
                 }
                 cmap_data_idx[1] = count[0];
diff --git a/src/ex_get_concat_sets.c b/src/ex_get_concat_sets.c
index 8583fb280a6..8448a2dedc1 100644
--- a/src/ex_get_concat_sets.c
+++ b/src/ex_get_concat_sets.c
@@ -55,10 +55,6 @@
 
 #include "exodusII.h"     // for ex_set_specs, ex_err, etc
 #include "exodusII_int.h" // for ex_check_valid_file_id, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_inq_dimid, etc
-#include <stddef.h>       // for NULL, size_t
-#include <stdint.h>       // for int64_t
-#include <stdio.h>        // for snprintf
 
 int ex_get_concat_sets(int exoid, ex_entity_type set_type, struct ex_set_specs *set_specs)
 {
@@ -99,7 +95,7 @@ int ex_get_concat_sets(int exoid, ex_entity_type set_type, struct ex_set_specs *
   }
   else {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: invalid set type (%d)", set_type);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -109,12 +105,12 @@ int ex_get_concat_sets(int exoid, ex_entity_type set_type, struct ex_set_specs *
     if (status == NC_EBADDIM) {
       snprintf(errmsg, MAX_ERR_LENGTH, "Warning: no %ss defined for file id %d",
                ex_name_of_object(set_type), exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_WARN);
     }
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate %ss defined in file id %d",
              ex_name_of_object(set_type), exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -125,7 +121,7 @@ int ex_get_concat_sets(int exoid, ex_entity_type set_type, struct ex_set_specs *
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get number of %ss defined for file id %d",
              ex_name_of_object(set_type), exoid);
     /* use error val from inquire */
-    ex_err(__func__, errmsg, EX_LASTERR);
+    ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -133,7 +129,7 @@ int ex_get_concat_sets(int exoid, ex_entity_type set_type, struct ex_set_specs *
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get %s ids for file id %d",
              ex_name_of_object(set_type), exoid);
     /* use error val from inquire */
-    ex_err(__func__, errmsg, EX_LASTERR);
+    ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
diff --git a/src/ex_get_concat_side_set_node_count.c b/src/ex_get_concat_side_set_node_count.c
index 07e60912db1..0aba7424ab6 100644
--- a/src/ex_get_concat_side_set_node_count.c
+++ b/src/ex_get_concat_side_set_node_count.c
@@ -50,14 +50,6 @@
 
 #include "exodusII.h"     // for ex_err, EX_MSG, etc
 #include "exodusII_int.h" // for elem_blk_parm, EX_FATAL, etc
-#include <assert.h>       // for assert
-#include <ctype.h>        // for toupper
-#include <inttypes.h>     // for PRId64
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <stdlib.h>    // for malloc, NULL, free
-#include <string.h>    // for strncmp, strlen
-#include <sys/types.h> // for int64_t
 
 /*! \endcond */
 
@@ -90,13 +82,13 @@ int ex_get_concat_side_set_node_count(int exoid, int *side_set_node_cnt_list)
   if (num_side_sets < 0) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get number of side sets in file id %d",
              exoid);
-    ex_err(__func__, errmsg, EX_LASTERR);
+    ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
   if (num_side_sets == 0) {
     snprintf(errmsg, MAX_ERR_LENGTH, "Warning: no side sets defined in file id %d", exoid);
-    ex_err(__func__, errmsg, EX_WARN);
+    ex_err_fn(exoid, __func__, errmsg, EX_WARN);
     EX_FUNC_LEAVE(EX_WARN);
   }
 
@@ -104,7 +96,7 @@ int ex_get_concat_side_set_node_count(int exoid, int *side_set_node_cnt_list)
   if (num_elem_blks < 0) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get number of element blocks in file id %d",
              exoid);
-    ex_err(__func__, errmsg, EX_LASTERR);
+    ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -112,7 +104,7 @@ int ex_get_concat_side_set_node_count(int exoid, int *side_set_node_cnt_list)
   if (tot_num_elem < 0) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get total number of elements in file id %d",
              exoid);
-    ex_err(__func__, errmsg, EX_LASTERR);
+    ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -121,7 +113,7 @@ int ex_get_concat_side_set_node_count(int exoid, int *side_set_node_cnt_list)
   ndim = ex_inquire_int(exoid, EX_INQ_DIM);
   if (ndim < 0) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get dimensionality in file id %d", exoid);
-    ex_err(__func__, errmsg, EX_LASTERR);
+    ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -139,13 +131,13 @@ int ex_get_concat_side_set_node_count(int exoid, int *side_set_node_cnt_list)
   if (!(elem_blk_ids = malloc(num_elem_blks * ids_size))) {
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to allocate space for element block ids for file id %d", exoid);
-    ex_err(__func__, errmsg, EX_MEMFAIL);
+    ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
     goto error_ret;
   }
 
   if (ex_get_ids(exoid, EX_ELEM_BLOCK, elem_blk_ids) != EX_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get element block ids in file id %d", exoid);
-    ex_err(__func__, errmsg, EX_MSG);
+    ex_err_fn(exoid, __func__, errmsg, EX_MSG);
     goto error_ret;
   }
 
@@ -155,7 +147,7 @@ int ex_get_concat_side_set_node_count(int exoid, int *side_set_node_cnt_list)
              "ERROR: failed to allocate space for element block params "
              "for file id %d",
              exoid);
-    ex_err(__func__, errmsg, EX_MEMFAIL);
+    ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
     goto error_ret;
   }
 
@@ -184,13 +176,13 @@ int ex_get_concat_side_set_node_count(int exoid, int *side_set_node_cnt_list)
   if (!(side_set_ids = malloc(num_side_sets * ids_size))) {
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to allocate space for side set ids for file id %d", exoid);
-    ex_err(__func__, errmsg, EX_MEMFAIL);
+    ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
     goto error_ret;
   }
 
   if (ex_get_ids(exoid, EX_SIDE_SET, side_set_ids) != EX_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get side set ids in file id %d", exoid);
-    ex_err(__func__, errmsg, EX_MSG);
+    ex_err_fn(exoid, __func__, errmsg, EX_MSG);
     goto error_ret;
   }
 
@@ -219,7 +211,7 @@ int ex_get_concat_side_set_node_count(int exoid, int *side_set_node_cnt_list)
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to get number of elements in side set  %" PRId64 " in file id %d",
                side_set_id, exoid);
-      ex_err(__func__, errmsg, EX_LASTERR);
+      ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
       goto error_ret;
     }
 
@@ -233,7 +225,7 @@ int ex_get_concat_side_set_node_count(int exoid, int *side_set_node_cnt_list)
                "ERROR: failed to allocate space for side set element "
                "list for file id %d",
                exoid);
-      ex_err(__func__, errmsg, EX_MEMFAIL);
+      ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
       goto error_ret;
     }
 
@@ -243,7 +235,7 @@ int ex_get_concat_side_set_node_count(int exoid, int *side_set_node_cnt_list)
                "ERROR: failed to allocate space for side set side list "
                "for file id %d",
                exoid);
-      ex_err(__func__, errmsg, EX_MEMFAIL);
+      ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
       goto error_ret;
     }
 
@@ -251,7 +243,7 @@ int ex_get_concat_side_set_node_count(int exoid, int *side_set_node_cnt_list)
         EX_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get side set  %" PRId64 " in file id %d",
                side_set_id, exoid);
-      ex_err(__func__, errmsg, EX_LASTERR);
+      ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
       goto error_ret;
     }
 
@@ -261,7 +253,7 @@ int ex_get_concat_side_set_node_count(int exoid, int *side_set_node_cnt_list)
                "ERROR: failed to allocate space for side set elem sort "
                "array for file id %d",
                exoid);
-      ex_err(__func__, errmsg, EX_MEMFAIL);
+      ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
       goto error_ret;
     }
 
@@ -319,7 +311,7 @@ int ex_get_concat_side_set_node_count(int exoid, int *side_set_node_cnt_list)
                  "ERROR: Invalid element number  %" PRId64 " found in side set  %" PRId64
                  " in file %d",
                  elem, side_set_id, exoid);
-        ex_err(__func__, errmsg, EX_BADPARAM);
+        ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
         goto error_ret;
       }
     }
diff --git a/src/ex_get_conn.c b/src/ex_get_conn.c
index 3646193635e..91d84aa14be 100644
--- a/src/ex_get_conn.c
+++ b/src/ex_get_conn.c
@@ -52,11 +52,6 @@
  */
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, ex_id_lkup, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_get_var_int, etc
-#include <inttypes.h>     // for PRId64
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <stdlib.h> // for NULL
 
 int ex_get_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id, void_int *nodeconn,
                 void_int *edgeconn, void_int *faceconn)
@@ -105,13 +100,13 @@ int ex_get_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id, void_in
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "Warning: no connectivity array for NULL %s %" PRId64 " in file id %d",
                  ex_name_of_object(blk_type), blk_id, exoid);
-        ex_err(__func__, errmsg, EX_NULLENTITY);
+        ex_err_fn(exoid, __func__, errmsg, EX_NULLENTITY);
         EX_FUNC_LEAVE(EX_WARN); /* no connectivity array for this element block */
       }
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to locate %s id %" PRId64 " in id array in file id %d",
                ex_name_of_object(blk_type), blk_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -145,7 +140,7 @@ int ex_get_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id, void_in
     snprintf(errmsg, MAX_ERR_LENGTH,
              "Internal ERROR: unrecognized block type in switch: %d in file id %d", blk_type,
              exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL); /* number of attributes not defined */
   }
   /* inquire id's of previously defined dimensions  */
@@ -160,7 +155,7 @@ int ex_get_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id, void_in
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to get number of nodes/entity for %s %" PRId64 " in file id %d",
                  ex_name_of_object(blk_type), blk_id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
     }
@@ -176,7 +171,7 @@ int ex_get_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id, void_in
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to get number of edges/entry for %s %" PRId64 " in file id %d",
                  ex_name_of_object(blk_type), blk_id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
     }
@@ -192,7 +187,7 @@ int ex_get_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id, void_in
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to get number of faces/entry for %s %" PRId64 " in file id %d",
                  ex_name_of_object(blk_type), blk_id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
     }
@@ -204,7 +199,7 @@ int ex_get_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id, void_in
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to locate node connectivity array for %s %" PRId64 " in file id %d",
              ex_name_of_object(blk_type), blk_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -214,7 +209,7 @@ int ex_get_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id, void_in
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to locate edge connectivity array for %s %" PRId64 " in file id %d",
              ex_name_of_object(blk_type), blk_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -223,7 +218,7 @@ int ex_get_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id, void_in
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to locate face connectivity array for %s %" PRId64 " in file id %d",
              ex_name_of_object(blk_type), blk_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -240,7 +235,7 @@ int ex_get_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id, void_in
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to get edge connectivity array for %s %" PRId64 " in file id %d",
                ex_name_of_object(blk_type), blk_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -257,7 +252,7 @@ int ex_get_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id, void_in
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to get face connectivity array for %s %" PRId64 " in file id %d",
                ex_name_of_object(blk_type), blk_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -274,7 +269,7 @@ int ex_get_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id, void_in
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to get node connectivity array for %s %" PRId64 " in file id %d",
                ex_name_of_object(blk_type), blk_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
diff --git a/src/ex_get_coord.c b/src/ex_get_coord.c
index 343af1ca601..921343400e9 100644
--- a/src/ex_get_coord.c
+++ b/src/ex_get_coord.c
@@ -35,9 +35,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, ex_comp_ws, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_inq_varid, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
 
 /*!
 The function ex_get_coord() reads the nodal coordinates of the
@@ -126,7 +123,7 @@ int ex_get_coord(int exoid, void *x_coor, void *y_coor, void *z_coor)
 
   if ((status = nc_inq_dimlen(exoid, numnoddim, &num_nod)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get number of nodes in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -135,7 +132,7 @@ int ex_get_coord(int exoid, void *x_coor, void *y_coor, void *z_coor)
     if ((status = nc_inq_varid(exoid, VAR_COORD, &coordid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate nodal coordinates in file id %d",
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -178,7 +175,7 @@ int ex_get_coord(int exoid, void *x_coor, void *y_coor, void *z_coor)
       if (status != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get %s coord array in file id %d", which,
                  exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
     }
@@ -187,7 +184,7 @@ int ex_get_coord(int exoid, void *x_coor, void *y_coor, void *z_coor)
     if ((status = nc_inq_varid(exoid, VAR_COORD_X, &coordidx)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate x nodal coordinates in file id %d",
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -195,7 +192,7 @@ int ex_get_coord(int exoid, void *x_coor, void *y_coor, void *z_coor)
       if ((status = nc_inq_varid(exoid, VAR_COORD_Y, &coordidy)) != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to locate y nodal coordinates in file id %d", exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
     }
@@ -207,7 +204,7 @@ int ex_get_coord(int exoid, void *x_coor, void *y_coor, void *z_coor)
       if ((status = nc_inq_varid(exoid, VAR_COORD_Z, &coordidz)) != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to locate z nodal coordinates in file id %d", exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
     }
@@ -247,7 +244,7 @@ int ex_get_coord(int exoid, void *x_coor, void *y_coor, void *z_coor)
         if (status != NC_NOERR) {
           snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get %s coord array in file id %d",
                    which, exoid);
-          ex_err(__func__, errmsg, status);
+          ex_err_fn(exoid, __func__, errmsg, status);
           EX_FUNC_LEAVE(EX_FATAL);
         }
       }
diff --git a/src/ex_get_coord_names.c b/src/ex_get_coord_names.c
index 4a16d89d9cb..cf1fbf46bc0 100644
--- a/src/ex_get_coord_names.c
+++ b/src/ex_get_coord_names.c
@@ -35,9 +35,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_inq_dimid, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
 
 /*!
 
@@ -88,21 +85,21 @@ int ex_get_coord_names(int exoid, char **coord_names)
   if ((status = nc_inq_dimid(exoid, DIM_NUM_DIM, &ndimdim)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate number of dimensions in file id %d",
              exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
   if ((status = nc_inq_dimlen(exoid, ndimdim, &num_dim)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get number of dimensions in file id %d",
              exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
   if ((status = nc_inq_varid(exoid, VAR_NAME_COOR, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "Warning: failed to locate coordinate names in file id %d",
              exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_WARN);
   }
 
diff --git a/src/ex_get_coordinate_frames.c b/src/ex_get_coordinate_frames.c
index cd583fdbcda..9a5e9bc8bad 100644
--- a/src/ex_get_coordinate_frames.c
+++ b/src/ex_get_coordinate_frames.c
@@ -71,10 +71,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, EX_NOERR, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_inq_varid, etc
-#include <assert.h>       // for assert
-#include <stddef.h>       // for size_t
-#include <stdio.h>
 
 /*!
  * Coordinate frames are stored in the database as a series of three
@@ -158,7 +154,7 @@ int ex_get_coordinate_frames(int exoid, int *nframes, void_int *cf_ids, void *pt
     if ((status = nc_inq_varid(exoid, VAR_FRAME_IDS, &varids)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to read number coordinate ids from file id %d", exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -172,7 +168,7 @@ int ex_get_coordinate_frames(int exoid, int *nframes, void_int *cf_ids, void *pt
     if (status != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to read coordinate frame ids from file id %d",
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -182,7 +178,7 @@ int ex_get_coordinate_frames(int exoid, int *nframes, void_int *cf_ids, void *pt
         (nc_get_vara_text(exoid, varids, &start, &count, tags) != NC_NOERR)) {
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to read number coordinate tags from file id %d", exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -191,7 +187,7 @@ int ex_get_coordinate_frames(int exoid, int *nframes, void_int *cf_ids, void *pt
     if ((status = nc_inq_varid(exoid, VAR_FRAME_COORDS, &varids)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to read number coordinate tags from file id %d", exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -205,7 +201,7 @@ int ex_get_coordinate_frames(int exoid, int *nframes, void_int *cf_ids, void *pt
     if (status != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to read number coordinate tags from file id %d", exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
diff --git a/src/ex_get_eb_info_global.c b/src/ex_get_eb_info_global.c
index ae84104b240..dd02c6520dd 100644
--- a/src/ex_get_eb_info_global.c
+++ b/src/ex_get_eb_info_global.c
@@ -51,8 +51,6 @@
 
 #include <exodusII.h>     // for ex_err, etc
 #include <exodusII_int.h> // for EX_FATAL, etc
-#include <vtk_netcdf.h>       // for NC_NOERR, nc_get_var_int, etc
-#include <stdio.h>
 
 int ex_get_eb_info_global(int exoid, void_int *el_blk_ids, void_int *el_blk_cnts)
 {
@@ -68,7 +66,7 @@ int ex_get_eb_info_global(int exoid, void_int *el_blk_ids, void_int *el_blk_cnts
   if ((status = nc_inq_varid(exoid, VAR_ELBLK_IDS_GLOBAL, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
              VAR_ELBLK_IDS_GLOBAL, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -83,7 +81,7 @@ int ex_get_eb_info_global(int exoid, void_int *el_blk_ids, void_int *el_blk_cnts
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get variable \"%s\" from file ID %d",
              VAR_ELBLK_IDS_GLOBAL, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -92,7 +90,7 @@ int ex_get_eb_info_global(int exoid, void_int *el_blk_ids, void_int *el_blk_cnts
   if ((status = nc_inq_varid(exoid, VAR_ELBLK_CNT_GLOBAL, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
              VAR_ELBLK_CNT_GLOBAL, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -107,7 +105,7 @@ int ex_get_eb_info_global(int exoid, void_int *el_blk_ids, void_int *el_blk_cnts
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get variable \"%s\" from file ID %d",
              VAR_ELBLK_CNT_GLOBAL, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
diff --git a/src/ex_get_elem_cmap.c b/src/ex_get_elem_cmap.c
index e31410b4661..17a8051bde9 100644
--- a/src/ex_get_elem_cmap.c
+++ b/src/ex_get_elem_cmap.c
@@ -57,11 +57,6 @@
 
 #include <exodusII.h>     // for ex_err, etc
 #include <exodusII_int.h> // for EX_FATAL, DIM_ECNT_CMAP, etc
-#include <inttypes.h>     // for PRId64
-#include <vtk_netcdf.h>       // for NC_NOERR, nc_get_vara_int, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <sys/types.h> // for int64_t
 
 int ex_get_elem_cmap(int exoid, ex_entity_id map_id, void_int *elem_ids, void_int *side_ids,
                      void_int *proc_ids, int processor)
@@ -80,7 +75,7 @@ int ex_get_elem_cmap(int exoid, ex_entity_id map_id, void_int *elem_ids, void_in
   if (ex_get_idx(exoid, VAR_E_COMM_INFO_IDX, varidx, processor) == -1) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find index variable, \"%s\", in file ID %d",
              VAR_E_COMM_INFO_IDX, exoid);
-    ex_err(__func__, errmsg, EX_LASTERR);
+    ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -96,7 +91,7 @@ int ex_get_elem_cmap(int exoid, ex_entity_id map_id, void_int *elem_ids, void_in
              "ERROR: failed to find elemental comm map with ID %" PRId64 " in file \
 ID %d",
              map_id, exoid);
-    ex_err(__func__, errmsg, EX_LASTERR);
+    ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -104,7 +99,7 @@ ID %d",
   if (ex_get_idx(exoid, VAR_E_COMM_DATA_IDX, varidx, map_idx) == -1) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find index variable, \"%s\", in file ID %d",
              VAR_E_COMM_DATA_IDX, exoid);
-    ex_err(__func__, errmsg, EX_LASTERR);
+    ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -114,7 +109,7 @@ ID %d",
     if ((status = nc_inq_dimid(exoid, DIM_ECNT_CMAP, &dimid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to find dimension ID for \"%s\" in file ID %d", DIM_ECNT_CMAP, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -122,7 +117,7 @@ ID %d",
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to find length of dimension \"%s\" in file ID %d", DIM_ECNT_CMAP,
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -133,7 +128,7 @@ ID %d",
   if ((status = nc_inq_varid(exoid, VAR_E_COMM_EIDS, &varid[0])) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
              VAR_E_COMM_EIDS, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -141,7 +136,7 @@ ID %d",
   if ((status = nc_inq_varid(exoid, VAR_E_COMM_SIDS, &varid[1])) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
              VAR_E_COMM_SIDS, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -149,7 +144,7 @@ ID %d",
   if ((status = nc_inq_varid(exoid, VAR_E_COMM_PROC, &varid[2])) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
              VAR_E_COMM_PROC, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -165,7 +160,7 @@ ID %d",
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get variable \"%s\" from file ID %d",
              VAR_E_COMM_EIDS, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -179,7 +174,7 @@ ID %d",
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get variable \"%s\" from file ID %d",
              VAR_E_COMM_SIDS, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -193,7 +188,7 @@ ID %d",
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get variable \"%s\" from file ID %d",
              VAR_E_COMM_PROC, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
   EX_FUNC_LEAVE(EX_NOERR);
diff --git a/src/ex_get_elem_type.c b/src/ex_get_elem_type.c
index 1072d3cbe0c..dc762f88f17 100644
--- a/src/ex_get_elem_type.c
+++ b/src/ex_get_elem_type.c
@@ -53,10 +53,6 @@
 /*****************************************************************************/
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, ATT_NAME_ELB, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_get_att_text, etc
-#include <inttypes.h>     // for PRId64
-#include <stddef.h>       // for size_t
-#include <stdio.h>
 
 int ex_get_elem_type(int exoid, ex_entity_id elem_blk_id, char *elem_type)
 /*
@@ -77,21 +73,21 @@ int ex_get_elem_type(int exoid, ex_entity_id elem_blk_id, char *elem_type)
   if ((el_blk_id_ndx = ex_id_lkup(exoid, EX_ELEM_BLOCK, elem_blk_id)) == -1) {
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to find element block ID %" PRId64 " in file %d", elem_blk_id, exoid);
-    ex_err(__func__, errmsg, EX_LASTERR);
+    ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
   if ((status = nc_inq_varid(exoid, VAR_CONN(el_blk_id_ndx), &connid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find connectivity variable in file ID %d",
              exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
   /* get the element type name */
   if ((status = nc_inq_attlen(exoid, connid, ATT_NAME_ELB, &len)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find attribute in file ID %d", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -99,7 +95,7 @@ int ex_get_elem_type(int exoid, ex_entity_id elem_blk_id, char *elem_type)
   if (len > (MAX_STR_LENGTH + 1)) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: Element type must be of length %d in file ID %d",
              (int)len, exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -110,7 +106,7 @@ int ex_get_elem_type(int exoid, ex_entity_id elem_blk_id, char *elem_type)
   if ((status = nc_get_att_text(exoid, connid, ATT_NAME_ELB, elem_type)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get attribute \"%s\" in file ID %d",
              ATT_NAME_ELB, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
diff --git a/src/ex_get_entity_count_per_polyhedra.c b/src/ex_get_entity_count_per_polyhedra.c
index 7f93c9d6a97..74a6f7d6eb2 100644
--- a/src/ex_get_entity_count_per_polyhedra.c
+++ b/src/ex_get_entity_count_per_polyhedra.c
@@ -40,9 +40,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, ex_id_lkup, etc
-#include "vtk_netcdf.h"       // for nc_inq_varid, NC_NOERR, etc
-#include <inttypes.h>     // for PRId64
-#include <stdio.h>
 
 /*!
  * reads in the number of entities (nodes/faces) per polyhedra
@@ -72,14 +69,14 @@ int ex_get_entity_count_per_polyhedra(int exoid, ex_entity_type blk_type, ex_ent
                  "Warning: entity_counts array not allowed for NULL %s block %" PRId64
                  " in file id %d",
                  ex_name_of_object(blk_type), blk_id, exoid);
-        ex_err(__func__, errmsg, EX_NULLENTITY);
+        ex_err_fn(exoid, __func__, errmsg, EX_NULLENTITY);
         EX_FUNC_LEAVE(EX_WARN);
       }
 
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to locate %s block id %" PRId64 " in id array in file id %d",
                ex_name_of_object(blk_type), blk_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -92,14 +89,14 @@ int ex_get_entity_count_per_polyhedra(int exoid, ex_entity_type blk_type, ex_ent
     snprintf(errmsg, MAX_ERR_LENGTH,
              "Internal ERROR: unrecognized block type in switch: %d in file id %d", blk_type,
              exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to locate entity_counts array for %s block %" PRId64 " in file id %d",
              ex_name_of_object(blk_type), blk_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -108,7 +105,7 @@ int ex_get_entity_count_per_polyhedra(int exoid, ex_entity_type blk_type, ex_ent
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to read node counts array for %s block %" PRId64 " in file id %d",
              ex_name_of_object(blk_type), blk_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
   EX_FUNC_LEAVE(EX_NOERR);
diff --git a/src/ex_get_glob_var_time_int.c b/src/ex_get_glob_var_time_int.c
index fde308ea9bb..8745a3d4fe2 100644
--- a/src/ex_get_glob_var_time_int.c
+++ b/src/ex_get_glob_var_time_int.c
@@ -35,9 +35,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for ex_comp_ws, EX_FATAL, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
 
 /*!
  The function ex_get_glob_var_time() reads the values of a
@@ -115,12 +112,19 @@ int ex_get_glob_var_time_int(int exoid, int glob_var_index, int beg_time_step, i
   /* Check that times are in range */
   {
     int num_time_steps = ex_inquire_int(exoid, EX_INQ_TIME);
+
+    if (num_time_steps == 0) {
+      snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: there are no time_steps on the file id %d", exoid);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
+      EX_FUNC_LEAVE(EX_FATAL);
+    }
+
     if (beg_time_step <= 0 || beg_time_step > num_time_steps) {
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: beginning time_step is out-of-range. Value = %d, "
                "valid range is 1 to %d in file id %d",
                beg_time_step, num_time_steps, exoid);
-      ex_err(__func__, errmsg, EX_BADPARAM);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -136,7 +140,7 @@ int ex_get_glob_var_time_int(int exoid, int glob_var_index, int beg_time_step, i
                "ERROR: end time_step is out-of-range. Value = %d, valid "
                "range is %d to %d in file id %d",
                beg_time_step, end_time_step, num_time_steps, exoid);
-      ex_err(__func__, errmsg, EX_BADPARAM);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -153,7 +157,7 @@ int ex_get_glob_var_time_int(int exoid, int glob_var_index, int beg_time_step, i
   if ((status = nc_inq_varid(exoid, VAR_GLO_VAR, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate global variables in file id %d",
              exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_WARN);
   }
 
@@ -168,7 +172,7 @@ int ex_get_glob_var_time_int(int exoid, int glob_var_index, int beg_time_step, i
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to get global variable %d values from file id %d", glob_var_index,
              exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
   EX_FUNC_LEAVE(EX_NOERR);
diff --git a/src/ex_get_glob_vars_int.c b/src/ex_get_glob_vars_int.c
index f9f3a1cf136..87dbc00d49d 100644
--- a/src/ex_get_glob_vars_int.c
+++ b/src/ex_get_glob_vars_int.c
@@ -52,9 +52,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for ex_comp_ws, EX_FATAL, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
 
 /*!
  Internal function. Do not use in client code.
@@ -74,7 +71,7 @@ int ex_get_glob_vars_int(int exoid, int time_step, int num_glob_vars, void *glob
   if ((status = nc_inq_varid(exoid, VAR_GLO_VAR, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "Warning: failed to locate global variables in file id %d",
              exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_WARN);
   }
 
@@ -95,7 +92,7 @@ int ex_get_glob_vars_int(int exoid, int time_step, int num_glob_vars, void *glob
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get global variable values from file id %d",
              exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
   EX_FUNC_LEAVE(EX_NOERR);
diff --git a/src/ex_get_group_id.c b/src/ex_get_group_id.c
index a5362d06ab2..8715d49c91f 100644
--- a/src/ex_get_group_id.c
+++ b/src/ex_get_group_id.c
@@ -35,10 +35,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, EX_FILE_ID_MASK, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, etc
-#include <stdio.h>
-#include <stdlib.h> // for NULL
-#include <string.h> // for strchr
 
 /**
  * Given an exoid and group name (NULL gets root group), return id of that
@@ -66,7 +62,7 @@ int ex_get_group_id(int parent_id, const char *group_name, int *group_id)
                "ERROR: Failed to locate group with name %s as child "
                "group in file id %d",
                group_name, parent_id);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(parent_id, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -77,20 +73,20 @@ int ex_get_group_id(int parent_id, const char *group_name, int *group_id)
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: Failed to locate group with full path name %s in file id %d", group_name,
                parent_id);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(parent_id, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
   EX_FUNC_LEAVE(EX_NOERR);
 #else
-  (void)parent_id;
-  (void)group_name;
-  (void)group_id;
+  EX_UNUSED(parent_id);
+  EX_UNUSED(group_name);
+  EX_UNUSED(group_id);
   EX_FUNC_ENTER();
   snprintf(errmsg, MAX_ERR_LENGTH,
            "ERROR: Group capabilities are not available in this netcdf "
            "version--not netcdf4");
-  ex_err(__func__, errmsg, NC_ENOTNC4);
+  ex_err_fn(parent_id, __func__, errmsg, NC_ENOTNC4);
   EX_FUNC_LEAVE(EX_FATAL);
 #endif
 }
diff --git a/src/ex_get_group_ids.c b/src/ex_get_group_ids.c
index a990918c0f5..b99cc951b77 100644
--- a/src/ex_get_group_ids.c
+++ b/src/ex_get_group_ids.c
@@ -35,8 +35,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, EX_NOERR
-#include "vtk_netcdf.h"       // for nc_inq_grps, NC_NOERR
-#include <stdio.h>
 
 /**
  * Given a file or group 'parent' id, return the number of child groups and the
@@ -58,7 +56,7 @@ int ex_get_group_ids(int parent_id, int *num_groups, int *group_ids)
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: Failed to get child group ids in file id %d",
              parent_id);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(parent_id, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
   EX_FUNC_LEAVE(EX_NOERR);
@@ -67,7 +65,7 @@ int ex_get_group_ids(int parent_id, int *num_groups, int *group_ids)
   snprintf(errmsg, MAX_ERR_LENGTH,
            "ERROR: Group capabilities are not available in this netcdf "
            "version--not netcdf4");
-  ex_err(__func__, errmsg, NC_ENOTNC4);
+  ex_err_fn(parent_id, __func__, errmsg, NC_ENOTNC4);
   EX_FUNC_LEAVE(EX_FATAL);
 #endif
 }
diff --git a/src/ex_get_id_map.c b/src/ex_get_id_map.c
index d60b965099e..454e46f09a6 100644
--- a/src/ex_get_id_map.c
+++ b/src/ex_get_id_map.c
@@ -48,10 +48,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, EX_NOERR, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_get_var_int, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <sys/types.h> // for int64_t
 
 /*
  * reads the id map
@@ -94,7 +90,7 @@ int ex_get_id_map(int exoid, ex_entity_type map_type, void_int *map)
   default:
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: Bad map type (%d) specified for file id %d", map_type,
              exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -107,7 +103,7 @@ int ex_get_id_map(int exoid, ex_entity_type map_type, void_int *map)
     if ((status = nc_inq_dimlen(exoid, dimid, &num_entries)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get number of %ss in file id %d", tname,
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -138,7 +134,7 @@ int ex_get_id_map(int exoid, ex_entity_type map_type, void_int *map)
 
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get %s id map in file id %d", tname, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
diff --git a/src/ex_get_ids.c b/src/ex_get_ids.c
index f6520580560..ba4a3093f4a 100644
--- a/src/ex_get_ids.c
+++ b/src/ex_get_ids.c
@@ -38,8 +38,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_get_var_int, etc
-#include <stdio.h>
 
 /*
  *  reads the element block ids from the database
@@ -70,7 +68,7 @@ int ex_get_ids(int exoid, ex_entity_type obj_type, void_int *ids)
   case EX_ELEM_MAP: varidobj = VAR_EM_PROP(1); break;
   default: /* invalid variable type */
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: Invalid type specified in file id %d", exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -78,7 +76,7 @@ int ex_get_ids(int exoid, ex_entity_type obj_type, void_int *ids)
   if ((status = nc_inq_dimid(exoid, ex_dim_num_objects(obj_type), &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "Warning: no %s defined in file id %d",
              ex_name_of_object(obj_type), exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_WARN);
   }
 
@@ -86,7 +84,7 @@ int ex_get_ids(int exoid, ex_entity_type obj_type, void_int *ids)
   if ((status = nc_inq_varid(exoid, varidobj, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate %s ids variable in file id %d",
              ex_name_of_object(obj_type), exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -101,7 +99,7 @@ int ex_get_ids(int exoid, ex_entity_type obj_type, void_int *ids)
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to return %s ids in file id %d",
              ex_name_of_object(obj_type), exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
   EX_FUNC_LEAVE(EX_NOERR);
diff --git a/src/ex_get_info.c b/src/ex_get_info.c
index d33bac0a5f2..ed8e0a840b3 100644
--- a/src/ex_get_info.c
+++ b/src/ex_get_info.c
@@ -35,9 +35,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, ex_trim_internal, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_get_vara_text, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
 
 /*!
 
@@ -91,14 +88,14 @@ int ex_get_info(int exoid, char **info)
   if ((status = nc_inq_dimid(rootid, DIM_NUM_INFO, &dimid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH,
              "Warning: failed to locate number of info records in file id %d", rootid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_WARN);
   }
 
   if ((status = nc_inq_dimlen(rootid, dimid, &num_info)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get number of info records in file id %d",
              rootid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -107,7 +104,7 @@ int ex_get_info(int exoid, char **info)
     if ((status = nc_inq_varid(rootid, VAR_INFO, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate info record data in file id %d",
                rootid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -121,7 +118,7 @@ int ex_get_info(int exoid, char **info)
       if ((status = nc_get_vara_text(rootid, varid, start, count, info[i])) != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get info record data in file id %d",
                  rootid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
       info[i][MAX_LINE_LENGTH] = '\0';
diff --git a/src/ex_get_init.c b/src/ex_get_init.c
index 8883c2af238..8f7e2789ad4 100644
--- a/src/ex_get_init.c
+++ b/src/ex_get_init.c
@@ -57,8 +57,6 @@
 
 #include "exodusII.h" // for ex_init_params, void_int, etc
 #include "exodusII_int.h"
-#include <stdint.h> // for int64_t
-#include <string.h> // for strcpy
 
 /*!
 
@@ -145,7 +143,7 @@ int ex_get_init(int exoid, char *title, void_int *num_dim, void_int *num_nodes,
     *n_node_sets = info.num_node_sets;
     *n_side_sets = info.num_side_sets;
   }
-  strcpy(title, info.title);
+  ex_copy_string(title, info.title, MAX_LINE_LENGTH + 1);
 
   EX_FUNC_LEAVE(EX_NOERR);
 }
diff --git a/src/ex_get_init_ext.c b/src/ex_get_init_ext.c
index 3c90e2e6842..69f7ea7a8b6 100644
--- a/src/ex_get_init_ext.c
+++ b/src/ex_get_init_ext.c
@@ -50,12 +50,6 @@
 
 #include "exodusII.h"     // for ex_init_params, etc
 #include "exodusII_int.h" // for EX_FATAL, EX_NOERR, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_get_att_text, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <stdlib.h>    // for free, malloc
-#include <string.h>    // for strncpy
-#include <sys/types.h> // for int64_t
 
 /* Used to reduce repeated code below */
 static int64_t ex_get_dim_value(int exoid, const char *name, const char *dimension_name,
@@ -73,7 +67,7 @@ static int64_t ex_get_dim_value(int exoid, const char *name, const char *dimensi
     if ((status = nc_inq_dimlen(exoid, dimension, &tmp)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get number of %s in file id %d", name,
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       return (EX_FATAL);
     }
     *value = tmp;
@@ -143,7 +137,7 @@ int ex_get_init_ext(int exoid, ex_init_params *info)
   if (info->num_elem_blk == 0 && info->num_elem > 0) {
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to locate number of element blocks in file id %d", exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -188,7 +182,7 @@ int ex_get_init_ext(int exoid, ex_init_params *info)
 
   if ((status = nc_inq_att(rootid, NC_GLOBAL, ATT_TITLE, &title_type, &title_len)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "Warning: no title in file id %d", rootid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
   }
 
   /* Check title length to avoid overrunning clients memory space; include
@@ -197,7 +191,7 @@ int ex_get_init_ext(int exoid, ex_init_params *info)
     if (title_len > MAX_LINE_LENGTH) {
       char *title = malloc(title_len + 1);
       if ((status = nc_get_att_text(rootid, NC_GLOBAL, ATT_TITLE, title)) == NC_NOERR) {
-        strncpy(info->title, title, MAX_LINE_LENGTH + 1);
+        ex_copy_string(info->title, title, MAX_LINE_LENGTH + 1);
         info->title[MAX_LINE_LENGTH] = '\0';
       }
       free(title);
@@ -208,7 +202,7 @@ int ex_get_init_ext(int exoid, ex_init_params *info)
     }
     if (status != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get title in file id %d", rootid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
diff --git a/src/ex_get_init_global.c b/src/ex_get_init_global.c
index 55266ac9a13..932a659fea3 100644
--- a/src/ex_get_init_global.c
+++ b/src/ex_get_init_global.c
@@ -58,10 +58,6 @@
 
 #include "exodusII.h"     // for ex_err, void_int, etc
 #include "exodusII_int.h" // for EX_FATAL, etc
-#include <vtk_netcdf.h>       // for NC_NOERR, nc_inq_dimid, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <sys/types.h> // for int64_t
 
 int ex_get_init_global(int exoid, void_int *num_nodes_g, void_int *num_elems_g,
                        void_int *num_elem_blks_g, void_int *num_node_sets_g,
@@ -85,7 +81,7 @@ int ex_get_init_global(int exoid, void_int *num_nodes_g, void_int *num_elems_g,
   if ((status = nc_inq_dimid(exoid, DIM_NUM_NODES_GLOBAL, &dimid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find dimension ID for \"%s\" in file ID %d",
              DIM_NUM_NODES_GLOBAL, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -95,7 +91,7 @@ int ex_get_init_global(int exoid, void_int *num_nodes_g, void_int *num_elems_g,
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to find length of dimension \"%s\" in file ID %d", DIM_NUM_NODES_GLOBAL,
              exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -104,7 +100,7 @@ int ex_get_init_global(int exoid, void_int *num_nodes_g, void_int *num_elems_g,
   if ((status = nc_inq_dimid(exoid, DIM_NUM_ELEMS_GLOBAL, &dimid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find dimension ID for \"%s\" in file ID %d",
              DIM_NUM_ELEMS_GLOBAL, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -114,7 +110,7 @@ int ex_get_init_global(int exoid, void_int *num_nodes_g, void_int *num_elems_g,
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to find length of dimension \"%s\" in file ID %d", DIM_NUM_ELEMS_GLOBAL,
              exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -123,7 +119,7 @@ int ex_get_init_global(int exoid, void_int *num_nodes_g, void_int *num_elems_g,
   if ((status = nc_inq_dimid(exoid, DIM_NUM_ELBLK_GLOBAL, &dimid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find dimension ID for \"%s\" in file ID %d",
              DIM_NUM_ELBLK_GLOBAL, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -133,7 +129,7 @@ int ex_get_init_global(int exoid, void_int *num_nodes_g, void_int *num_elems_g,
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to find length of dimension \"%s\" in file ID %d", DIM_NUM_ELBLK_GLOBAL,
              exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -148,7 +144,7 @@ int ex_get_init_global(int exoid, void_int *num_nodes_g, void_int *num_elems_g,
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to find length of dimension \"%s\" in file ID %d", DIM_NUM_NS_GLOBAL,
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
 
       EX_FUNC_LEAVE(EX_FATAL);
     }
@@ -164,7 +160,7 @@ int ex_get_init_global(int exoid, void_int *num_nodes_g, void_int *num_elems_g,
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to find length of dimension \"%s\" in file ID %d", DIM_NUM_SS_GLOBAL,
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
 
       EX_FUNC_LEAVE(EX_FATAL);
     }
diff --git a/src/ex_get_init_info.c b/src/ex_get_init_info.c
index 3e7d4921323..cb590f22817 100644
--- a/src/ex_get_init_info.c
+++ b/src/ex_get_init_info.c
@@ -52,9 +52,6 @@
 
 #include <exodusII.h>     // for ex_err, EX_MSG, etc
 #include <exodusII_int.h> // for EX_FATAL, DIM_NUM_PROCS, etc
-#include <vtk_netcdf.h>       // for NC_NOERR, nc_inq_dimid, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
 
 int ex_get_init_info(int exoid, int *num_proc, int *num_proc_in_f, char *ftype)
 {
@@ -74,7 +71,7 @@ int ex_get_init_info(int exoid, int *num_proc, int *num_proc_in_f, char *ftype)
   /* Get the file type */
   if (ex_get_file_type(exoid, ftype) != EX_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get file type for file ID %d", exoid);
-    ex_err(__func__, errmsg, EX_LASTERR);
+    ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -90,7 +87,7 @@ int ex_get_init_info(int exoid, int *num_proc, int *num_proc_in_f, char *ftype)
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to find length of dimension \"%s\" in file ID %d", DIM_NUM_PROCS,
              exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -100,7 +97,7 @@ int ex_get_init_info(int exoid, int *num_proc, int *num_proc_in_f, char *ftype)
   if ((status = nc_inq_dimid(exoid, DIM_NUM_PROCS_F, &dimid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find dimension ID for \"%s\" in file ID %d",
              DIM_NUM_PROCS_F, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -110,7 +107,7 @@ int ex_get_init_info(int exoid, int *num_proc, int *num_proc_in_f, char *ftype)
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to find length of dimension \"%s\" in file ID %d", DIM_NUM_PROCS_F,
              exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
diff --git a/src/ex_get_loadbal_param.c b/src/ex_get_loadbal_param.c
index f4bfc47838a..931d17cb5d1 100644
--- a/src/ex_get_loadbal_param.c
+++ b/src/ex_get_loadbal_param.c
@@ -56,10 +56,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, DIM_NUM_BOR_ELEMS, etc
-#include <vtk_netcdf.h>       // for NC_NOERR, nc_inq_dimid, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <sys/types.h> // for int64_t
 
 int ex_get_loadbal_param(int exoid, void_int *num_int_nodes, void_int *num_bor_nodes,
                          void_int *num_ext_nodes, void_int *num_int_elems, void_int *num_bor_elems,
@@ -104,7 +100,7 @@ int ex_get_loadbal_param(int exoid, void_int *num_int_nodes, void_int *num_bor_n
   /* Get the file type */
   if (ex_get_file_type(exoid, ftype) != EX_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: unable to find file type for file ID %d", exoid);
-    ex_err(__func__, errmsg, EX_LASTERR);
+    ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -113,7 +109,7 @@ int ex_get_loadbal_param(int exoid, void_int *num_int_nodes, void_int *num_bor_n
   if ((status = nc_inq_varid(exoid, VAR_INT_N_STAT, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" from file ID %d",
              VAR_INT_N_STAT, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -128,7 +124,7 @@ int ex_get_loadbal_param(int exoid, void_int *num_int_nodes, void_int *num_bor_n
   if ((status = nc_get_var1_int(exoid, varid, start, &nmstat)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get status for \"%s\" from file ID %d",
              VAR_INT_N_STAT, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -137,7 +133,7 @@ int ex_get_loadbal_param(int exoid, void_int *num_int_nodes, void_int *num_bor_n
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to find index variable, \"%s\", in file ID %d", VAR_NODE_MAP_INT_IDX,
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
 
       EX_FUNC_LEAVE(EX_FATAL);
     }
@@ -149,7 +145,7 @@ int ex_get_loadbal_param(int exoid, void_int *num_int_nodes, void_int *num_bor_n
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to find dimension ID for \"%s\" in file ID %d", DIM_NUM_INT_NODES,
                  exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
 
         EX_FUNC_LEAVE(EX_FATAL);
       }
@@ -162,7 +158,7 @@ int ex_get_loadbal_param(int exoid, void_int *num_int_nodes, void_int *num_bor_n
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to find length of dimension \"%s\" in file ID %d",
                  DIM_NUM_INT_NODES, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
 
         EX_FUNC_LEAVE(EX_FATAL);
       }
@@ -184,7 +180,7 @@ int ex_get_loadbal_param(int exoid, void_int *num_int_nodes, void_int *num_bor_n
   if ((status = nc_inq_varid(exoid, VAR_BOR_N_STAT, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" from file ID %d",
              VAR_BOR_N_STAT, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -199,7 +195,7 @@ int ex_get_loadbal_param(int exoid, void_int *num_int_nodes, void_int *num_bor_n
   if ((status = nc_get_var1_int(exoid, varid, start, &nmstat)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get status for \"%s\" from file ID %d",
              VAR_BOR_N_STAT, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -208,7 +204,7 @@ int ex_get_loadbal_param(int exoid, void_int *num_int_nodes, void_int *num_bor_n
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to find index variable, \"%s\", in file ID %d", VAR_NODE_MAP_BOR_IDX,
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
 
       EX_FUNC_LEAVE(EX_FATAL);
     }
@@ -220,7 +216,7 @@ int ex_get_loadbal_param(int exoid, void_int *num_int_nodes, void_int *num_bor_n
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to find dimension ID for \"%s\" in file ID %d", DIM_NUM_BOR_NODES,
                  exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
 
         EX_FUNC_LEAVE(EX_FATAL);
       }
@@ -233,7 +229,7 @@ int ex_get_loadbal_param(int exoid, void_int *num_int_nodes, void_int *num_bor_n
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to find length of dimension \"%s\" in file ID %d",
                  DIM_NUM_BOR_NODES, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
 
         EX_FUNC_LEAVE(EX_FATAL);
       }
@@ -255,7 +251,7 @@ int ex_get_loadbal_param(int exoid, void_int *num_int_nodes, void_int *num_bor_n
   if ((status = nc_inq_varid(exoid, VAR_EXT_N_STAT, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" from file ID %d",
              VAR_EXT_N_STAT, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -270,7 +266,7 @@ int ex_get_loadbal_param(int exoid, void_int *num_int_nodes, void_int *num_bor_n
   if ((status = nc_get_var1_int(exoid, varid, start, &nmstat)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get status for \"%s\" from file ID %d",
              VAR_EXT_N_STAT, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -279,7 +275,7 @@ int ex_get_loadbal_param(int exoid, void_int *num_int_nodes, void_int *num_bor_n
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to find index variable, \"%s\", in file ID %d", VAR_NODE_MAP_EXT_IDX,
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
 
       EX_FUNC_LEAVE(EX_FATAL);
     }
@@ -291,7 +287,7 @@ int ex_get_loadbal_param(int exoid, void_int *num_int_nodes, void_int *num_bor_n
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to find dimension ID for \"%s\" in file ID %d", DIM_NUM_EXT_NODES,
                  exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
 
         EX_FUNC_LEAVE(EX_FATAL);
       }
@@ -304,7 +300,7 @@ int ex_get_loadbal_param(int exoid, void_int *num_int_nodes, void_int *num_bor_n
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to find length of dimension \"%s\" in file ID %d",
                  DIM_NUM_EXT_NODES, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
 
         EX_FUNC_LEAVE(EX_FATAL);
       }
@@ -325,7 +321,7 @@ int ex_get_loadbal_param(int exoid, void_int *num_int_nodes, void_int *num_bor_n
   if ((status = nc_inq_varid(exoid, VAR_INT_E_STAT, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" from file ID %d",
              VAR_INT_E_STAT, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -339,7 +335,7 @@ int ex_get_loadbal_param(int exoid, void_int *num_int_nodes, void_int *num_bor_n
   if ((status = nc_get_var1_int(exoid, varid, start, &nmstat)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get status for \"%s\" from file ID %d",
              VAR_INT_E_STAT, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -348,7 +344,7 @@ int ex_get_loadbal_param(int exoid, void_int *num_int_nodes, void_int *num_bor_n
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to find index variable, \"%s\", in file ID %d", VAR_ELEM_MAP_INT_IDX,
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
 
       EX_FUNC_LEAVE(EX_FATAL);
     }
@@ -360,7 +356,7 @@ int ex_get_loadbal_param(int exoid, void_int *num_int_nodes, void_int *num_bor_n
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to find dimension ID for \"%s\" from file ID %d", DIM_NUM_INT_ELEMS,
                  exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
 
         EX_FUNC_LEAVE(EX_FATAL);
       }
@@ -373,7 +369,7 @@ int ex_get_loadbal_param(int exoid, void_int *num_int_nodes, void_int *num_bor_n
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to find length of dimension \"%s\" in file ID %d",
                  DIM_NUM_INT_ELEMS, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
 
@@ -394,7 +390,7 @@ int ex_get_loadbal_param(int exoid, void_int *num_int_nodes, void_int *num_bor_n
   if ((status = nc_inq_varid(exoid, VAR_BOR_E_STAT, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" from file ID %d",
              VAR_BOR_E_STAT, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -408,7 +404,7 @@ int ex_get_loadbal_param(int exoid, void_int *num_int_nodes, void_int *num_bor_n
   if ((status = nc_get_var1_int(exoid, varid, start, &nmstat)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get status for \"%s\" from file ID %d",
              VAR_BOR_E_STAT, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -417,7 +413,7 @@ int ex_get_loadbal_param(int exoid, void_int *num_int_nodes, void_int *num_bor_n
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to find index variable, \"%s\", in file ID %d", VAR_ELEM_MAP_BOR_IDX,
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
 
       EX_FUNC_LEAVE(EX_FATAL);
     }
@@ -429,7 +425,7 @@ int ex_get_loadbal_param(int exoid, void_int *num_int_nodes, void_int *num_bor_n
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to find dimension ID for \"%s\" from file ID %d", DIM_NUM_BOR_ELEMS,
                  exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
 
         EX_FUNC_LEAVE(EX_FATAL);
       }
@@ -442,7 +438,7 @@ int ex_get_loadbal_param(int exoid, void_int *num_int_nodes, void_int *num_bor_n
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to find length of dimension \"%s\" in file ID %d",
                  DIM_NUM_BOR_ELEMS, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
 
@@ -462,7 +458,7 @@ int ex_get_loadbal_param(int exoid, void_int *num_int_nodes, void_int *num_bor_n
   if (ex_get_idx(exoid, VAR_N_COMM_INFO_IDX, varidx, processor) == -1) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find index variable, \"%s\", in file ID %d",
              VAR_N_COMM_INFO_IDX, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -478,7 +474,7 @@ int ex_get_loadbal_param(int exoid, void_int *num_int_nodes, void_int *num_bor_n
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to find length of dimension \"%s\" in file ID %d", DIM_NUM_N_CMAPS,
                  exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
       /* set the end value for the node map */
@@ -496,7 +492,7 @@ int ex_get_loadbal_param(int exoid, void_int *num_int_nodes, void_int *num_bor_n
   if (ex_get_idx(exoid, VAR_E_COMM_INFO_IDX, varidx, processor) == -1) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find index variable, \"%s\", in file ID %d",
              VAR_E_COMM_INFO_IDX, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -512,7 +508,7 @@ int ex_get_loadbal_param(int exoid, void_int *num_int_nodes, void_int *num_bor_n
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to find length of dimension \"%s\" in file ID %d", DIM_NUM_E_CMAPS,
                  exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
 
diff --git a/src/ex_get_map.c b/src/ex_get_map.c
index ed1ab2892b2..359d45de10e 100644
--- a/src/ex_get_map.c
+++ b/src/ex_get_map.c
@@ -35,10 +35,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_NOERR, EX_FATAL, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_get_var_int, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <sys/types.h> // for int64_t
 
 /*!
 The function ex_get_map() reads the element order map
@@ -91,7 +87,7 @@ int ex_get_map(int exoid, void_int *elem_map)
   if ((status = nc_inq_dimlen(exoid, numelemdim, &num_elem)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get number of elements in file id %d",
              exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -123,7 +119,7 @@ int ex_get_map(int exoid, void_int *elem_map)
 
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get element order map in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
diff --git a/src/ex_get_map_param.c b/src/ex_get_map_param.c
index 62c1eaedb38..fce05954e73 100644
--- a/src/ex_get_map_param.c
+++ b/src/ex_get_map_param.c
@@ -50,9 +50,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, DIM_NUM_EM, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_inq_dimid, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
 
 /*
  * reads the number of node and element maps
@@ -76,7 +73,7 @@ int ex_get_map_param(int exoid, int *num_node_maps, int *num_elem_maps)
     if ((status = nc_inq_dimlen(exoid, dimid, &lnum_node_maps)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get number of node maps in file id %d",
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
     *num_node_maps = lnum_node_maps;
@@ -90,7 +87,7 @@ int ex_get_map_param(int exoid, int *num_node_maps, int *num_elem_maps)
     if ((status = nc_inq_dimlen(exoid, dimid, &lnum_elem_maps)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get number of element maps in file id %d",
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
     *num_elem_maps = lnum_elem_maps;
diff --git a/src/ex_get_name.c b/src/ex_get_name.c
index a8050e0e0e7..fd92022eb2f 100644
--- a/src/ex_get_name.c
+++ b/src/ex_get_name.c
@@ -52,8 +52,6 @@
 
 #include "exodusII.h"     // for ex_inquire_int, etc
 #include "exodusII_int.h" // for EX_FATAL, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_inq_varid
-#include <stdio.h>
 
 /*
  * reads the specified entity name from the database
@@ -85,7 +83,7 @@ int ex_get_name(int exoid, ex_entity_type obj_type, ex_entity_id entity_id, char
   default:
     /* invalid variable type */
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: Invalid type specified in file id %d", exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
diff --git a/src/ex_get_names.c b/src/ex_get_names.c
index ab1091994f9..0a74644c2c8 100644
--- a/src/ex_get_names.c
+++ b/src/ex_get_names.c
@@ -51,9 +51,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for ex_get_dimension, EX_NOERR, etc
-#include "vtk_netcdf.h"       // for nc_inq_varid, NC_NOERR
-#include <stddef.h>       // for size_t
-#include <stdio.h>
 
 /*
  * reads the entity names from the database
@@ -129,7 +126,7 @@ int ex_get_names(int exoid, ex_entity_type obj_type, char **names)
   /* invalid variable type */
   default:
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: Invalid type specified in file id %d", exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
diff --git a/src/ex_get_nodal_var_int.c b/src/ex_get_nodal_var_int.c
index 00951e76f9d..fb282e71074 100644
--- a/src/ex_get_nodal_var_int.c
+++ b/src/ex_get_nodal_var_int.c
@@ -35,10 +35,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_NOERR, EX_WARN, etc
-#include "vtk_netcdf.h"       // for nc_inq_varid, NC_NOERR, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <sys/types.h> // for int64_t
 
 /*!
 The function ex_get_nodal_var() reads the values of a single nodal
@@ -121,7 +117,7 @@ int ex_get_nodal_var_int(int exoid, int time_step, int nodal_var_index, int64_t
     if ((status = nc_inq_varid(exoid, VAR_NOD_VAR, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "Warning: could not find nodal variables in file id %d",
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       return (EX_WARN);
     }
 
@@ -139,7 +135,7 @@ int ex_get_nodal_var_int(int exoid, int time_step, int nodal_var_index, int64_t
     if ((status = nc_inq_varid(exoid, VAR_NOD_VAR_NEW(nodal_var_index), &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "Warning: could not find nodal variable %d in file id %d",
                nodal_var_index, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       return (EX_WARN);
     }
 
@@ -159,7 +155,7 @@ int ex_get_nodal_var_int(int exoid, int time_step, int nodal_var_index, int64_t
 
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get nodal variables in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     return (EX_FATAL);
   }
   return (EX_NOERR);
diff --git a/src/ex_get_nodal_var_time_int.c b/src/ex_get_nodal_var_time_int.c
index 077643a4046..154e85dd87d 100644
--- a/src/ex_get_nodal_var_time_int.c
+++ b/src/ex_get_nodal_var_time_int.c
@@ -35,10 +35,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_WARN, ex_comp_ws, etc
-#include "vtk_netcdf.h"       // for nc_inq_varid, NC_NOERR, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <sys/types.h> // for int64_t
 
 /*!
 The function ex_get_nodal_var_time() reads the values of a nodal
@@ -123,12 +119,19 @@ int ex_get_nodal_var_time_int(int exoid, int nodal_var_index, int64_t node_numbe
   /* Check that times are in range */
   {
     int num_time_steps = ex_inquire_int(exoid, EX_INQ_TIME);
+
+    if (num_time_steps == 0) {
+      snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: there are no time_steps on the file id %d", exoid);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
+      EX_FUNC_LEAVE(EX_FATAL);
+    }
+
     if (beg_time_step <= 0 || beg_time_step > num_time_steps) {
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: beginning time_step is out-of-range. Value = %d, "
                "valid range is 1 to %d in file id %d",
                beg_time_step, num_time_steps, exoid);
-      ex_err(__func__, errmsg, EX_BADPARAM);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -144,7 +147,7 @@ int ex_get_nodal_var_time_int(int exoid, int nodal_var_index, int64_t node_numbe
                "ERROR: end time_step is out-of-range. Value = %d, valid "
                "range is %d to %d in file id %d",
                beg_time_step, end_time_step, num_time_steps, exoid);
-      ex_err(__func__, errmsg, EX_BADPARAM);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -161,7 +164,7 @@ int ex_get_nodal_var_time_int(int exoid, int nodal_var_index, int64_t node_numbe
     if ((status = nc_inq_varid(exoid, VAR_NOD_VAR, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "Warning: could not find nodal variable %d in file id %d",
                nodal_var_index, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_WARN);
     }
 
@@ -177,7 +180,7 @@ int ex_get_nodal_var_time_int(int exoid, int nodal_var_index, int64_t node_numbe
     if ((status = nc_inq_varid(exoid, VAR_NOD_VAR_NEW(nodal_var_index), &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "Warning: could not find nodal variable %d in file id %d",
                nodal_var_index, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_WARN);
     }
 
@@ -202,7 +205,7 @@ int ex_get_nodal_var_time_int(int exoid, int nodal_var_index, int64_t node_numbe
 
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get nodal variables in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
   EX_FUNC_LEAVE(EX_NOERR);
diff --git a/src/ex_get_node_cmap.c b/src/ex_get_node_cmap.c
index 395f2043159..c6178b2a9b4 100644
--- a/src/ex_get_node_cmap.c
+++ b/src/ex_get_node_cmap.c
@@ -54,11 +54,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, DIM_NCNT_CMAP, etc
-#include <inttypes.h>     // for PRId64
-#include <vtk_netcdf.h>       // for NC_NOERR, nc_get_vara_int, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <sys/types.h> // for int64_t
 
 int ex_get_node_cmap(int exoid, ex_entity_id map_id, void_int *node_ids, void_int *proc_ids,
                      int processor)
@@ -76,7 +71,7 @@ int ex_get_node_cmap(int exoid, ex_entity_id map_id, void_int *node_ids, void_in
   if (ex_get_idx(exoid, VAR_N_COMM_INFO_IDX, varidx, processor) == -1) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find index variable, \"%s\", in file ID %d",
              VAR_N_COMM_INFO_IDX, exoid);
-    ex_err(__func__, errmsg, EX_LASTERR);
+    ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -91,7 +86,7 @@ int ex_get_node_cmap(int exoid, ex_entity_id map_id, void_int *node_ids, void_in
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to find nodal comm map with ID %" PRId64 " in file ID %d", map_id,
              exoid);
-    ex_err(__func__, errmsg, EX_LASTERR);
+    ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -99,7 +94,7 @@ int ex_get_node_cmap(int exoid, ex_entity_id map_id, void_int *node_ids, void_in
   if (ex_get_idx(exoid, VAR_N_COMM_DATA_IDX, varidx, map_idx) == -1) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find index variable, \"%s\", in file ID %d",
              VAR_N_COMM_DATA_IDX, exoid);
-    ex_err(__func__, errmsg, EX_LASTERR);
+    ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -109,7 +104,7 @@ int ex_get_node_cmap(int exoid, ex_entity_id map_id, void_int *node_ids, void_in
     if ((status = nc_inq_dimid(exoid, DIM_NCNT_CMAP, &dimid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to find dimension ID for \"%s\" in file ID %d", DIM_NCNT_CMAP, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -117,7 +112,7 @@ int ex_get_node_cmap(int exoid, ex_entity_id map_id, void_int *node_ids, void_in
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to find length of dimension \"%s\" in file ID %d", DIM_NCNT_CMAP,
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
     varidx[1] = count[0];
@@ -127,7 +122,7 @@ int ex_get_node_cmap(int exoid, ex_entity_id map_id, void_int *node_ids, void_in
   if ((status = nc_inq_varid(exoid, VAR_N_COMM_NIDS, &varid[0])) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
              VAR_N_COMM_NIDS, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -135,7 +130,7 @@ int ex_get_node_cmap(int exoid, ex_entity_id map_id, void_int *node_ids, void_in
   if ((status = nc_inq_varid(exoid, VAR_N_COMM_PROC, &varid[1])) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
              VAR_N_COMM_PROC, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -152,7 +147,7 @@ int ex_get_node_cmap(int exoid, ex_entity_id map_id, void_int *node_ids, void_in
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get variable \"%s\" from file ID %d",
              VAR_N_COMM_NIDS, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -167,7 +162,7 @@ int ex_get_node_cmap(int exoid, ex_entity_id map_id, void_int *node_ids, void_in
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get variable \"%s\" from file ID %d",
              VAR_N_COMM_PROC, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
diff --git a/src/ex_get_ns_param_global.c b/src/ex_get_ns_param_global.c
index b5163a0f511..c728f4e27ea 100644
--- a/src/ex_get_ns_param_global.c
+++ b/src/ex_get_ns_param_global.c
@@ -53,8 +53,6 @@
 /*****************************************************************************/
 #include <exodusII.h>     // for ex_err, etc
 #include <exodusII_int.h> // for EX_FATAL, etc
-#include <vtk_netcdf.h>       // for NC_NOERR, nc_get_var_int, etc
-#include <stdio.h>
 
 int ex_get_ns_param_global(int exoid, void_int *global_ids, void_int *node_cnts, void_int *df_cnts)
 {
@@ -70,7 +68,7 @@ int ex_get_ns_param_global(int exoid, void_int *global_ids, void_int *node_cnts,
   if ((status = nc_inq_varid(exoid, VAR_NS_IDS_GLOBAL, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
              VAR_NS_IDS_GLOBAL, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -85,7 +83,7 @@ int ex_get_ns_param_global(int exoid, void_int *global_ids, void_int *node_cnts,
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get variable \"%s\" from file ID %d",
              VAR_NS_IDS_GLOBAL, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -95,7 +93,7 @@ int ex_get_ns_param_global(int exoid, void_int *global_ids, void_int *node_cnts,
     if ((status = nc_inq_varid(exoid, VAR_NS_NODE_CNT_GLOBAL, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
                VAR_NS_NODE_CNT_GLOBAL, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
 
       EX_FUNC_LEAVE(EX_FATAL);
     }
@@ -110,7 +108,7 @@ int ex_get_ns_param_global(int exoid, void_int *global_ids, void_int *node_cnts,
     if (status != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get variable \"%s\" from file ID %d",
                VAR_NS_NODE_CNT_GLOBAL, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
 
       EX_FUNC_LEAVE(EX_FATAL);
     }
@@ -122,7 +120,7 @@ int ex_get_ns_param_global(int exoid, void_int *global_ids, void_int *node_cnts,
     if ((status = nc_inq_varid(exoid, VAR_NS_DF_CNT_GLOBAL, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
                VAR_NS_DF_CNT_GLOBAL, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
 
       EX_FUNC_LEAVE(EX_FATAL);
     }
@@ -137,7 +135,7 @@ int ex_get_ns_param_global(int exoid, void_int *global_ids, void_int *node_cnts,
     if (status != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get variable \"%s\" from file ID %d",
                VAR_NS_DF_CNT_GLOBAL, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
 
       EX_FUNC_LEAVE(EX_FATAL);
     }
diff --git a/src/ex_get_num_map.c b/src/ex_get_num_map.c
index 52a14e79e7b..3d89d5d0f37 100644
--- a/src/ex_get_num_map.c
+++ b/src/ex_get_num_map.c
@@ -52,9 +52,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, EX_NOERR, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_inq_dimid, etc
-#include <inttypes.h>     // for PRId64
-#include <stdio.h>
 
 /*
  * reads the map with specified ID
@@ -89,7 +86,7 @@ int ex_get_num_map(int exoid, ex_entity_type map_type, ex_entity_id map_id, void
     break;
   default:
     snprintf(errmsg, MAX_ERR_LENGTH, "Bad map type (%d) specified", map_type);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -102,7 +99,7 @@ int ex_get_num_map(int exoid, ex_entity_type map_type, ex_entity_id map_id, void
   if ((status = nc_inq_dimid(exoid, dim_num_maps, &dimid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "Warning: no %ss defined in file id %d",
              ex_name_of_object(map_type), exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_WARN);
   }
 
@@ -112,7 +109,7 @@ int ex_get_num_map(int exoid, ex_entity_type map_type, ex_entity_id map_id, void
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to locate %s id %" PRId64 " in id variable in file id %d",
              ex_name_of_object(map_type), map_id, exoid);
-    ex_err(__func__, errmsg, EX_LASTERR);
+    ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -120,7 +117,7 @@ int ex_get_num_map(int exoid, ex_entity_type map_type, ex_entity_id map_id, void
   if ((status = nc_inq_varid(exoid, ex_name_of_map(map_type, id_ndx), &var_id)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate %s %" PRId64 " in file id %d",
              ex_name_of_object(map_type), map_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -135,7 +132,7 @@ int ex_get_num_map(int exoid, ex_entity_type map_type, ex_entity_id map_id, void
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get %s in file id %d",
              ex_name_of_object(map_type), exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
diff --git a/src/ex_get_object_truth_vector.c b/src/ex_get_object_truth_vector.c
index e6d07ba7cd7..53ed1a41e14 100644
--- a/src/ex_get_object_truth_vector.c
+++ b/src/ex_get_object_truth_vector.c
@@ -43,11 +43,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for ex_get_dimension, EX_FATAL, etc
-#include "vtk_netcdf.h"       // for nc_inq_varid, NC_NOERR, etc
-#include <inttypes.h>     // for PRId64
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <stdlib.h> // for NULL
 
 /*!
  * reads the EXODUS specified variable truth vector from the database
@@ -133,7 +128,7 @@ int ex_get_object_truth_vector(int exoid, ex_entity_type obj_type, ex_entity_id
   default:
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: Invalid variable type %d specified in file id %d",
              obj_type, exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_WARN);
   }
 
@@ -150,7 +145,7 @@ int ex_get_object_truth_vector(int exoid, ex_entity_type obj_type, ex_entity_id
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to locate %s id %" PRId64 " in id variable in file id %d",
                  ex_name_of_object(obj_type), entity_id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
     }
@@ -165,7 +160,7 @@ int ex_get_object_truth_vector(int exoid, ex_entity_type obj_type, ex_entity_id
   if ((int)num_var_db != num_var) {
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: # of variables doesn't match those defined in file id %d", exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -198,7 +193,7 @@ int ex_get_object_truth_vector(int exoid, ex_entity_type obj_type, ex_entity_id
 
     if (status != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get truth vector from file id %d", exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
diff --git a/src/ex_get_one_attr.c b/src/ex_get_one_attr.c
index 8e4687f8549..4004d9f87e1 100644
--- a/src/ex_get_one_attr.c
+++ b/src/ex_get_one_attr.c
@@ -52,10 +52,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, ex_get_dimension, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, etc
-#include <inttypes.h>     // for PRId64
-#include <stddef.h>       // for size_t, ptrdiff_t
-#include <stdio.h>
 
 /*
  * reads the attributes for an edge, face, or element block
@@ -89,13 +85,13 @@ int ex_get_one_attr(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, int
           snprintf(errmsg, MAX_ERR_LENGTH,
                    "Warning: no attributes found for NULL %s %" PRId64 " in file id %d",
                    ex_name_of_object(obj_type), obj_id, exoid);
-          ex_err(__func__, errmsg, EX_NULLENTITY);
+          ex_err_fn(exoid, __func__, errmsg, EX_NULLENTITY);
           EX_FUNC_LEAVE(EX_WARN); /* no attributes for this object */
         }
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "Warning: failed to locate %s id %" PRId64 " in id array in file id %d",
                  ex_name_of_object(obj_type), obj_id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_WARN);
       }
     }
@@ -151,7 +147,7 @@ int ex_get_one_attr(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, int
     snprintf(errmsg, MAX_ERR_LENGTH,
              "Internal ERROR: unrecognized object type in switch: %d in file id %d", obj_type,
              exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL); /* number of attributes not defined */
   }
 
@@ -170,7 +166,7 @@ int ex_get_one_attr(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, int
              "ERROR: Invalid attribute index specified: %d.  Valid "
              "range is 1 to %d for %s %" PRId64 " in file id %d",
              attrib_index, (int)num_attr, ex_name_of_object(obj_type), obj_id, exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -178,7 +174,7 @@ int ex_get_one_attr(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, int
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to locate attributes for %s %" PRId64 " in file id %d",
              ex_name_of_object(obj_type), obj_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -203,7 +199,7 @@ int ex_get_one_attr(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, int
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to get attribute %d for %s %" PRId64 " in file id %d", attrib_index,
              ex_name_of_object(obj_type), obj_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
   EX_FUNC_LEAVE(EX_NOERR);
diff --git a/src/ex_get_partial_attr.c b/src/ex_get_partial_attr.c
index 172fc45455c..463132bdd59 100644
--- a/src/ex_get_partial_attr.c
+++ b/src/ex_get_partial_attr.c
@@ -56,11 +56,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, ex_get_dimension, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, etc
-#include <inttypes.h>     // for PRId64
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <sys/types.h> // for int64_t
 
 /*!
  * reads the specified attribute for a subsect of a block
@@ -108,13 +103,13 @@ int ex_get_partial_attr(int exoid, ex_entity_type obj_type, ex_entity_id obj_id,
           snprintf(errmsg, MAX_ERR_LENGTH,
                    "Warning: no attributes found for NULL %s %" PRId64 " in file id %d",
                    ex_name_of_object(obj_type), obj_id, exoid);
-          ex_err(__func__, errmsg, EX_NULLENTITY);
+          ex_err_fn(exoid, __func__, errmsg, EX_NULLENTITY);
           EX_FUNC_LEAVE(EX_WARN); /* no attributes for this object */
         }
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "Warning: failed to locate %s id%" PRId64 " in id array in file id %d",
                  ex_name_of_object(obj_type), obj_id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_WARN);
       }
     }
@@ -170,7 +165,7 @@ int ex_get_partial_attr(int exoid, ex_entity_type obj_type, ex_entity_id obj_id,
     snprintf(errmsg, MAX_ERR_LENGTH,
              "Internal ERROR: unrecognized object type in switch: %d in file id %d", obj_type,
              exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL); /* number of attributes not defined */
   }
 
@@ -185,7 +180,7 @@ int ex_get_partial_attr(int exoid, ex_entity_type obj_type, ex_entity_id obj_id,
              "ERROR: start index (%" PRId64 ") + count (%" PRId64
              ") is larger than total number of entities (%" ST_ZU ") in file id %d",
              start_num, num_ent, num_entries_this_obj, exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -197,7 +192,7 @@ int ex_get_partial_attr(int exoid, ex_entity_type obj_type, ex_entity_id obj_id,
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to locate attributes for %s %" PRId64 " in file id %d",
              ex_name_of_object(obj_type), obj_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -222,7 +217,7 @@ int ex_get_partial_attr(int exoid, ex_entity_type obj_type, ex_entity_id obj_id,
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to get attributes for %s %" PRId64 " in file id %d",
              ex_name_of_object(obj_type), obj_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
   EX_FUNC_LEAVE(EX_NOERR);
diff --git a/src/ex_get_partial_conn.c b/src/ex_get_partial_conn.c
index efd93ef5c34..1225bfc83a6 100644
--- a/src/ex_get_partial_conn.c
+++ b/src/ex_get_partial_conn.c
@@ -56,11 +56,6 @@
  */
 #include "exodusII.h"     // for ex_err, ex_name_of_object, etc
 #include "exodusII_int.h" // for ex_check_valid_file_id, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_get_vara_int, etc
-#include <inttypes.h>     // for PRId64
-#include <stddef.h>       // for size_t, NULL
-#include <stdint.h>       // for int64_t
-#include <stdio.h>        // for snprintf
 
 /*
  * reads the connectivity array for an element block
@@ -103,7 +98,7 @@ int ex_get_partial_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id,
              "Warning: ex_get_partial_conn only supports nodal "
              "connectivity at this time. %s %" PRId64 " in file id %d",
              ex_name_of_object(blk_type), blk_id, exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
   }
 
   /* Locate index of element block id in VAR_ID_EL_BLK array */
@@ -117,14 +112,14 @@ int ex_get_partial_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id,
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "Warning: no connectivity array for NULL %s %" PRId64 " in file id %d",
                  ex_name_of_object(blk_type), blk_id, exoid);
-        ex_err(__func__, errmsg, EX_NULLENTITY);
+        ex_err_fn(exoid, __func__, errmsg, EX_NULLENTITY);
         EX_FUNC_LEAVE(EX_WARN); /* no connectivity array for this element block */
       }
 
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to locate %s id %" PRId64 " in id array in file id %d",
                ex_name_of_object(blk_type), blk_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -158,7 +153,7 @@ int ex_get_partial_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id,
     snprintf(errmsg, MAX_ERR_LENGTH,
              "Internal ERROR: unrecognized block type in switch: %d in file id %d", blk_type,
              exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL); /* number of attributes not defined */
   }
   /* inquire id's of previously defined dimensions  */
@@ -167,7 +162,7 @@ int ex_get_partial_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id,
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to locate number of nodes/entity for %s %" PRId64 " in file id %d",
              ex_name_of_object(blk_type), blk_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -175,7 +170,7 @@ int ex_get_partial_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id,
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to get number of nodes/entity for %s %" PRId64 " in file id %d",
              ex_name_of_object(blk_type), blk_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -189,7 +184,7 @@ int ex_get_partial_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id,
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to get number of edges/entry for %s %" PRId64 " in file id %d",
                  ex_name_of_object(blk_type), blk_id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
     }
@@ -205,7 +200,7 @@ int ex_get_partial_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id,
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to get number of faces/entry for %s %" PRId64 " in file id %d",
                  ex_name_of_object(blk_type), blk_id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
     }
@@ -215,7 +210,7 @@ int ex_get_partial_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id,
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to locate connectivity array for %s %" PRId64 " in file id %d",
              ex_name_of_object(blk_type), blk_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -225,7 +220,7 @@ int ex_get_partial_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id,
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to locate edge connectivity array for %s %" PRId64 " in file id %d",
              ex_name_of_object(blk_type), blk_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -234,7 +229,7 @@ int ex_get_partial_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id,
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to locate face connectivity array for %s %" PRId64 " in file id %d",
              ex_name_of_object(blk_type), blk_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -261,7 +256,7 @@ int ex_get_partial_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id,
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to get edge connectivity array for %s %" PRId64 " in file id %d",
                ex_name_of_object(blk_type), blk_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -288,7 +283,7 @@ int ex_get_partial_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id,
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to get face connectivity array for %s %" PRId64 " in file id %d",
                ex_name_of_object(blk_type), blk_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -315,7 +310,7 @@ int ex_get_partial_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id,
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to get connectivity array for %s %" PRId64 " in file id %d",
                ex_name_of_object(blk_type), blk_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
diff --git a/src/ex_get_partial_coord.c b/src/ex_get_partial_coord.c
index 498c1773269..40c03ca68d4 100644
--- a/src/ex_get_partial_coord.c
+++ b/src/ex_get_partial_coord.c
@@ -55,11 +55,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, ex_comp_ws, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, etc
-#include <inttypes.h>     // for PRId64
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <sys/types.h> // for int64_t
 
 /*!
  * reads the coordinates of the nodes.
@@ -106,7 +101,7 @@ int ex_get_partial_coord(int exoid, int64_t start_node_num, int64_t num_nodes, v
 
   if ((status = nc_inq_dimlen(exoid, numnoddim, &num_nod)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get number of nodes in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -116,7 +111,7 @@ int ex_get_partial_coord(int exoid, int64_t start_node_num, int64_t num_nodes, v
              "ERROR: start index (%" PRId64 ") + node count (%" PRId64
              ") is larger than total number of nodes (%" ST_ZU ") in file id %d",
              start_node_num, num_nodes, num_nod, exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -130,7 +125,7 @@ int ex_get_partial_coord(int exoid, int64_t start_node_num, int64_t num_nodes, v
     if ((status = nc_inq_varid(exoid, VAR_COORD, &coordid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate nodal coordinates in file id %d",
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -176,7 +171,7 @@ int ex_get_partial_coord(int exoid, int64_t start_node_num, int64_t num_nodes, v
       if (status != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get %s coord array in file id %d", which,
                  exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
     }
@@ -185,7 +180,7 @@ int ex_get_partial_coord(int exoid, int64_t start_node_num, int64_t num_nodes, v
     if ((status = nc_inq_varid(exoid, VAR_COORD_X, &coordidx)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate x nodal coordinates in file id %d",
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -193,7 +188,7 @@ int ex_get_partial_coord(int exoid, int64_t start_node_num, int64_t num_nodes, v
       if ((status = nc_inq_varid(exoid, VAR_COORD_Y, &coordidy)) != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to locate y nodal coordinates in file id %d", exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
     }
@@ -205,7 +200,7 @@ int ex_get_partial_coord(int exoid, int64_t start_node_num, int64_t num_nodes, v
       if ((status = nc_inq_varid(exoid, VAR_COORD_Z, &coordidz)) != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to locate z nodal coordinates in file id %d", exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
     }
@@ -251,7 +246,7 @@ int ex_get_partial_coord(int exoid, int64_t start_node_num, int64_t num_nodes, v
         if (status != NC_NOERR) {
           snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get %s coord array in file id %d",
                    which, exoid);
-          ex_err(__func__, errmsg, status);
+          ex_err_fn(exoid, __func__, errmsg, status);
           EX_FUNC_LEAVE(EX_FATAL);
         }
       }
diff --git a/src/ex_get_partial_coord_component.c b/src/ex_get_partial_coord_component.c
index 0e9add57b6f..b4f1363bd1e 100644
--- a/src/ex_get_partial_coord_component.c
+++ b/src/ex_get_partial_coord_component.c
@@ -35,11 +35,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, ex_comp_ws, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, etc
-#include <inttypes.h>     // for PRId64
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <sys/types.h> // for int64_t
 
 /*!
  * reads the coordinates of some of the nodes in the model for the specified component
@@ -82,7 +77,7 @@ int ex_get_partial_coord_component(int exoid, int64_t start_node_num, int64_t nu
 
   if ((status = nc_inq_dimlen(exoid, numnoddim, &num_nod)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get number of nodes in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -92,7 +87,7 @@ int ex_get_partial_coord_component(int exoid, int64_t start_node_num, int64_t nu
              "ERROR: start index (%" PRId64 ") + node count (%" PRId64
              ") is larger than total number of nodes (%" ST_ZU ") in file id %d",
              start_node_num, num_nodes, num_nod, exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -105,7 +100,7 @@ int ex_get_partial_coord_component(int exoid, int64_t start_node_num, int64_t nu
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: Component (%d) is larger than number of dimensions (%" ST_ZU ") in file id %d",
              component, num_dim, exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
   --component;
@@ -115,7 +110,7 @@ int ex_get_partial_coord_component(int exoid, int64_t start_node_num, int64_t nu
     if ((status = nc_inq_varid(exoid, VAR_COORD, &coordid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate nodal coordinates in file id %d",
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -139,7 +134,7 @@ int ex_get_partial_coord_component(int exoid, int64_t start_node_num, int64_t nu
       if (status != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get %c coord array in file id %d",
                  which[component], exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
     }
@@ -158,7 +153,7 @@ int ex_get_partial_coord_component(int exoid, int64_t start_node_num, int64_t nu
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to locate %c nodal coordinates in file id %d", which[component],
                  exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
 
@@ -172,7 +167,7 @@ int ex_get_partial_coord_component(int exoid, int64_t start_node_num, int64_t nu
       if (status != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get %c coord array in file id %d",
                  which[component], exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
     }
diff --git a/src/ex_get_partial_id_map.c b/src/ex_get_partial_id_map.c
index 2b5f777f36d..2edfad4bd04 100644
--- a/src/ex_get_partial_id_map.c
+++ b/src/ex_get_partial_id_map.c
@@ -35,10 +35,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, EX_NOERR, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_get_vara_int, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <sys/types.h> // for int64_t
 
 /*
  * reads the id map
@@ -83,7 +79,7 @@ int ex_get_partial_id_map(int exoid, ex_entity_type map_type, int64_t start_enti
   default:
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: Bad map type (%d) specified for file id %d", map_type,
              exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -92,15 +88,24 @@ int ex_get_partial_id_map(int exoid, ex_entity_type map_type, int64_t start_enti
     EX_FUNC_LEAVE(EX_NOERR);
   }
 
-  if (nc_inq_varid(exoid, vmap, &mapid) != NC_NOERR) {
-    if ((status = nc_inq_dimlen(exoid, dimid, &num_entries)) != NC_NOERR) {
-      snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get number of %ss in file id %d", tname,
-               exoid);
-      ex_err(__func__, errmsg, status);
-      EX_FUNC_LEAVE(EX_FATAL);
-    }
+  if ((status = nc_inq_dimlen(exoid, dimid, &num_entries)) != NC_NOERR) {
+    snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get number of %ss in file id %d", tname,
+             exoid);
+    ex_err_fn(exoid, __func__, errmsg, status);
+    EX_FUNC_LEAVE(EX_FATAL);
+  }
 
-    /* generate default map of 1..n, where n is num_entries */
+  if (start_entity_num + num_entities - 1 > num_entries) {
+    snprintf(errmsg, MAX_ERR_LENGTH,
+             "ERROR: start index (%" PRId64 ") + entity count (%" PRId64
+             ") is larger than total number of entities (%" ST_ZU ") in file id %d",
+             start_entity_num, num_entities, num_entries, exoid);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
+    EX_FUNC_LEAVE(EX_FATAL);
+  }
+
+  if (nc_inq_varid(exoid, vmap, &mapid) != NC_NOERR) {
+    /* generate portion of the default map (1..num_entries) */
     if (ex_int64_status(exoid) & EX_MAPS_INT64_API) {
       int64_t *lmap = (int64_t *)map;
       for (i = 0; i < num_entities; i++) {
@@ -133,7 +138,7 @@ int ex_get_partial_id_map(int exoid, ex_entity_type map_type, int64_t start_enti
 
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get %s id map in file id %d", tname, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     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 b8f7f8f80d0..74cfd888d7c 100644
--- a/src/ex_get_partial_nodal_var_int.c
+++ b/src/ex_get_partial_nodal_var_int.c
@@ -55,12 +55,8 @@
  *
  *****************************************************************************/
 
-#include "vtk_netcdf.h"       // for nc_inq_varid, NC_NOERR, etc
 #include <exodusII.h>     // for ex_err, etc
 #include <exodusII_int.h> // for EX_WARN, ex_comp_ws, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <sys/types.h> // for int64_t
 
 /*!
   \ingroup ResultsData
@@ -85,7 +81,7 @@ int ex_get_partial_nodal_var_int(int exoid, int time_step, int nodal_var_index,
     if ((status = nc_inq_varid(exoid, VAR_NOD_VAR, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "Warning: could not find nodal variables in file id %d",
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_WARN);
     }
 
@@ -103,7 +99,7 @@ int ex_get_partial_nodal_var_int(int exoid, int time_step, int nodal_var_index,
     if ((status = nc_inq_varid(exoid, VAR_NOD_VAR_NEW(nodal_var_index), &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "Warning: could not find nodal variable %d in file id %d",
                nodal_var_index, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_WARN);
     }
 
@@ -126,7 +122,7 @@ int ex_get_partial_nodal_var_int(int exoid, int time_step, int nodal_var_index,
 
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get nodal variables in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
   EX_FUNC_LEAVE(EX_NOERR);
diff --git a/src/ex_get_partial_num_map.c b/src/ex_get_partial_num_map.c
index 11db9ddb407..59ba3086b62 100644
--- a/src/ex_get_partial_num_map.c
+++ b/src/ex_get_partial_num_map.c
@@ -53,11 +53,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, EX_NOERR, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_inq_dimid, etc
-#include <inttypes.h>     // for PRId64
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <sys/types.h> // for int64_t
 
 /*
  * reads the element map with specified ID
@@ -94,7 +89,7 @@ int ex_get_partial_num_map(int exoid, ex_entity_type map_type, ex_entity_id map_
     break;
   default:
     snprintf(errmsg, MAX_ERR_LENGTH, "Bad map type (%d) specified", map_type);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -106,27 +101,27 @@ int ex_get_partial_num_map(int exoid, ex_entity_type map_type, ex_entity_id map_
   if ((status = nc_inq_dimlen(exoid, dimid, &num_mobj)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get number of mesh objects in file id %d",
              exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
   /* Check input parameters for a valid range of numbers */
   if (ent_start <= 0 || ent_start > num_mobj) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: start count is invalid in file id %d", exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
   if (ent_count < 0) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: Invalid count value in file id %d", exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
   if (ent_start + ent_count - 1 > num_mobj) {
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: start+count-1 is larger than element count in file id %d", exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -134,7 +129,7 @@ int ex_get_partial_num_map(int exoid, ex_entity_type map_type, ex_entity_id map_
   if ((status = nc_inq_dimid(exoid, dim_num_maps, &dimid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "Warning: no %ss defined in file id %d",
              ex_name_of_object(map_type), exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_WARN);
   }
 
@@ -144,7 +139,7 @@ int ex_get_partial_num_map(int exoid, ex_entity_type map_type, ex_entity_id map_
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to locate %s id %" PRId64 " in id variable in file id %d",
              ex_name_of_object(map_type), map_id, exoid);
-    ex_err(__func__, errmsg, EX_LASTERR);
+    ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -152,7 +147,7 @@ int ex_get_partial_num_map(int exoid, ex_entity_type map_type, ex_entity_id map_
   if ((status = nc_inq_varid(exoid, ex_name_of_map(map_type, id_ndx), &var_id)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate %s %" PRId64 " in file id %d",
              ex_name_of_object(map_type), map_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -173,7 +168,7 @@ int ex_get_partial_num_map(int exoid, ex_entity_type map_type, ex_entity_id map_
   if (status == -1) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get %s in file id %d",
              ex_name_of_object(map_type), exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
   EX_FUNC_LEAVE(EX_NOERR);
diff --git a/src/ex_get_partial_one_attr.c b/src/ex_get_partial_one_attr.c
index 355cf59291e..e18e0c49ce5 100644
--- a/src/ex_get_partial_one_attr.c
+++ b/src/ex_get_partial_one_attr.c
@@ -56,11 +56,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, ex_get_dimension, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, etc
-#include <inttypes.h>     // for PRId64
-#include <stddef.h>       // for size_t, ptrdiff_t
-#include <stdio.h>
-#include <sys/types.h> // for int64_t
 
 /*!
  * reads the specified attribute for a subsect of a block
@@ -110,13 +105,13 @@ int ex_get_partial_one_attr(int exoid, ex_entity_type obj_type, ex_entity_id obj
           snprintf(errmsg, MAX_ERR_LENGTH,
                    "Warning: no attributes found for NULL %s %" PRId64 " in file id %d",
                    ex_name_of_object(obj_type), obj_id, exoid);
-          ex_err(__func__, errmsg, EX_NULLENTITY);
+          ex_err_fn(exoid, __func__, errmsg, EX_NULLENTITY);
           EX_FUNC_LEAVE(EX_WARN); /* no attributes for this object */
         }
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "Warning: failed to locate %s id%" PRId64 " in id array in file id %d",
                  ex_name_of_object(obj_type), obj_id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_WARN);
       }
     }
@@ -172,7 +167,7 @@ int ex_get_partial_one_attr(int exoid, ex_entity_type obj_type, ex_entity_id obj
     snprintf(errmsg, MAX_ERR_LENGTH,
              "Internal ERROR: unrecognized object type in switch: %d in file id %d", obj_type,
              exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL); /* number of attributes not defined */
   }
 
@@ -187,7 +182,7 @@ int ex_get_partial_one_attr(int exoid, ex_entity_type obj_type, ex_entity_id obj
              "ERROR: start index (%" PRId64 ") + count (%" PRId64
              ") is larger than total number of entities (%" ST_ZU ") in file id %d",
              start_num, num_ent, num_entries_this_obj, exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -200,7 +195,7 @@ int ex_get_partial_one_attr(int exoid, ex_entity_type obj_type, ex_entity_id obj
              "ERROR: Invalid attribute index specified: %d.  Valid "
              "range is 1 to %d for %s %" PRId64 " in file id %d",
              attrib_index, (int)num_attr, ex_name_of_object(obj_type), obj_id, exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -208,7 +203,7 @@ int ex_get_partial_one_attr(int exoid, ex_entity_type obj_type, ex_entity_id obj
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to locate attributes for %s %" PRId64 " in file id %d",
              ex_name_of_object(obj_type), obj_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -236,7 +231,7 @@ int ex_get_partial_one_attr(int exoid, ex_entity_type obj_type, ex_entity_id obj
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to get attribute %d for %s %" PRId64 " in file id %d", attrib_index,
              ex_name_of_object(obj_type), obj_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
   EX_FUNC_LEAVE(EX_NOERR);
diff --git a/src/ex_get_partial_set.c b/src/ex_get_partial_set.c
index 07e98c784a2..0da073fd972 100644
--- a/src/ex_get_partial_set.c
+++ b/src/ex_get_partial_set.c
@@ -32,35 +32,12 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  */
-/*****************************************************************************
-*
-* expss - ex_put_set
-*
-* entry conditions -
-*   input parameters:
-*       int     exoid                   exodus file id
-*       int     set_type                set type
-*       int     set_id                  set id
-*       int*    set_entry_list          array of entries in set
-*       int*    set_extra_list          array of extras in set
-
-* exit conditions -
-*
-* revision history -
-*
-*
-*****************************************************************************/
 
 #include "exodusII.h"     // for ex_err, ex_name_of_object, etc
 #include "exodusII_int.h" // for ex_is_parallel, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_get_vara_int, etc
-#include <inttypes.h>     // for PRId64
-#include <stddef.h>       // for size_t, NULL
-#include <stdint.h>       // for int64_t
-#include <stdio.h>        // for snprintf
 
 /*!
- * writes the set entry list and set extra list for a single set
+ * reads a portion of the set entry list and set extra list for a single set
  * \param   exoid                   exodus file id
  * \param   set_type                set type
  * \param   set_id                  set id
@@ -89,7 +66,7 @@ int ex_get_partial_set(int exoid, ex_entity_type set_type, ex_entity_id set_id,
   if ((status = nc_inq_dimid(exoid, ex_dim_num_objects(set_type), &dimid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: no %ss defined in file id %d",
              ex_name_of_object(set_type), exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -103,13 +80,13 @@ int ex_get_partial_set(int exoid, ex_entity_type set_type, ex_entity_id set_id,
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "Warning: no data allowed for NULL %s %" PRId64 " in file id %d",
                  ex_name_of_object(set_type), set_id, exoid);
-        ex_err(__func__, errmsg, EX_NULLENTITY);
+        ex_err_fn(exoid, __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",
                ex_name_of_object(set_type), set_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -141,7 +118,7 @@ int ex_get_partial_set(int exoid, ex_entity_type set_type, ex_entity_id set_id,
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to locate entry list for %s %" PRId64 " in file id %d",
              ex_name_of_object(set_type), set_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -164,7 +141,7 @@ int ex_get_partial_set(int exoid, ex_entity_type set_type, ex_entity_id set_id,
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to get entry list for %s %" PRId64 " in file id %d",
                ex_name_of_object(set_type), set_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -175,7 +152,7 @@ int ex_get_partial_set(int exoid, ex_entity_type set_type, ex_entity_id set_id,
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to locate extra list for %s %" PRId64 " in file id %d",
                ex_name_of_object(set_type), set_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -195,7 +172,7 @@ int ex_get_partial_set(int exoid, ex_entity_type set_type, ex_entity_id set_id,
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to get extra list for %s %" PRId64 " in file id %d",
                ex_name_of_object(set_type), set_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -205,7 +182,7 @@ int ex_get_partial_set(int exoid, ex_entity_type set_type, ex_entity_id set_id,
     snprintf(errmsg, MAX_ERR_LENGTH,
              "Warning: extra list was ignored for %s %" PRId64 " in file id %d",
              ex_name_of_object(set_type), set_id, exoid);
-    ex_err(__func__, errmsg, EX_MSG);
+    ex_err_fn(exoid, __func__, errmsg, EX_MSG);
     EX_FUNC_LEAVE(EX_WARN);
   }
 
diff --git a/src/ex_get_partial_set_dist_fact.c b/src/ex_get_partial_set_dist_fact.c
index eee053b6de1..8f290dff6cc 100644
--- a/src/ex_get_partial_set_dist_fact.c
+++ b/src/ex_get_partial_set_dist_fact.c
@@ -35,11 +35,6 @@
 
 #include "exodusII.h"     // for ex_err, ex_name_of_object, etc
 #include "exodusII_int.h" // for ex_check_valid_file_id, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, etc
-#include <inttypes.h>     // for PRId64
-#include <stddef.h>       // for size_t, NULL
-#include <stdint.h>       // for int64_t
-#include <stdio.h>        // for snprintf
 
 /*!
  * reads the distribution factors for a single set
@@ -62,7 +57,7 @@ int ex_get_partial_set_dist_fact(int exoid, ex_entity_type set_type, ex_entity_i
   if ((status = nc_inq_dimid(exoid, ex_dim_num_objects(set_type), &dimid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "Warning: no %s sets stored in file id %d",
              ex_name_of_object(set_type), exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_WARN);
   }
 
@@ -75,13 +70,13 @@ int ex_get_partial_set_dist_fact(int exoid, ex_entity_type set_type, ex_entity_i
       if (status == EX_NULLENTITY) {
         snprintf(errmsg, MAX_ERR_LENGTH, "Warning: %s set %" PRId64 " is NULL in file id %d",
                  ex_name_of_object(set_type), set_id, exoid);
-        ex_err(__func__, errmsg, EX_NULLENTITY);
+        ex_err_fn(exoid, __func__, errmsg, EX_NULLENTITY);
         EX_FUNC_LEAVE(EX_WARN);
       }
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to locate %s set %" PRId64 " in VAR_*S_IDS array in file id %d",
                ex_name_of_object(set_type), set_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -111,7 +106,7 @@ int ex_get_partial_set_dist_fact(int exoid, ex_entity_type set_type, ex_entity_i
       snprintf(errmsg, MAX_ERR_LENGTH,
                "Warning: dist factors not stored for %s set %" PRId64 " in file id %d",
                ex_name_of_object(set_type), set_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_WARN); /* complain - but not too loud */
     }
     /* is an error for other sets */
@@ -119,7 +114,7 @@ int ex_get_partial_set_dist_fact(int exoid, ex_entity_type set_type, ex_entity_i
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to locate dist factors list for %s set %" PRId64 " in file id %d",
              ex_name_of_object(set_type), set_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -140,7 +135,7 @@ int ex_get_partial_set_dist_fact(int exoid, ex_entity_type set_type, ex_entity_i
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to get dist factors list for %s set %" PRId64 " in file id %d",
              ex_name_of_object(set_type), set_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
   EX_FUNC_LEAVE(EX_NOERR);
diff --git a/src/ex_get_partial_var.c b/src/ex_get_partial_var.c
index 8fca6a534f0..af924f22330 100644
--- a/src/ex_get_partial_var.c
+++ b/src/ex_get_partial_var.c
@@ -35,11 +35,6 @@
 
 #include "exodusII.h"     // for ex_err, ex_name_of_object, etc
 #include "exodusII_int.h" // for ex_check_valid_file_id, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, etc
-#include <inttypes.h>     // for PRId64
-#include <stddef.h>       // for size_t
-#include <stdint.h>       // for int64_t
-#include <stdio.h>        // for snprintf
 
 /*
  * reads the values of a single element variable for one element block at
@@ -105,13 +100,13 @@ int ex_get_partial_var(int exoid, int time_step, ex_entity_type var_type, int va
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "Warning: no %s variables for NULL block %" PRId64 " in file id %d",
                  ex_name_of_object(var_type), obj_id, exoid);
-        ex_err(__func__, errmsg, EX_NULLENTITY);
+        ex_err_fn(exoid, __func__, errmsg, EX_NULLENTITY);
         EX_FUNC_LEAVE(EX_WARN);
       }
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to locate %s id %" PRId64 " in id variable in file id %d",
                ex_name_of_object(var_type), obj_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -122,7 +117,7 @@ int ex_get_partial_var(int exoid, int time_step, ex_entity_type var_type, int va
                              &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate %s %" PRId64 " var %d in file id %d",
              ex_name_of_object(var_type), obj_id, var_index, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -147,7 +142,7 @@ int ex_get_partial_var(int exoid, int time_step, ex_entity_type var_type, int va
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to get %s %" PRId64 " variable %d in file id %d",
              ex_name_of_object(var_type), obj_id, var_index, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
   EX_FUNC_LEAVE(EX_NOERR);
diff --git a/src/ex_get_processor_elem_maps.c b/src/ex_get_processor_elem_maps.c
index 95bb78e6f11..d676a65ade0 100644
--- a/src/ex_get_processor_elem_maps.c
+++ b/src/ex_get_processor_elem_maps.c
@@ -52,10 +52,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, VAR_INT_E_STAT, etc
-#include <vtk_netcdf.h>       // for NC_NOERR, nc_inq_varid, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <sys/types.h> // for int64_t
 
 int ex_get_processor_elem_maps(int exoid, void_int *elem_mapi, void_int *elem_mapb, int processor)
 {
@@ -73,7 +69,7 @@ int ex_get_processor_elem_maps(int exoid, void_int *elem_mapi, void_int *elem_ma
   /* Get the file type */
   if (ex_get_file_type(exoid, ftype) != EX_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: unable to find file type for file ID %d", exoid);
-    ex_err(__func__, errmsg, EX_LASTERR);
+    ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -82,7 +78,7 @@ int ex_get_processor_elem_maps(int exoid, void_int *elem_mapi, void_int *elem_ma
   if ((status = nc_inq_varid(exoid, VAR_INT_E_STAT, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
              VAR_INT_E_STAT, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -96,7 +92,7 @@ int ex_get_processor_elem_maps(int exoid, void_int *elem_mapi, void_int *elem_ma
   if ((status = nc_get_var1_int(exoid, varid, start, &emstat)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get status for \"%s\" from file ID %d",
              VAR_INT_E_STAT, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -106,7 +102,7 @@ int ex_get_processor_elem_maps(int exoid, void_int *elem_mapi, void_int *elem_ma
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to find index variable, \"%s\", in file ID %d", VAR_ELEM_MAP_INT_IDX,
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
 
       EX_FUNC_LEAVE(EX_FATAL);
     }
@@ -117,7 +113,7 @@ int ex_get_processor_elem_maps(int exoid, void_int *elem_mapi, void_int *elem_ma
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to find dimension ID for \"%s\" in file ID %d", DIM_NUM_INT_ELEMS,
                  exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
 
@@ -125,7 +121,7 @@ int ex_get_processor_elem_maps(int exoid, void_int *elem_mapi, void_int *elem_ma
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to find length of dimension \"%s\" in file ID %d",
                  DIM_NUM_INT_ELEMS, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
 
@@ -136,7 +132,7 @@ int ex_get_processor_elem_maps(int exoid, void_int *elem_mapi, void_int *elem_ma
     if ((status = nc_inq_varid(exoid, VAR_ELEM_MAP_INT, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
                VAR_ELEM_MAP_INT, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -152,7 +148,7 @@ int ex_get_processor_elem_maps(int exoid, void_int *elem_mapi, void_int *elem_ma
     if (status != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get variable \"%s\" from file ID %d",
                VAR_ELEM_MAP_INT, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -162,7 +158,7 @@ int ex_get_processor_elem_maps(int exoid, void_int *elem_mapi, void_int *elem_ma
   if ((status = nc_inq_varid(exoid, VAR_BOR_E_STAT, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
              VAR_BOR_E_STAT, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -176,7 +172,7 @@ int ex_get_processor_elem_maps(int exoid, void_int *elem_mapi, void_int *elem_ma
   if ((status = nc_get_var1_int(exoid, varid, start, &emstat)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get status for \"%s\" from file ID %d",
              VAR_INT_E_STAT, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -186,7 +182,7 @@ int ex_get_processor_elem_maps(int exoid, void_int *elem_mapi, void_int *elem_ma
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to find index variable, \"%s\", in file ID %d", VAR_ELEM_MAP_BOR_IDX,
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
 
       EX_FUNC_LEAVE(EX_FATAL);
     }
@@ -197,7 +193,7 @@ int ex_get_processor_elem_maps(int exoid, void_int *elem_mapi, void_int *elem_ma
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to find dimension ID for \"%s\" in file ID %d", DIM_NUM_BOR_ELEMS,
                  exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
 
@@ -205,7 +201,7 @@ int ex_get_processor_elem_maps(int exoid, void_int *elem_mapi, void_int *elem_ma
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to find length of dimension \"%s\" in file ID %d",
                  DIM_NUM_BOR_ELEMS, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
 
@@ -216,7 +212,7 @@ int ex_get_processor_elem_maps(int exoid, void_int *elem_mapi, void_int *elem_ma
     if ((status = nc_inq_varid(exoid, VAR_ELEM_MAP_BOR, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
                VAR_ELEM_MAP_BOR, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -232,7 +228,7 @@ int ex_get_processor_elem_maps(int exoid, void_int *elem_mapi, void_int *elem_ma
     if (status != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get variable \"%s\" from file ID %d",
                VAR_ELEM_MAP_BOR, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   } /* End "if (emstat == 1)" */
diff --git a/src/ex_get_processor_node_maps.c b/src/ex_get_processor_node_maps.c
index 667bf9a67f1..b7144ab9b34 100644
--- a/src/ex_get_processor_node_maps.c
+++ b/src/ex_get_processor_node_maps.c
@@ -55,10 +55,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, DIM_NUM_BOR_NODES, etc
-#include <vtk_netcdf.h>       // for NC_NOERR, nc_inq_varid, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <sys/types.h> // for int64_t
 
 int ex_get_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_mapb,
                                void_int *node_mape, int processor)
@@ -78,7 +74,7 @@ int ex_get_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_ma
   /* Get the file type */
   if (ex_get_file_type(exoid, ftype) != EX_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: unable to find file type for file ID %d", exoid);
-    ex_err(__func__, errmsg, EX_LASTERR);
+    ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -86,7 +82,7 @@ int ex_get_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_ma
   if ((status = nc_inq_varid(exoid, VAR_INT_N_STAT, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" from file ID %d",
              VAR_INT_N_STAT, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -100,7 +96,7 @@ int ex_get_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_ma
   if (nc_get_var1_int(exoid, varid, start, &nmstat) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get status for \"%s\" in file ID %d",
              VAR_INT_N_STAT, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -110,7 +106,7 @@ int ex_get_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_ma
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to find index variable, \"%s\", in file ID %d", VAR_NODE_MAP_INT_IDX,
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
 
       EX_FUNC_LEAVE(EX_FATAL);
     }
@@ -121,7 +117,7 @@ int ex_get_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_ma
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to find dimension ID for \"%s\" in file ID %d", DIM_NUM_INT_NODES,
                  exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
 
@@ -129,7 +125,7 @@ int ex_get_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_ma
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to find length of dimension \"%s\" in file ID %d",
                  DIM_NUM_INT_NODES, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
       varidx[1] = count[0];
@@ -138,7 +134,7 @@ int ex_get_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_ma
     if ((status = nc_inq_varid(exoid, VAR_NODE_MAP_INT, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
                VAR_NODE_MAP_INT, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -153,7 +149,7 @@ int ex_get_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_ma
     if (status != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get variable \"%s\" from file ID %d",
                VAR_NODE_MAP_INT, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -163,7 +159,7 @@ int ex_get_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_ma
   if ((status = nc_inq_varid(exoid, VAR_BOR_N_STAT, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" from file ID %d",
              VAR_BOR_N_STAT, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -177,7 +173,7 @@ int ex_get_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_ma
   if (nc_get_var1_int(exoid, varid, start, &nmstat) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get status for \"%s\" from file ID %d",
              VAR_BOR_N_STAT, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -187,7 +183,7 @@ int ex_get_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_ma
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to find index variable, \"%s\", in file ID %d", VAR_NODE_MAP_BOR_IDX,
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
 
       EX_FUNC_LEAVE(EX_FATAL);
     }
@@ -198,7 +194,7 @@ int ex_get_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_ma
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to find dimension ID for \"%s\" in file ID %d", DIM_NUM_BOR_NODES,
                  exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
 
@@ -206,7 +202,7 @@ int ex_get_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_ma
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to find length of dimension \"%s\" in file ID %d",
                  DIM_NUM_BOR_NODES, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
       varidx[1] = count[0];
@@ -215,7 +211,7 @@ int ex_get_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_ma
     if ((status = nc_inq_varid(exoid, VAR_NODE_MAP_BOR, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
                VAR_NODE_MAP_BOR, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -230,7 +226,7 @@ int ex_get_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_ma
     if (status != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get variable \"%s\" from file ID %d",
                VAR_NODE_MAP_BOR, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   } /* End "if (nmstat == 1)" */
@@ -239,7 +235,7 @@ int ex_get_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_ma
   if ((status = nc_inq_varid(exoid, VAR_EXT_N_STAT, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" from file ID %d",
              VAR_EXT_N_STAT, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -253,7 +249,7 @@ int ex_get_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_ma
   if (nc_get_var1_int(exoid, varid, start, &nmstat) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get status for \"%s\" from file ID %d",
              VAR_EXT_N_STAT, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -263,7 +259,7 @@ int ex_get_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_ma
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to find index variable, \"%s\", in file ID %d", VAR_NODE_MAP_EXT_IDX,
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
 
       EX_FUNC_LEAVE(EX_FATAL);
     }
@@ -274,7 +270,7 @@ int ex_get_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_ma
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to find dimension ID for \"%s\" in file ID %d", DIM_NUM_EXT_NODES,
                  exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
 
@@ -282,7 +278,7 @@ int ex_get_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_ma
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to find length of dimension \"%s\" in file ID %d",
                  DIM_NUM_EXT_NODES, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
       varidx[1] = count[0];
@@ -291,7 +287,7 @@ int ex_get_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_ma
     if ((status = nc_inq_varid(exoid, VAR_NODE_MAP_EXT, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
                VAR_NODE_MAP_EXT, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -306,7 +302,7 @@ int ex_get_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_ma
     if (status != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get variable \"%s\" from file ID %d",
                VAR_NODE_MAP_EXT, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   } /* End "if (nmstat == 1)" */
diff --git a/src/ex_get_prop.c b/src/ex_get_prop.c
index a5748b93b54..5660924596a 100644
--- a/src/ex_get_prop.c
+++ b/src/ex_get_prop.c
@@ -35,12 +35,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, EX_WARN, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_get_att_text, etc
-#include <inttypes.h>     // for PRId64
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <string.h>    // for memset, strcmp
-#include <sys/types.h> // for int64_t
 
 /*!
 
@@ -120,14 +114,14 @@ int ex_get_prop(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, const c
     default:
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: object type %d not supported; file id %d", obj_type,
                exoid);
-      ex_err(__func__, errmsg, EX_BADPARAM);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
     if ((status = nc_inq_varid(exoid, name, &propid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate property array %s in file id %d",
                name, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -135,7 +129,7 @@ int ex_get_prop(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, const c
     memset(tmpstr, 0, MAX_STR_LENGTH + 1);
     if ((status = nc_get_att_text(exoid, propid, ATT_PROP_NAME, tmpstr)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get property name in file id %d", exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -149,7 +143,7 @@ int ex_get_prop(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, const c
   if (!found) {
     snprintf(errmsg, MAX_ERR_LENGTH, "Warning: %s property %s not defined in file id %d",
              ex_name_of_object(obj_type), prop_name, exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_WARN);
   }
 
@@ -167,13 +161,13 @@ int ex_get_prop(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, const c
       if (status == EX_NULLENTITY) {
         snprintf(errmsg, MAX_ERR_LENGTH, "Warning: %s id %" PRId64 " is NULL in file id %d",
                  ex_name_of_object(obj_type), obj_id, exoid);
-        ex_err(__func__, errmsg, EX_NULLENTITY);
+        ex_err_fn(exoid, __func__, errmsg, EX_NULLENTITY);
         EX_FUNC_LEAVE(EX_WARN);
       }
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to locate id %" PRId64 " in %s property array in file id %d", obj_id,
                ex_name_of_object(obj_type), exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -199,7 +193,7 @@ int ex_get_prop(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, const c
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to read value in %s property array in file id %d",
              ex_name_of_object(obj_type), exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
diff --git a/src/ex_get_prop_array.c b/src/ex_get_prop_array.c
index e5e020a6f40..c0fd5442c8b 100644
--- a/src/ex_get_prop_array.c
+++ b/src/ex_get_prop_array.c
@@ -54,9 +54,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, ATT_PROP_NAME, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_get_att_text, etc
-#include <stdio.h>
-#include <string.h> // for memset, strcmp
 
 /*!
 
@@ -147,14 +144,14 @@ int ex_get_prop_array(int exoid, ex_entity_type obj_type, const char *prop_name,
     default:
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: object type %d not supported; file id %d", obj_type,
                exoid);
-      ex_err(__func__, errmsg, EX_BADPARAM);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
     if ((status = nc_inq_varid(exoid, name, &propid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate property array %s in file id %d",
                name, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -162,7 +159,7 @@ int ex_get_prop_array(int exoid, ex_entity_type obj_type, const char *prop_name,
     memset(tmpstr, 0, MAX_STR_LENGTH + 1);
     if ((status = nc_get_att_text(exoid, propid, ATT_PROP_NAME, tmpstr)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get property name in file id %d", exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -177,7 +174,7 @@ int ex_get_prop_array(int exoid, ex_entity_type obj_type, const char *prop_name,
     snprintf(errmsg, MAX_ERR_LENGTH,
              "Warning: object type %d, property %s not defined in file id %d", obj_type, prop_name,
              exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_WARN);
   }
 
@@ -193,7 +190,7 @@ int ex_get_prop_array(int exoid, ex_entity_type obj_type, const char *prop_name,
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to read values in %s property array in file id %d",
              ex_name_of_object(obj_type), exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
diff --git a/src/ex_get_prop_names.c b/src/ex_get_prop_names.c
index b790645393c..15ba024c328 100644
--- a/src/ex_get_prop_names.c
+++ b/src/ex_get_prop_names.c
@@ -35,9 +35,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, ATT_PROP_NAME, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_get_att_text, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
 
 /*!
 
@@ -141,14 +138,14 @@ int ex_get_prop_names(int exoid, ex_entity_type obj_type, char **prop_names)
     default:
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: object type %d not supported; file id %d", obj_type,
                exoid);
-      ex_err(__func__, errmsg, EX_BADPARAM);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
     if ((status = nc_inq_varid(exoid, var_name, &propid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate property array %s in file id %d",
                var_name, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -157,7 +154,7 @@ int ex_get_prop_names(int exoid, ex_entity_type obj_type, char **prop_names)
     if ((status = nc_inq_att(exoid, propid, ATT_PROP_NAME, &att_type, &att_len)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to get property attributes (type, len) in file id %d", exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -165,7 +162,7 @@ int ex_get_prop_names(int exoid, ex_entity_type obj_type, char **prop_names)
       /* Client has large enough char string to hold text... */
       if ((status = nc_get_att_text(exoid, propid, ATT_PROP_NAME, prop_names[i])) != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get property name in file id %d", exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
     }
@@ -175,7 +172,7 @@ int ex_get_prop_names(int exoid, ex_entity_type obj_type, char **prop_names)
                "ERROR: property name length exceeds space available to "
                "store it in file id %d",
                exoid);
-      ex_err(__func__, errmsg, NC_ESTS);
+      ex_err_fn(exoid, __func__, errmsg, NC_ESTS);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
diff --git a/src/ex_get_qa.c b/src/ex_get_qa.c
index 15c46bb743b..5c3302f633a 100644
--- a/src/ex_get_qa.c
+++ b/src/ex_get_qa.c
@@ -35,9 +35,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, ex_trim_internal, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_get_vara_text, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
 
 /*!
 The function ex_get_qa() reads the QA records from the database. Each
@@ -98,14 +95,14 @@ int ex_get_qa(int exoid, char *qa_record[][4])
   /* inquire previously defined dimensions and variables  */
   if ((status = nc_inq_dimid(rootid, DIM_NUM_QA, &dimid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "Warning: no qa records stored in file id %d", rootid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_WARN);
   }
 
   if ((status = nc_inq_dimlen(rootid, dimid, &num_qa_records)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get number of qa records in file id %d",
              rootid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -114,7 +111,7 @@ int ex_get_qa(int exoid, char *qa_record[][4])
     if ((status = nc_inq_varid(rootid, VAR_QA_TITLE, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate qa record data in file id %d",
                rootid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -130,7 +127,7 @@ int ex_get_qa(int exoid, char *qa_record[][4])
         if ((status = nc_get_vara_text(rootid, varid, start, count, qa_record[i][j])) != NC_NOERR) {
           snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get qa record data in file id %d",
                    rootid);
-          ex_err(__func__, errmsg, status);
+          ex_err_fn(exoid, __func__, errmsg, status);
           EX_FUNC_LEAVE(EX_FATAL);
         }
         qa_record[i][j][MAX_STR_LENGTH] = '\0';
diff --git a/src/ex_get_set.c b/src/ex_get_set.c
index e929102398c..958b26f7325 100644
--- a/src/ex_get_set.c
+++ b/src/ex_get_set.c
@@ -35,9 +35,6 @@
 
 #include "exodusII.h"     // for ex_err, ex_name_of_object, etc
 #include "exodusII_int.h" // for ex_check_valid_file_id, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_get_var_int, etc
-#include <inttypes.h>     // for PRId64
-#include <stdio.h>        // for snprintf, NULL
 
 /*!
  * reads the set entry list and set extra list for a single set
@@ -67,7 +64,7 @@ int ex_get_set(int exoid, ex_entity_type set_type, ex_entity_id set_id, void_int
   if ((status = nc_inq_dimid(exoid, ex_dim_num_objects(set_type), &dimid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "Warning: no %ss stored in file id %d",
              ex_name_of_object(set_type), exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_WARN);
   }
 
@@ -80,14 +77,14 @@ int ex_get_set(int exoid, ex_entity_type set_type, ex_entity_id set_id, void_int
       if (status == EX_NULLENTITY) {
         snprintf(errmsg, MAX_ERR_LENGTH, "Warning: %s %" PRId64 " is NULL in file id %d",
                  ex_name_of_object(set_type), set_id, exoid);
-        ex_err(__func__, errmsg, EX_NULLENTITY);
+        ex_err_fn(exoid, __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",
                ex_name_of_object(set_type), set_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -109,7 +106,7 @@ int ex_get_set(int exoid, ex_entity_type set_type, ex_entity_id set_id, void_int
     entryptr = VAR_ELEM_SS(set_id_ndx);
     extraptr = VAR_SIDE_SS(set_id_ndx);
   }
-  if (set_type == EX_ELEM_SET) {
+  else if (set_type == EX_ELEM_SET) {
     entryptr = VAR_ELEM_ELS(set_id_ndx);
     extraptr = NULL;
   }
@@ -119,7 +116,7 @@ int ex_get_set(int exoid, ex_entity_type set_type, ex_entity_id set_id, void_int
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to locate entry list for %s %" PRId64 " in file id %d",
              ex_name_of_object(set_type), set_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -132,7 +129,7 @@ int ex_get_set(int exoid, ex_entity_type set_type, ex_entity_id set_id, void_int
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to locate extra list for %s %" PRId64 " in file id %d",
                ex_name_of_object(set_type), set_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -150,7 +147,7 @@ int ex_get_set(int exoid, ex_entity_type set_type, ex_entity_id set_id, void_int
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to get entry list for %s %" PRId64 " in file id %d",
                ex_name_of_object(set_type), set_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -168,7 +165,7 @@ int ex_get_set(int exoid, ex_entity_type set_type, ex_entity_id set_id, void_int
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to get extra list for %s %" PRId64 " in file id %d",
                ex_name_of_object(set_type), set_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
diff --git a/src/ex_get_set_dist_fact.c b/src/ex_get_set_dist_fact.c
index b2efd0ab995..7b2dcbe0cbd 100644
--- a/src/ex_get_set_dist_fact.c
+++ b/src/ex_get_set_dist_fact.c
@@ -52,9 +52,6 @@
 
 #include "exodusII.h"     // for ex_err, ex_name_of_object, etc
 #include "exodusII_int.h" // for EX_FATAL, EX_WARN, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_get_var_double, etc
-#include <inttypes.h>     // for PRId64
-#include <stdio.h>
 
 /*!
  * reads the distribution factors for a single set
@@ -76,7 +73,7 @@ int ex_get_set_dist_fact(int exoid, ex_entity_type set_type, ex_entity_id set_id
   if ((status = nc_inq_dimid(exoid, ex_dim_num_objects(set_type), &dimid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "Warning: no %s sets stored in file id %d",
              ex_name_of_object(set_type), exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_WARN);
   }
 
@@ -89,13 +86,13 @@ int ex_get_set_dist_fact(int exoid, ex_entity_type set_type, ex_entity_id set_id
       if (status == EX_NULLENTITY) {
         snprintf(errmsg, MAX_ERR_LENGTH, "Warning: %s set %" PRId64 " is NULL in file id %d",
                  ex_name_of_object(set_type), set_id, exoid);
-        ex_err(__func__, errmsg, EX_NULLENTITY);
+        ex_err_fn(exoid, __func__, errmsg, EX_NULLENTITY);
         EX_FUNC_LEAVE(EX_WARN);
       }
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to locate %s set %" PRId64 " in VAR_*S_IDS array in file id %d",
                ex_name_of_object(set_type), set_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -125,7 +122,7 @@ int ex_get_set_dist_fact(int exoid, ex_entity_type set_type, ex_entity_id set_id
       snprintf(errmsg, MAX_ERR_LENGTH,
                "Warning: dist factors not stored for %s set %" PRId64 " in file id %d",
                ex_name_of_object(set_type), set_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_WARN); /* complain - but not too loud */
     }
     /* is an error for other sets */
@@ -133,7 +130,7 @@ int ex_get_set_dist_fact(int exoid, ex_entity_type set_type, ex_entity_id set_id
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to locate dist factors list for %s set %" PRId64 " in file id %d",
              ex_name_of_object(set_type), set_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -149,7 +146,7 @@ int ex_get_set_dist_fact(int exoid, ex_entity_type set_type, ex_entity_id set_id
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to get dist factors list for %s set %" PRId64 " in file id %d",
              ex_name_of_object(set_type), set_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
   EX_FUNC_LEAVE(EX_NOERR);
diff --git a/src/ex_get_set_param.c b/src/ex_get_set_param.c
index fa4270c8502..5c2d6c92562 100644
--- a/src/ex_get_set_param.c
+++ b/src/ex_get_set_param.c
@@ -54,11 +54,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, EX_NOERR, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_inq_dimid, etc
-#include <inttypes.h>     // for PRId64
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <sys/types.h> // for int64_t
 
 /*
  * reads the number of entries and the number of distribution factors which
@@ -99,7 +94,7 @@ int ex_get_set_param(int exoid, ex_entity_type set_type, ex_entity_id set_id,
   if ((status = nc_inq_dimid(exoid, ex_dim_num_objects(set_type), &dimid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "Warning: no %ss stored in file id %d",
              ex_name_of_object(set_type), exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_WARN);
   }
 
@@ -115,7 +110,7 @@ int ex_get_set_param(int exoid, ex_entity_type set_type, ex_entity_id set_id,
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to locate %s id %" PRId64 " in id array in file id %d",
                ex_name_of_object(set_type), set_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -175,7 +170,7 @@ int ex_get_set_param(int exoid, ex_entity_type set_type, ex_entity_id set_id,
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to locate the dist factors for %s %" PRId64 " in file id %d",
                ex_name_of_object(set_type), set_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
     if (ex_int64_status(exoid) & EX_BULK_INT64_API) {
@@ -198,7 +193,7 @@ int ex_get_set_param(int exoid, ex_entity_type set_type, ex_entity_id set_id,
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to locate number of dist factors in %s %" PRId64 " in file id %d",
                ex_name_of_object(set_type), set_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -206,7 +201,7 @@ int ex_get_set_param(int exoid, ex_entity_type set_type, ex_entity_id set_id,
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to get number of dist factors in %s %" PRId64 " in file id %d",
                ex_name_of_object(set_type), set_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
     if (ex_int64_status(exoid) & EX_BULK_INT64_API) {
diff --git a/src/ex_get_sets.c b/src/ex_get_sets.c
index 4703db10574..694a92a5996 100644
--- a/src/ex_get_sets.c
+++ b/src/ex_get_sets.c
@@ -35,7 +35,6 @@
 
 #include "exodusII.h"     // for ex_set, EX_FATAL, EX_NOERR, etc
 #include "exodusII_int.h" // for ex_check_valid_file_id
-#include <stddef.h>       // for NULL, size_t
 
 int ex_get_sets(int exoid, size_t set_count, struct ex_set *sets)
 {
diff --git a/src/ex_get_side_set_node_count.c b/src/ex_get_side_set_node_count.c
index 3474f12ca68..5e94b9aedee 100644
--- a/src/ex_get_side_set_node_count.c
+++ b/src/ex_get_side_set_node_count.c
@@ -50,14 +50,6 @@
 
 #include "exodusII.h"     // for ex_err, ex_block, etc
 #include "exodusII_int.h" // for elem_blk_parm, EX_FATAL, etc
-#include <assert.h>       // for assert
-#include <ctype.h>        // for toupper
-#include <inttypes.h>     // for PRId64
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <stdlib.h>    // for free, malloc
-#include <string.h>    // for strncmp, strlen
-#include <sys/types.h> // for int64_t
 
 int ex_get_side_set_node_count(int exoid, ex_entity_id side_set_id, int *side_set_node_cnt_list)
 {
@@ -86,13 +78,13 @@ int ex_get_side_set_node_count(int exoid, ex_entity_id side_set_id, int *side_se
   if (num_side_sets < 0) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get number of side sets in file id %d",
              exoid);
-    ex_err(__func__, errmsg, EX_LASTERR);
+    ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
   if (num_side_sets == 0) {
     snprintf(errmsg, MAX_ERR_LENGTH, "Warning: no side sets defined in file id %d", exoid);
-    ex_err(__func__, errmsg, EX_WARN);
+    ex_err_fn(exoid, __func__, errmsg, EX_WARN);
     EX_FUNC_LEAVE(EX_WARN);
   }
 
@@ -106,14 +98,14 @@ int ex_get_side_set_node_count(int exoid, ex_entity_id side_set_id, int *side_se
     if (status == EX_NULLENTITY) {
       snprintf(errmsg, MAX_ERR_LENGTH, "Warning: side set %" PRId64 " is NULL in file id %d",
                side_set_id, exoid);
-      ex_err(__func__, errmsg, EX_NULLENTITY);
+      ex_err_fn(exoid, __func__, errmsg, EX_NULLENTITY);
       EX_FUNC_LEAVE(EX_WARN);
     }
 
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to locate side set %" PRId64 " in VAR_SS_IDS array in file id %d",
              side_set_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -121,7 +113,7 @@ int ex_get_side_set_node_count(int exoid, ex_entity_id side_set_id, int *side_se
   if (num_elem_blks < 0) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get number of element blocks in file id %d",
              exoid);
-    ex_err(__func__, errmsg, EX_LASTERR);
+    ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -130,7 +122,7 @@ int ex_get_side_set_node_count(int exoid, ex_entity_id side_set_id, int *side_se
   ndim = ex_inquire_int(exoid, EX_INQ_DIM);
   if (ndim < 0) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get dimensionality in file id %d", exoid);
-    ex_err(__func__, errmsg, EX_LASTERR);
+    ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -158,7 +150,7 @@ int ex_get_side_set_node_count(int exoid, ex_entity_id side_set_id, int *side_se
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to get number of elements in side set %" PRId64 " in file id %d",
              side_set_id, exoid);
-    ex_err(__func__, errmsg, EX_LASTERR);
+    ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -169,7 +161,7 @@ int ex_get_side_set_node_count(int exoid, ex_entity_id side_set_id, int *side_se
                "ERROR: failed to allocate space for side set element "
                "list for file id %d",
                exoid);
-      ex_err(__func__, errmsg, EX_MEMFAIL);
+      ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -179,7 +171,7 @@ int ex_get_side_set_node_count(int exoid, ex_entity_id side_set_id, int *side_se
                "ERROR: failed to allocate space for side set side list "
                "for file id %d",
                exoid);
-      ex_err(__func__, errmsg, EX_MEMFAIL);
+      ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
       err_stat = EX_FATAL;
       goto cleanup;
     }
@@ -187,7 +179,7 @@ int ex_get_side_set_node_count(int exoid, ex_entity_id side_set_id, int *side_se
     if (ex_get_set(exoid, EX_SIDE_SET, side_set_id, side_set_elem_list, side_set_side_list) == -1) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get side set %" PRId64 " in file id %d",
                side_set_id, exoid);
-      ex_err(__func__, errmsg, EX_LASTERR);
+      ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
       err_stat = EX_FATAL;
       goto cleanup;
     }
@@ -198,7 +190,7 @@ int ex_get_side_set_node_count(int exoid, ex_entity_id side_set_id, int *side_se
                "ERROR: failed to allocate space for side set elem sort "
                "array for file id %d",
                exoid);
-      ex_err(__func__, errmsg, EX_MEMFAIL);
+      ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
       err_stat = EX_FATAL;
       goto cleanup;
     }
@@ -233,7 +225,7 @@ int ex_get_side_set_node_count(int exoid, ex_entity_id side_set_id, int *side_se
                "ERROR: failed to allocate space for element block ids "
                "for file id %d",
                exoid);
-      ex_err(__func__, errmsg, EX_MEMFAIL);
+      ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
       err_stat = EX_FATAL;
       goto cleanup;
     }
@@ -241,7 +233,7 @@ int ex_get_side_set_node_count(int exoid, ex_entity_id side_set_id, int *side_se
     if (ex_get_ids(exoid, EX_ELEM_BLOCK, elem_blk_ids) == -1) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get element block ids in file id %d",
                exoid);
-      ex_err(__func__, errmsg, EX_MSG);
+      ex_err_fn(exoid, __func__, errmsg, EX_MSG);
       err_stat = EX_FATAL;
       goto cleanup;
     }
@@ -253,7 +245,7 @@ int ex_get_side_set_node_count(int exoid, ex_entity_id side_set_id, int *side_se
              "ERROR: failed to allocate space for element block params "
              "for file id %d",
              exoid);
-    ex_err(__func__, errmsg, EX_MEMFAIL);
+    ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
     err_stat = EX_FATAL;
     goto cleanup;
   }
@@ -315,7 +307,7 @@ int ex_get_side_set_node_count(int exoid, ex_entity_id side_set_id, int *side_se
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: Invalid element number %" PRId64 " found in side set %" PRId64 " in file %d",
                elem, side_set_id, exoid);
-      ex_err(__func__, errmsg, EX_BADPARAM);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
       err_stat = EX_FATAL;
       goto cleanup;
     }
diff --git a/src/ex_get_side_set_node_list.c b/src/ex_get_side_set_node_list.c
index 4b82c70b8dc..9a36b61e415 100644
--- a/src/ex_get_side_set_node_list.c
+++ b/src/ex_get_side_set_node_list.c
@@ -53,14 +53,6 @@
 
 #include "exodusII.h"     // for ex_err, ex_block, etc
 #include "exodusII_int.h" // for elem_blk_parm, EX_FATAL, etc
-#include <assert.h>
-#include <ctype.h>    // for toupper
-#include <inttypes.h> // for PRId64
-#include <stddef.h>   // for size_t
-#include <stdio.h>
-#include <stdlib.h>    // for malloc, NULL, free
-#include <string.h>    // for strncmp, strlen
-#include <sys/types.h> // for int64_t
 
 /*!
  * This routine is designed to read the Exodus II V 2.0 side set side
@@ -68,13 +60,13 @@
  */
 static int check_valid_side(size_t side_num, size_t max_sides, char *topology, int exoid)
 {
-  char errmsg[MAX_ERR_LENGTH];
-  int  err_stat = EX_NOERR;
+  int err_stat = EX_NOERR;
 
   if (side_num + 1 < 1 || side_num + 1 > max_sides) {
+    char errmsg[MAX_ERR_LENGTH];
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: Invalid %s edge number %" ST_ZU " in file id %d",
              topology, side_num + 1, exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     err_stat = EX_FATAL;
   }
   return (err_stat);
@@ -260,13 +252,13 @@ int ex_get_side_set_node_list(int exoid, ex_entity_id side_set_id, void_int *sid
     ex_get_err(NULL, NULL, &status);
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get number of side sets in file id %d",
              exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
   if (num_side_sets == 0) {
     snprintf(errmsg, MAX_ERR_LENGTH, "Warning: no side sets defined in file id %d", exoid);
-    ex_err(__func__, errmsg, EX_WARN);
+    ex_err_fn(exoid, __func__, errmsg, EX_WARN);
     EX_FUNC_LEAVE(EX_WARN);
   }
 
@@ -278,14 +270,14 @@ int ex_get_side_set_node_list(int exoid, ex_entity_id side_set_id, void_int *sid
       if (status == EX_NULLENTITY) {
         snprintf(errmsg, MAX_ERR_LENGTH, "Warning: side set %" PRId64 " is NULL in file id %d",
                  side_set_id, exoid);
-        ex_err(__func__, errmsg, EX_NULLENTITY);
+        ex_err_fn(exoid, __func__, errmsg, EX_NULLENTITY);
         EX_FUNC_LEAVE(EX_WARN);
       }
 
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to locate side set %" PRId64 " in VAR_SS_IDS array in file id %d",
                side_set_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -294,7 +286,7 @@ int ex_get_side_set_node_list(int exoid, ex_entity_id side_set_id, void_int *sid
   if (num_elem_blks < 0) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get number of element blocks in file id %d",
              exoid);
-    ex_err(__func__, errmsg, EX_LASTERR);
+    ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -302,7 +294,7 @@ int ex_get_side_set_node_list(int exoid, ex_entity_id side_set_id, void_int *sid
   if (tot_num_elem < 0) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get total number of elements in file id %d",
              exoid);
-    ex_err(__func__, errmsg, EX_LASTERR);
+    ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -311,7 +303,7 @@ int ex_get_side_set_node_list(int exoid, ex_entity_id side_set_id, void_int *sid
   ndim = ex_inquire_int(exoid, EX_INQ_DIM);
   if (ndim < 0) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get dimensionality in file id %d", exoid);
-    ex_err(__func__, errmsg, EX_LASTERR);
+    ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -340,7 +332,7 @@ int ex_get_side_set_node_list(int exoid, ex_entity_id side_set_id, void_int *sid
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to get number of elements in side set %" PRId64 " in file id %d",
              side_set_id, exoid);
-    ex_err(__func__, errmsg, EX_LASTERR);
+    ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -350,7 +342,7 @@ int ex_get_side_set_node_list(int exoid, ex_entity_id side_set_id, void_int *sid
              "ERROR: failed to allocate space for side set element list "
              "for file id %d",
              exoid);
-    ex_err(__func__, errmsg, EX_MEMFAIL);
+    ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -358,7 +350,7 @@ int ex_get_side_set_node_list(int exoid, ex_entity_id side_set_id, void_int *sid
   if (!(side_set_side_list = malloc(tot_num_ss_elem * int_size))) {
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to allocate space for side set side list for file id %d", exoid);
-    ex_err(__func__, errmsg, EX_MEMFAIL);
+    ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
     err_stat = EX_FATAL;
     goto cleanup;
   }
@@ -366,7 +358,7 @@ int ex_get_side_set_node_list(int exoid, ex_entity_id side_set_id, void_int *sid
   if (ex_get_set(exoid, EX_SIDE_SET, side_set_id, side_set_elem_list, side_set_side_list) == -1) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get side set %" PRId64 " in file id %d",
              side_set_id, exoid);
-    ex_err(__func__, errmsg, EX_LASTERR);
+    ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
     err_stat = EX_FATAL;
     goto cleanup;
   }
@@ -377,7 +369,7 @@ int ex_get_side_set_node_list(int exoid, ex_entity_id side_set_id, void_int *sid
              "ERROR: failed to allocate space for side set elem sort "
              "array for file id %d",
              exoid);
-    ex_err(__func__, errmsg, EX_MEMFAIL);
+    ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
     err_stat = EX_FATAL;
     goto cleanup;
   }
@@ -404,14 +396,14 @@ int ex_get_side_set_node_list(int exoid, ex_entity_id side_set_id, void_int *sid
   if (!(elem_blk_ids = malloc(num_elem_blks * ids_size))) {
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to allocate space for element block ids for file id %d", exoid);
-    ex_err(__func__, errmsg, EX_MEMFAIL);
+    ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
     err_stat = EX_FATAL;
     goto cleanup;
   }
 
   if (ex_get_ids(exoid, EX_ELEM_BLOCK, elem_blk_ids) == -1) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get element block ids in file id %d", exoid);
-    ex_err(__func__, errmsg, EX_MSG);
+    ex_err_fn(exoid, __func__, errmsg, EX_MSG);
     err_stat = EX_FATAL;
     goto cleanup;
   }
@@ -422,7 +414,7 @@ int ex_get_side_set_node_list(int exoid, ex_entity_id side_set_id, void_int *sid
              "ERROR: failed to allocate space for element block params "
              "for file id %d",
              exoid);
-    ex_err(__func__, errmsg, EX_MEMFAIL);
+    ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
     err_stat = EX_FATAL;
     goto cleanup;
   }
@@ -452,7 +444,7 @@ int ex_get_side_set_node_list(int exoid, ex_entity_id side_set_id, void_int *sid
              "ERROR: failed to allocate space for side set elem parms "
              "index for file id %d",
              exoid);
-    ex_err(__func__, errmsg, EX_MEMFAIL);
+    ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
     err_stat = EX_FATAL;
     goto cleanup;
   }
@@ -463,7 +455,7 @@ int ex_get_side_set_node_list(int exoid, ex_entity_id side_set_id, void_int *sid
              "ERROR: failed to allocate space for side set elem to node "
              "index for file id %d",
              exoid);
-    ex_err(__func__, errmsg, EX_MEMFAIL);
+    ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
 
     err_stat = EX_FATAL;
     goto cleanup;
@@ -504,7 +496,7 @@ int ex_get_side_set_node_list(int exoid, ex_entity_id side_set_id, void_int *sid
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: Invalid element number %" PRId64 " found in side set %" PRId64 " in file %d",
                elem, side_set_id, exoid);
-      ex_err(__func__, errmsg, EX_BADPARAM);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
       err_stat = EX_FATAL;
       goto cleanup;
     }
@@ -522,7 +514,7 @@ int ex_get_side_set_node_list(int exoid, ex_entity_id side_set_id, void_int *sid
                ") does not match the side set node list length (%" ST_ZU
                "). These should match and this may indicate a corrupt database in file %d",
                side_set_id, num_df, node_ctr, exoid);
-      ex_err(__func__, errmsg, EX_MSG);
+      ex_err_fn(exoid, __func__, errmsg, EX_MSG);
       err_stat = EX_WARN;
     }
   }
@@ -580,7 +572,7 @@ int ex_get_side_set_node_list(int exoid, ex_entity_id side_set_id, void_int *sid
                  "ERROR: failed to allocate space for connectivity "
                  "array for file id %d",
                  exoid);
-        ex_err(__func__, errmsg, EX_MEMFAIL);
+        ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
         err_stat = EX_FATAL;
         goto cleanup;
       }
@@ -592,7 +584,7 @@ int ex_get_side_set_node_list(int exoid, ex_entity_id side_set_id, void_int *sid
                  "ERROR: failed to allocate space for connectivity "
                  "array for file id %d",
                  exoid);
-        ex_err(__func__, errmsg, EX_LASTERR);
+        ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
         err_stat = EX_FATAL;
         goto cleanup;
       }
@@ -602,7 +594,7 @@ int ex_get_side_set_node_list(int exoid, ex_entity_id side_set_id, void_int *sid
     if (connect == NULL) {
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: internal error -- connect pointer is NULL for file id %d", exoid);
-      ex_err(__func__, errmsg, EX_INTERNAL);
+      ex_err_fn(exoid, __func__, errmsg, EX_INTERNAL);
       err_stat = EX_FATAL;
       goto cleanup;
     }
@@ -632,7 +624,11 @@ 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);
       break;
     }
-    case EX_EL_TRUSS:
+    case EX_EL_TRUSS: { /* Sideset for truss is single node at either end of trus */
+      get_nodes(exoid, side_set_node_list, node_pos, connect, connect_offset + side_num);
+      break;
+    }
+
     case EX_EL_BEAM: { /* Note: no side-node lookup table is used for this
                           simple case */
       for (i = 0; i < num_nodes_per_elem; i++) {
@@ -707,7 +703,7 @@ int ex_get_side_set_node_list(int exoid, ex_entity_id side_set_id, void_int *sid
             snprintf(errmsg, MAX_ERR_LENGTH,
                      "ERROR: %d is an unsupported number of nodes for the triangle element type",
                      (int)num_nodes_per_elem);
-            ex_err(__func__, errmsg, EX_BADPARAM);
+            ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
             err_stat = EX_FATAL;
             goto cleanup;
           }
@@ -1049,14 +1045,12 @@ int ex_get_side_set_node_list(int exoid, ex_entity_id side_set_id, void_int *sid
                   connect_offset + hex16_table[side_num][4] - 1);
         get_nodes(exoid, side_set_node_list, node_pos + 3, connect,
                   connect_offset + hex16_table[side_num][5] - 1);
-        if (side_num == 5 || side_num == 6) {
+        if (side_num + 1 == 5 || side_num + 1 == 6) {
           get_nodes(exoid, side_set_node_list, node_pos++, connect,
                     connect_offset + hex16_table[side_num][6] - 1);
           get_nodes(exoid, side_set_node_list, node_pos++, connect,
                     connect_offset + hex16_table[side_num][7] - 1);
         }
-        else {
-        }
       }
       else {
         get_nodes(exoid, side_set_node_list, node_pos + 0, connect,
@@ -1083,13 +1077,13 @@ 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 + 8, connect,
                     connect_offset + hex_table[side_num][8] - 1);
         }
-        break;
       }
+      break;
     }
     default: {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: %s is an unsupported element type",
                elem_blk_parms[parm_ndx].elem_type);
-      ex_err(__func__, errmsg, EX_BADPARAM);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
       err_stat = EX_FATAL;
       goto cleanup;
     }
diff --git a/src/ex_get_side_set_node_list_len.c b/src/ex_get_side_set_node_list_len.c
index f04ace5e4b0..75dc6c1aec1 100644
--- a/src/ex_get_side_set_node_list_len.c
+++ b/src/ex_get_side_set_node_list_len.c
@@ -51,14 +51,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for elem_blk_parm, EX_FATAL, etc
-#include "vtk_netcdf.h"       // for NC_NOERR
-#include <ctype.h>        // for toupper
-#include <inttypes.h>     // for PRId64
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <stdlib.h>    // for malloc, NULL, free
-#include <string.h>    // for strncmp, strlen
-#include <sys/types.h> // for int64_t
 
 /*!
  * This routine is designed to read the Exodus II V 2.0 side set side
@@ -109,7 +101,7 @@ int ex_get_side_set_node_list_len(int exoid, ex_entity_id side_set_id,
   ndim = ex_inquire_int(exoid, EX_INQ_DIM);
   if (ndim < 0) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get dimensionality in file id %d", exoid);
-    ex_err(__func__, errmsg, EX_LASTERR);
+    ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -117,7 +109,7 @@ int ex_get_side_set_node_list_len(int exoid, ex_entity_id side_set_id,
   if (tot_num_elem < 0) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get total number of elements in file id %d",
              exoid);
-    ex_err(__func__, errmsg, EX_LASTERR);
+    ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -125,7 +117,7 @@ int ex_get_side_set_node_list_len(int exoid, ex_entity_id side_set_id,
   if (num_elem_blks < 0) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get number of element blocks in file id %d",
              exoid);
-    ex_err(__func__, errmsg, EX_LASTERR);
+    ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -133,13 +125,13 @@ int ex_get_side_set_node_list_len(int exoid, ex_entity_id side_set_id,
   if (num_side_sets < 0) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get number of side sets in file id %d",
              exoid);
-    ex_err(__func__, errmsg, EX_LASTERR);
+    ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
   if (num_side_sets == 0) {
     snprintf(errmsg, MAX_ERR_LENGTH, "Warning: no side sets defined in file id %d", exoid);
-    ex_err(__func__, errmsg, EX_WARN);
+    ex_err_fn(exoid, __func__, errmsg, EX_WARN);
     EX_FUNC_LEAVE(EX_WARN);
   }
 
@@ -159,7 +151,7 @@ int ex_get_side_set_node_list_len(int exoid, ex_entity_id side_set_id,
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to get number of elements in side set %" PRId64 " in file id %d",
              side_set_id, exoid);
-    ex_err(__func__, errmsg, EX_LASTERR);
+    ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -178,7 +170,7 @@ int ex_get_side_set_node_list_len(int exoid, ex_entity_id side_set_id,
                "ERROR: failed to allocate space for side set element "
                "list for file id %d",
                exoid);
-      ex_err(__func__, errmsg, EX_MEMFAIL);
+      ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -188,7 +180,7 @@ int ex_get_side_set_node_list_len(int exoid, ex_entity_id side_set_id,
                "ERROR: failed to allocate space for side set side list "
                "for file id %d",
                exoid);
-      ex_err(__func__, errmsg, EX_MEMFAIL);
+      ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
       err_stat = EX_FATAL;
       goto cleanup;
     }
@@ -197,7 +189,7 @@ int ex_get_side_set_node_list_len(int exoid, ex_entity_id side_set_id,
         NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get side set %" PRId64 " in file id %d",
                side_set_id, exoid);
-      ex_err(__func__, errmsg, EX_LASTERR);
+      ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
       err_stat = EX_FATAL;
       goto cleanup;
     }
@@ -215,7 +207,7 @@ int ex_get_side_set_node_list_len(int exoid, ex_entity_id side_set_id,
                "ERROR: failed to allocate space for side set elem sort "
                "array for file id %d",
                exoid);
-      ex_err(__func__, errmsg, EX_MEMFAIL);
+      ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
       err_stat = EX_FATAL;
       goto cleanup;
     }
@@ -247,7 +239,7 @@ int ex_get_side_set_node_list_len(int exoid, ex_entity_id side_set_id,
                "ERROR: failed to allocate space for element block ids "
                "for file id %d",
                exoid);
-      ex_err(__func__, errmsg, EX_MEMFAIL);
+      ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
       err_stat = EX_FATAL;
       goto cleanup;
     }
@@ -255,7 +247,7 @@ int ex_get_side_set_node_list_len(int exoid, ex_entity_id side_set_id,
 
   if (ex_get_ids(exoid, EX_ELEM_BLOCK, elem_blk_ids)) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get element block ids in file id %d", exoid);
-    ex_err(__func__, errmsg, EX_MSG);
+    ex_err_fn(exoid, __func__, errmsg, EX_MSG);
     err_stat = EX_FATAL;
     goto cleanup;
   }
@@ -266,7 +258,7 @@ int ex_get_side_set_node_list_len(int exoid, ex_entity_id side_set_id,
              "ERROR: failed to allocate space for element block params "
              "for file id %d",
              exoid);
-    ex_err(__func__, errmsg, EX_MEMFAIL);
+    ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
     err_stat = EX_FATAL;
     goto cleanup;
   }
@@ -326,7 +318,7 @@ int ex_get_side_set_node_list_len(int exoid, ex_entity_id side_set_id,
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: Invalid element number %" ST_ZU " found in side set %" PRId64 " in file %d",
                elem, side_set_id, exoid);
-      ex_err(__func__, errmsg, EX_BADPARAM);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
       err_stat = EX_FATAL;
       goto cleanup;
     }
@@ -347,7 +339,7 @@ int ex_get_side_set_node_list_len(int exoid, ex_entity_id side_set_id,
                ") does not match the side set node list length (%" ST_ZU
                "). These should match and this may indicate a corrupt database in file %d",
                side_set_id, num_df, list_len, exoid);
-      ex_err(__func__, errmsg, EX_MSG);
+      ex_err_fn(exoid, __func__, errmsg, EX_MSG);
       err_stat = EX_WARN;
       goto cleanup;
     }
diff --git a/src/ex_get_ss_param_global.c b/src/ex_get_ss_param_global.c
index 3785dbaf021..64cabe59b4c 100644
--- a/src/ex_get_ss_param_global.c
+++ b/src/ex_get_ss_param_global.c
@@ -53,8 +53,6 @@
 /*****************************************************************************/
 #include <exodusII.h>     // for ex_err, etc
 #include <exodusII_int.h> // for EX_FATAL, etc
-#include <vtk_netcdf.h>       // for NC_NOERR, nc_get_var_int, etc
-#include <stdio.h>
 
 int ex_get_ss_param_global(int exoid, void_int *global_ids, void_int *side_cnts, void_int *df_cnts)
 {
@@ -70,7 +68,7 @@ int ex_get_ss_param_global(int exoid, void_int *global_ids, void_int *side_cnts,
   if ((status = nc_inq_varid(exoid, VAR_SS_IDS_GLOBAL, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
              VAR_SS_IDS_GLOBAL, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -85,7 +83,7 @@ int ex_get_ss_param_global(int exoid, void_int *global_ids, void_int *side_cnts,
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get variable \"%s\" from file ID %d",
              VAR_SS_IDS_GLOBAL, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -95,7 +93,7 @@ int ex_get_ss_param_global(int exoid, void_int *global_ids, void_int *side_cnts,
     if ((status = nc_inq_varid(exoid, VAR_SS_SIDE_CNT_GLOBAL, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
                VAR_SS_SIDE_CNT_GLOBAL, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
 
       EX_FUNC_LEAVE(EX_FATAL);
     }
@@ -110,7 +108,7 @@ int ex_get_ss_param_global(int exoid, void_int *global_ids, void_int *side_cnts,
     if (status != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get variable \"%s\" from file ID %d",
                VAR_SS_SIDE_CNT_GLOBAL, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
 
       EX_FUNC_LEAVE(EX_FATAL);
     }
@@ -122,7 +120,7 @@ int ex_get_ss_param_global(int exoid, void_int *global_ids, void_int *side_cnts,
     if ((status = nc_inq_varid(exoid, VAR_SS_DF_CNT_GLOBAL, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
                VAR_SS_DF_CNT_GLOBAL, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
 
       EX_FUNC_LEAVE(EX_FATAL);
     }
@@ -137,7 +135,7 @@ int ex_get_ss_param_global(int exoid, void_int *global_ids, void_int *side_cnts,
     if (status != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get variable \"%s\" from file ID %d",
                VAR_SS_DF_CNT_GLOBAL, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
 
       EX_FUNC_LEAVE(EX_FATAL);
     }
diff --git a/src/ex_get_time.c b/src/ex_get_time.c
index 8e2b6de85f0..37e5ebc9587 100644
--- a/src/ex_get_time.c
+++ b/src/ex_get_time.c
@@ -35,9 +35,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, ex_comp_ws, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
 
 /*!
 
@@ -90,6 +87,31 @@ int ex_get_time(int exoid, int time_step, void *time_value)
   EX_FUNC_ENTER();
   ex_check_valid_file_id(exoid, __func__);
 
+  int num_time_steps = ex_inquire_int(exoid, EX_INQ_TIME);
+
+  if (num_time_steps == 0) {
+    snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: there are no time_steps on the file id %d", exoid);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
+    EX_FUNC_LEAVE(EX_FATAL);
+  }
+
+  if (time_step <= 0) {
+    snprintf(errmsg, MAX_ERR_LENGTH,
+             "ERROR: time_step must be greater than 0.  Entered value is %d in file id %d",
+             time_step, exoid);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
+    EX_FUNC_LEAVE(EX_FATAL);
+  }
+
+  if (time_step > num_time_steps) {
+    snprintf(errmsg, MAX_ERR_LENGTH,
+             "ERROR: beginning 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_fn(exoid, __func__, errmsg, EX_BADPARAM);
+    EX_FUNC_LEAVE(EX_FATAL);
+  }
+
   file  = ex_find_file_item(exoid);
   varid = file->time_varid;
   if (varid < 0) {
@@ -97,7 +119,7 @@ int ex_get_time(int exoid, int time_step, void *time_value)
     if ((status = nc_inq_varid(exoid, VAR_WHOLE_TIME, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate time variable in file id %d",
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
     file->time_varid = varid;
@@ -115,7 +137,7 @@ int ex_get_time(int exoid, int time_step, void *time_value)
 
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get time value in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
   EX_FUNC_LEAVE(EX_NOERR);
diff --git a/src/ex_get_truth_table.c b/src/ex_get_truth_table.c
index 7d8fe3812d2..28529ccbdc5 100644
--- a/src/ex_get_truth_table.c
+++ b/src/ex_get_truth_table.c
@@ -50,10 +50,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for ex_get_dimension, EX_FATAL, etc
-#include "vtk_netcdf.h"       // for nc_inq_varid, NC_NOERR, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <stdlib.h> // for NULL
 
 /*!
  * \ingroup ResultsData
@@ -143,7 +139,7 @@ int ex_get_truth_table(int exoid, ex_entity_type obj_type, int num_blk, int num_
   default:
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: Invalid variable type %d specified in file id %d",
              obj_type, exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_WARN);
   }
 
@@ -160,7 +156,7 @@ int ex_get_truth_table(int exoid, ex_entity_type obj_type, int num_blk, int num_
   if (num_entity != (size_t)num_blk) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: # of %s doesn't match those defined in file id %d",
              ex_name_of_object(obj_type), exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -168,7 +164,7 @@ int ex_get_truth_table(int exoid, ex_entity_type obj_type, int num_blk, int num_
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: # of %s variables doesn't match those defined in file id %d",
              ex_name_of_object(obj_type), exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -196,7 +192,7 @@ int ex_get_truth_table(int exoid, ex_entity_type obj_type, int num_blk, int num_
     if (status != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get %s truth table from file id %d",
                ex_name_of_object(obj_type), exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
diff --git a/src/ex_get_var.c b/src/ex_get_var.c
index 62aaca2a5b2..11baee3346a 100644
--- a/src/ex_get_var.c
+++ b/src/ex_get_var.c
@@ -35,11 +35,6 @@
 
 #include "exodusII.h"     // for ex_err, ex_name_of_object, etc
 #include "exodusII_int.h" // for ex_check_valid_file_id, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, etc
-#include <inttypes.h>     // for PRId64
-#include <stddef.h>       // for size_t
-#include <stdint.h>       // for int64_t
-#include <stdio.h>        // for snprintf
 
 /*!
 \ingroup ResultsData
@@ -130,13 +125,13 @@ int ex_get_var(int exoid, int time_step, ex_entity_type var_type, int var_index,
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "Warning: no %s variables for NULL block %" PRId64 " in file id %d",
                  ex_name_of_object(var_type), obj_id, exoid);
-        ex_err(__func__, errmsg, EX_NULLENTITY);
+        ex_err_fn(exoid, __func__, errmsg, EX_NULLENTITY);
         EX_FUNC_LEAVE(EX_WARN);
       }
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to locate %s id %" PRId64 " in id variable in file id %d",
                ex_name_of_object(var_type), obj_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -147,7 +142,7 @@ int ex_get_var(int exoid, int time_step, ex_entity_type var_type, int var_index,
                              &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate %s %" PRId64 " var %d in file id %d",
              ex_name_of_object(var_type), obj_id, var_index, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -169,7 +164,7 @@ int ex_get_var(int exoid, int time_step, ex_entity_type var_type, int var_index,
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to get %s %" PRId64 " variable %d in file id %d",
              ex_name_of_object(var_type), obj_id, var_index, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
   EX_FUNC_LEAVE(EX_NOERR);
diff --git a/src/ex_get_var_time.c b/src/ex_get_var_time.c
index bf81739024d..d92c8510a04 100644
--- a/src/ex_get_var_time.c
+++ b/src/ex_get_var_time.c
@@ -58,11 +58,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, ST_ZU, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_inq_varid, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <stdlib.h>    // for free, malloc
-#include <sys/types.h> // for int64_t
 
 /*!
   \ingroup ResultsData
@@ -132,7 +127,7 @@ int ex_get_var_time(int exoid, ex_entity_type var_type, int var_index, int64_t i
   default:
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: Invalid variable type (%d) specified for file id %d",
              var_type, exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -157,7 +152,7 @@ int ex_get_var_time(int exoid, ex_entity_type var_type, int var_index, int64_t i
   if ((status = nc_inq_varid(exoid, varobjids, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate %s ids in file id %d",
              ex_name_of_object(var_type), exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -166,7 +161,7 @@ int ex_get_var_time(int exoid, ex_entity_type var_type, int var_index, int64_t i
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to allocate memory for %s status array for file id %d",
              ex_name_of_object(var_type), exoid);
-    ex_err(__func__, errmsg, EX_MEMFAIL);
+    ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -179,7 +174,7 @@ int ex_get_var_time(int exoid, ex_entity_type var_type, int var_index, int64_t i
       free(stat_vals);
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get %s status array from file id %d",
                ex_name_of_object(var_type), exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -204,7 +199,7 @@ int ex_get_var_time(int exoid, ex_entity_type var_type, int var_index, int64_t i
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to locate number of entries in %" ST_ZU "th %s in file id %d", i,
                ex_name_of_object(var_type), exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       free(stat_vals);
       EX_FUNC_LEAVE(EX_FATAL);
     }
@@ -213,7 +208,7 @@ int ex_get_var_time(int exoid, ex_entity_type var_type, int var_index, int64_t i
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to get number of entries in %" ST_ZU "th %s in file id %d", i,
                ex_name_of_object(var_type), exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       free(stat_vals);
       EX_FUNC_LEAVE(EX_FATAL);
     }
@@ -228,7 +223,7 @@ int ex_get_var_time(int exoid, ex_entity_type var_type, int var_index, int64_t i
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to locate number of entries in %" ST_ZU "th %s in file id %d", i,
                  ex_name_of_object(var_type), exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         free(stat_vals);
         EX_FUNC_LEAVE(EX_FATAL);
       }
@@ -237,7 +232,7 @@ int ex_get_var_time(int exoid, ex_entity_type var_type, int var_index, int64_t i
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to get number of entries in %" ST_ZU "th %s in file id %d", i,
                  ex_name_of_object(var_type), exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         free(stat_vals);
         EX_FUNC_LEAVE(EX_FATAL);
       }
@@ -252,7 +247,7 @@ int ex_get_var_time(int exoid, ex_entity_type var_type, int var_index, int64_t i
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to locate variable %" ST_ZU " for %dth %s in file id %d", i, var_index,
              ex_name_of_object(var_type), exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     free(stat_vals);
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -262,12 +257,19 @@ int ex_get_var_time(int exoid, ex_entity_type var_type, int var_index, int64_t i
   /* Check that times are in range */
   {
     int num_time_steps = ex_inquire_int(exoid, EX_INQ_TIME);
+
+    if (num_time_steps == 0) {
+      snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: there are no time_steps on the file id %d", exoid);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
+      EX_FUNC_LEAVE(EX_FATAL);
+    }
+
     if (beg_time_step <= 0 || beg_time_step > num_time_steps) {
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: beginning time_step is out-of-range. Value = %d, "
                "valid range is 1 to %d in file id %d",
                beg_time_step, num_time_steps, exoid);
-      ex_err(__func__, errmsg, EX_BADPARAM);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -283,7 +285,7 @@ int ex_get_var_time(int exoid, ex_entity_type var_type, int var_index, int64_t i
                "ERROR: end time_step is out-of-range. Value = %d, valid "
                "range is %d to %d in file id %d",
                beg_time_step, end_time_step, num_time_steps, exoid);
-      ex_err(__func__, errmsg, EX_BADPARAM);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -307,7 +309,7 @@ int ex_get_var_time(int exoid, ex_entity_type var_type, int var_index, int64_t i
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get %s variable values in file id %d",
              ex_name_of_object(var_type), exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
   EX_FUNC_LEAVE(EX_NOERR);
diff --git a/src/ex_get_variable_name.c b/src/ex_get_variable_name.c
index dc0be2cfd8b..74225bd7177 100644
--- a/src/ex_get_variable_name.c
+++ b/src/ex_get_variable_name.c
@@ -52,8 +52,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_inq_varid
-#include <stdio.h>
 
 /*!
  * \ingroup ResultsData
@@ -87,14 +85,14 @@ int ex_get_variable_name(int exoid, ex_entity_type obj_type, int var_num, char *
   default:
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: Invalid variable type (%d) given for file id %d",
              obj_type, exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
   if ((status = nc_inq_varid(exoid, vname, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "Warning: no %s variable names stored in file id %d",
              ex_name_of_object(obj_type), exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_WARN);
   }
 
diff --git a/src/ex_get_variable_names.c b/src/ex_get_variable_names.c
index d5a9dd38d65..b6d07e72bfc 100644
--- a/src/ex_get_variable_names.c
+++ b/src/ex_get_variable_names.c
@@ -35,8 +35,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_WARN, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_inq_varid
-#include <stdio.h>
 
 /*!
 \ingroup ResultsData
@@ -116,7 +114,7 @@ int ex_get_variable_names(int exoid, ex_entity_type obj_type, int num_vars, char
   default:
     snprintf(errmsg, MAX_ERR_LENGTH, "Warning: invalid variable type %d requested from file id %d",
              obj_type, exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_WARN);
   }
 
@@ -124,7 +122,7 @@ int ex_get_variable_names(int exoid, ex_entity_type obj_type, int num_vars, char
   if ((status = nc_inq_varid(exoid, vvarname, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "Warning: no %s variables names stored in file id %d",
              ex_name_of_object(obj_type), exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_WARN);
   }
 
diff --git a/src/ex_get_variable_param.c b/src/ex_get_variable_param.c
index c4bc22980b2..59b90dce209 100644
--- a/src/ex_get_variable_param.c
+++ b/src/ex_get_variable_param.c
@@ -51,9 +51,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, EX_NOERR, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_inq_dimid, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
 
 /*!
 \ingroup ResultsData
@@ -127,7 +124,7 @@ int ex_get_variable_param(int exoid, ex_entity_type obj_type, int *num_vars)
   default:
     snprintf(errmsg, MAX_ERR_LENGTH, "Warning: invalid variable type %d requested from file id %d",
              obj_type, exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_WARN);
   }
 
@@ -139,14 +136,14 @@ int ex_get_variable_param(int exoid, ex_entity_type obj_type, int *num_vars)
 
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate %s variable names in file id %d",
              ex_name_of_object(obj_type), exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
   if ((status = nc_inq_dimlen(exoid, dimid, &dimlen)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get number of %s variables in file id %d",
              ex_name_of_object(obj_type), exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
   *num_vars = dimlen;
diff --git a/src/ex_inquire.c b/src/ex_inquire.c
index 71d9f68dae5..10cc747704a 100644
--- a/src/ex_inquire.c
+++ b/src/ex_inquire.c
@@ -33,9 +33,6 @@
  *
  */
 
-#include <stdlib.h>
-#include <string.h>
-
 #include "exodusII.h"
 #include "exodusII_int.h"
 
@@ -55,7 +52,7 @@ static int ex_get_dimension_value(int exoid, int64_t *var, int default_value,
     }
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to retrieve dimension %s for file id %d",
              dimension_name, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     return (EX_FATAL);
   }
   if ((status = nc_inq_dimlen(exoid, dimid, &idum)) != NC_NOERR) {
@@ -63,7 +60,7 @@ static int ex_get_dimension_value(int exoid, int64_t *var, int default_value,
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to retrieve value for dimension %s for file id %d", dimension_name,
              exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     return (EX_FATAL);
   }
   *var = idum;
@@ -88,7 +85,7 @@ static int ex_get_concat_set_len(int exoid, int64_t *set_length, const char *set
     if ((status = nc_inq_dimlen(exoid, dimid, &num_sets)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get number of %s sets in file id %d",
                set_name, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       return (EX_FATAL);
     }
 
@@ -98,7 +95,7 @@ static int ex_get_concat_set_len(int exoid, int64_t *set_length, const char *set
                "ERROR: failed to allocate memory for %s set status "
                "array for file id %d",
                set_name, exoid);
-      ex_err(__func__, errmsg, EX_MEMFAIL);
+      ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
       return (EX_FATAL);
     }
 
@@ -110,7 +107,7 @@ static int ex_get_concat_set_len(int exoid, int64_t *set_length, const char *set
         free(stat_vals);
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get %s set status array from file id %d",
                  set_name, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         return (EX_FATAL);
       }
     }
@@ -174,7 +171,7 @@ static int ex_inquire_internal(int exoid, int req_info, int64_t *ret_int, float
   }
   if (!ret_int) {
     snprintf(errmsg, MAX_ERR_LENGTH, "Warning: integer argument is NULL which is not allowed.");
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     return (EX_FATAL);
   }
 
@@ -186,7 +183,7 @@ static int ex_inquire_internal(int exoid, int req_info, int64_t *ret_int, float
     /* obsolete call */
     /*returns "r" for regular EXODUS file or "h" for history EXODUS file*/
     snprintf(errmsg, MAX_ERR_LENGTH, "Warning: file type inquire is obsolete");
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     return (EX_WARN);
 
   case EX_INQ_API_VERS:
@@ -195,7 +192,7 @@ static int ex_inquire_internal(int exoid, int req_info, int64_t *ret_int, float
       snprintf(errmsg, MAX_ERR_LENGTH,
                "Warning: float argument is NULL for EX_INQ_API_VERS "
                "which is not allowed.");
-      ex_err(__func__, errmsg, EX_BADPARAM);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
       return (EX_FATAL);
     }
 
@@ -205,7 +202,7 @@ static int ex_inquire_internal(int exoid, int req_info, int64_t *ret_int, float
           NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get EXODUS API version for file id %d",
                  rootid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         return (EX_FATAL);
       }
     }
@@ -218,14 +215,14 @@ static int ex_inquire_internal(int exoid, int req_info, int64_t *ret_int, float
       snprintf(errmsg, MAX_ERR_LENGTH,
                "Warning: float argument is NULL for EX_INQ_DB_VERS "
                "which is not allowed.");
-      ex_err(__func__, errmsg, EX_BADPARAM);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
       return (EX_FATAL);
     }
 
     if ((status = nc_get_att_float(rootid, NC_GLOBAL, ATT_VERSION, ret_float)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to get EXODUS database version for file id %d", rootid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       return (EX_FATAL);
     }
     break;
@@ -254,7 +251,7 @@ static int ex_inquire_internal(int exoid, int req_info, int64_t *ret_int, float
       if ((status = nc_inq_dimlen(rootid, dimid, &name_length)) != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get name string length in file id %d",
                  exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         return (EX_FATAL);
       }
 
@@ -298,7 +295,7 @@ static int ex_inquire_internal(int exoid, int req_info, int64_t *ret_int, float
 
     if (!file) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: unknown file id %d for ex_inquire_int().", rootid);
-      ex_err(__func__, errmsg, EX_BADFILEID);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADFILEID);
       *ret_int = 0;
     }
     else {
@@ -312,7 +309,7 @@ static int ex_inquire_internal(int exoid, int req_info, int64_t *ret_int, float
                "ERROR: Requested title, but character pointer was null "
                "for file id %d",
                rootid);
-      ex_err(__func__, errmsg, EX_BADPARAM);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
       return (EX_FATAL);
     }
     else {
@@ -322,11 +319,10 @@ static int ex_inquire_internal(int exoid, int req_info, int64_t *ret_int, float
         *ret_char = '\0';
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get database title for file id %d",
                  exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         return (EX_FATAL);
       }
-      strncpy(ret_char, tmp_title, MAX_LINE_LENGTH + 1);
-      ret_char[MAX_LINE_LENGTH] = '\0';
+      ex_copy_string(ret_char, tmp_title, MAX_LINE_LENGTH + 1);
     }
     break;
 
@@ -404,7 +400,7 @@ static int ex_inquire_internal(int exoid, int req_info, int64_t *ret_int, float
       if ((status = nc_inq_dimlen(exoid, dimid, &num_sets)) != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get number of node sets in file id %d",
                  exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         return (EX_FATAL);
       }
 
@@ -419,7 +415,7 @@ static int ex_inquire_internal(int exoid, int req_info, int64_t *ret_int, float
                      "ERROR: failed to locate number of dist fact for %" ST_ZU
                      "'th node set in file id %d",
                      i, exoid);
-            ex_err(__func__, errmsg, status);
+            ex_err_fn(exoid, __func__, errmsg, status);
             return (EX_FATAL);
           }
         }
@@ -430,7 +426,7 @@ static int ex_inquire_internal(int exoid, int req_info, int64_t *ret_int, float
                      "ERROR: failed to locate number of nodes in %" ST_ZU
                      "'th node set in file id %d",
                      i, exoid);
-            ex_err(__func__, errmsg, status);
+            ex_err_fn(exoid, __func__, errmsg, status);
             return (EX_FATAL);
           }
           if ((status = nc_inq_dimlen(exoid, dimid, &idum)) != NC_NOERR) {
@@ -438,7 +434,7 @@ static int ex_inquire_internal(int exoid, int req_info, int64_t *ret_int, float
             snprintf(errmsg, MAX_ERR_LENGTH,
                      "ERROR: failed to get number of nodes in %" ST_ZU "'th node set in file id %d",
                      i, exoid);
-            ex_err(__func__, errmsg, status);
+            ex_err_fn(exoid, __func__, errmsg, status);
             return (EX_FATAL);
           }
         }
@@ -468,7 +464,7 @@ static int ex_inquire_internal(int exoid, int req_info, int64_t *ret_int, float
       if ((status = nc_inq_dimlen(exoid, dimid, &num_sets)) != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get number of side sets in file id %d",
                  exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         return (EX_FATAL);
       }
 
@@ -476,13 +472,13 @@ static int ex_inquire_internal(int exoid, int req_info, int64_t *ret_int, float
                                                             needed, but should be OK */
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to allocate memory for side set ids for file id %d", exoid);
-        ex_err(__func__, errmsg, EX_MEMFAIL);
+        ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
         return (EX_FATAL);
       }
 
       if (ex_get_ids(exoid, EX_SIDE_SET, ids) == EX_FATAL) {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get side set ids in file id %d", exoid);
-        ex_err(__func__, errmsg, EX_LASTERR);
+        ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
         free(ids);
         return (EX_FATAL);
       }
@@ -494,7 +490,7 @@ static int ex_inquire_internal(int exoid, int req_info, int64_t *ret_int, float
                  "ERROR: failed to allocate memory for side set status "
                  "array for file id %d",
                  exoid);
-        ex_err(__func__, errmsg, EX_MEMFAIL);
+        ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
         return (EX_FATAL);
       }
       /* get variable id of status array */
@@ -507,7 +503,7 @@ static int ex_inquire_internal(int exoid, int req_info, int64_t *ret_int, float
           free(stat_vals);
           snprintf(errmsg, MAX_ERR_LENGTH,
                    "ERROR: failed to get element block status array from file id %d", exoid);
-          ex_err(__func__, errmsg, status);
+          ex_err_fn(exoid, __func__, errmsg, status);
           return (EX_FATAL);
         }
       }
@@ -546,7 +542,7 @@ static int ex_inquire_internal(int exoid, int req_info, int64_t *ret_int, float
           *ret_int = 0;
           snprintf(errmsg, MAX_ERR_LENGTH,
                    "ERROR: failed to side set %" PRId64 " node length in file id %d", id, exoid);
-          ex_err(__func__, errmsg, status);
+          ex_err_fn(exoid, __func__, errmsg, status);
           free(stat_vals);
           free(ids);
           return (EX_FATAL);
@@ -585,7 +581,7 @@ static int ex_inquire_internal(int exoid, int req_info, int64_t *ret_int, float
       if ((status = nc_inq_dimlen(exoid, dimid, &num_sets)) != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get number of side sets in file id %d",
                  exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         return (EX_FATAL);
       }
 
@@ -600,7 +596,7 @@ static int ex_inquire_internal(int exoid, int req_info, int64_t *ret_int, float
                      "ERROR: failed to locate number of dist fact for %" ST_ZU
                      "'th side set in file id %d",
                      i, exoid);
-            ex_err(__func__, errmsg, status);
+            ex_err_fn(exoid, __func__, errmsg, status);
             return (EX_FATAL);
           }
         }
@@ -611,7 +607,7 @@ static int ex_inquire_internal(int exoid, int req_info, int64_t *ret_int, float
                      "ERROR: failed to get number of dist factors in %" ST_ZU
                      "'th side set in file id %d",
                      i, exoid);
-            ex_err(__func__, errmsg, status);
+            ex_err_fn(exoid, __func__, errmsg, status);
             return (EX_FATAL);
           }
         }
@@ -869,7 +865,7 @@ static int ex_inquire_internal(int exoid, int req_info, int64_t *ret_int, float
                "ERROR: Requested group name, but character pointer was "
                "null for file id %d",
                exoid);
-      ex_err(__func__, errmsg, EX_BADPARAM);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
       return (EX_FATAL);
     }
 #if NC_HAS_HDF5
@@ -901,7 +897,7 @@ static int ex_inquire_internal(int exoid, int req_info, int64_t *ret_int, float
                "ERROR: Requested group name, but character pointer was "
                "null for file id %d",
                exoid);
-      ex_err(__func__, errmsg, EX_BADPARAM);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
       return (EX_FATAL);
     }
 #if NC_HAS_HDF5
@@ -923,7 +919,7 @@ static int ex_inquire_internal(int exoid, int req_info, int64_t *ret_int, float
   default:
     *ret_int = 0;
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: invalid inquiry %d", req_info);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     return (EX_FATAL);
   }
   return (EX_NOERR);
diff --git a/src/ex_int_get_block_param.c b/src/ex_int_get_block_param.c
index bc75bacb77b..50c0016668b 100644
--- a/src/ex_int_get_block_param.c
+++ b/src/ex_int_get_block_param.c
@@ -33,23 +33,17 @@
  *
  */
 
-#include <ctype.h>    // for toupper
-#include <inttypes.h> // for PRId64
-#include <stddef.h>   // for size_t
-#include <stdio.h>
-#include <string.h>    // for strncmp, strlen
-#include <sys/types.h> // for int64_t
-
 #include "exodusII.h"     // for ex_err, ex_block, etc
 #include "exodusII_int.h" // for elem_blk_parm, EX_FATAL, etc
+#include <ctype.h>
 
 /* Generic error message for element type/node count mapping...*/
-static int el_node_count_error(struct elem_blk_parm elem_blk_parms)
+static int el_node_count_error(int exoid, struct elem_blk_parm elem_blk_parms)
 {
   char errmsg[MAX_ERR_LENGTH];
   snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: An element of type '%s' with %d nodes is not valid.",
            elem_blk_parms.elem_type, elem_blk_parms.num_nodes_per_elem);
-  ex_err(__func__, errmsg, EX_MSG);
+  ex_err_fn(exoid, __func__, errmsg, EX_MSG);
   return (EX_FATAL);
 }
 
@@ -72,7 +66,7 @@ int ex_int_get_block_param(int exoid, ex_entity_id id, int ndim,
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to get element block %" PRId64 " parameters in file id %d", block.id,
              exoid);
-    ex_err(__func__, errmsg, EX_MSG);
+    ex_err_fn(exoid, __func__, errmsg, EX_MSG);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -118,7 +112,7 @@ int ex_int_get_block_param(int exoid, ex_entity_id id, int ndim,
       elem_blk_parm->num_nodes_per_side[3] = 3;
     }
     else {
-      EX_FUNC_LEAVE(el_node_count_error(*elem_blk_parm));
+      EX_FUNC_LEAVE(el_node_count_error(exoid, *elem_blk_parm));
     }
   }
   else if (strncmp(elem_blk_parm->elem_type, "TRIANGLE", 3) == 0) {
@@ -155,7 +149,7 @@ int ex_int_get_block_param(int exoid, ex_entity_id id, int ndim,
         elem_blk_parm->num_nodes_per_side[4] = 3;
       }
       else {
-        EX_FUNC_LEAVE(el_node_count_error(*elem_blk_parm));
+        EX_FUNC_LEAVE(el_node_count_error(exoid, *elem_blk_parm));
       }
     }
   }
@@ -186,7 +180,7 @@ int ex_int_get_block_param(int exoid, ex_entity_id id, int ndim,
       elem_blk_parm->num_nodes_per_side[5] = 3;
     }
     else {
-      EX_FUNC_LEAVE(el_node_count_error(*elem_blk_parm));
+      EX_FUNC_LEAVE(el_node_count_error(exoid, *elem_blk_parm));
     }
   }
   else if (strncmp(elem_blk_parm->elem_type, "HEX", 3) == 0) {
@@ -242,7 +236,7 @@ int ex_int_get_block_param(int exoid, ex_entity_id id, int ndim,
       elem_blk_parm->num_nodes_per_side[5] = 9;
     }
     else {
-      EX_FUNC_LEAVE(el_node_count_error(*elem_blk_parm));
+      EX_FUNC_LEAVE(el_node_count_error(exoid, *elem_blk_parm));
     }
   }
   else if (strncmp(elem_blk_parm->elem_type, "TETRA", 3) == 0) {
@@ -274,7 +268,7 @@ int ex_int_get_block_param(int exoid, ex_entity_id id, int ndim,
       elem_blk_parm->num_nodes_per_side[3] = 7;
     }
     else {
-      EX_FUNC_LEAVE(el_node_count_error(*elem_blk_parm));
+      EX_FUNC_LEAVE(el_node_count_error(exoid, *elem_blk_parm));
     }
   }
   else if (strncmp(elem_blk_parm->elem_type, "WEDGE", 3) == 0) {
@@ -316,7 +310,7 @@ int ex_int_get_block_param(int exoid, ex_entity_id id, int ndim,
       elem_blk_parm->num_nodes_per_side[4] = 7;
     }
     else {
-      EX_FUNC_LEAVE(el_node_count_error(*elem_blk_parm));
+      EX_FUNC_LEAVE(el_node_count_error(exoid, *elem_blk_parm));
     }
   }
   else if (strncmp(elem_blk_parm->elem_type, "PYRAMID", 3) == 0) {
@@ -351,7 +345,7 @@ int ex_int_get_block_param(int exoid, ex_entity_id id, int ndim,
       elem_blk_parm->num_nodes_per_side[4] = 9;
     }
     else {
-      EX_FUNC_LEAVE(el_node_count_error(*elem_blk_parm));
+      EX_FUNC_LEAVE(el_node_count_error(exoid, *elem_blk_parm));
     }
   }
   else if (strncmp(elem_blk_parm->elem_type, "BEAM", 3) == 0) {
@@ -367,7 +361,7 @@ int ex_int_get_block_param(int exoid, ex_entity_id id, int ndim,
       elem_blk_parm->num_nodes_per_side[1] = 3;
     }
     else {
-      EX_FUNC_LEAVE(el_node_count_error(*elem_blk_parm));
+      EX_FUNC_LEAVE(el_node_count_error(exoid, *elem_blk_parm));
     }
   }
   else if ((strncmp(elem_blk_parm->elem_type, "TRUSS", 3) == 0) ||
@@ -376,16 +370,12 @@ int ex_int_get_block_param(int exoid, ex_entity_id id, int ndim,
     elem_blk_parm->elem_type_val = EX_EL_TRUSS;
     elem_blk_parm->num_sides     = 2;
 
-    if (elem_blk_parm->num_nodes_per_elem == 2) {
-      elem_blk_parm->num_nodes_per_side[0] = 2;
-      elem_blk_parm->num_nodes_per_side[1] = 2;
-    }
-    else if (elem_blk_parm->num_nodes_per_elem == 3) {
-      elem_blk_parm->num_nodes_per_side[0] = 3;
-      elem_blk_parm->num_nodes_per_side[1] = 3;
+    if (elem_blk_parm->num_nodes_per_elem == 2 || elem_blk_parm->num_nodes_per_elem == 3) {
+      elem_blk_parm->num_nodes_per_side[0] = 1;
+      elem_blk_parm->num_nodes_per_side[1] = 1;
     }
     else {
-      EX_FUNC_LEAVE(el_node_count_error(*elem_blk_parm));
+      EX_FUNC_LEAVE(el_node_count_error(exoid, *elem_blk_parm));
     }
   }
   /* Used for an empty block in a parallel decomposition */
diff --git a/src/ex_ne_util.c b/src/ex_ne_util.c
index 8ee74fb3e02..36bfdeaf48d 100644
--- a/src/ex_ne_util.c
+++ b/src/ex_ne_util.c
@@ -54,30 +54,10 @@
 
 #include <exodusII.h>     // for ex_err, etc
 #include <exodusII_int.h> // for EX_FATAL, EX_NOERR, etc
-#include <vtk_netcdf.h>       // for NC_NOERR, nc_inq_varid, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <stdlib.h>    // for malloc
-#include <string.h>    // for strcpy, strlen
-#include <sys/types.h> // for int64_t
 
 /* Global variables */
 char *ne_ret_string;
 
-int ex_leavedef(int exoid, const char *call_rout)
-{
-  char errmsg[MAX_ERR_LENGTH];
-  int  status;
-
-  if ((status = nc_enddef(exoid)) != NC_NOERR) {
-    snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to end define mode for file id %d", exoid);
-    ex_err(call_rout, errmsg, status);
-
-    return (EX_FATAL);
-  }
-  return (EX_NOERR);
-}
-
 /*****************************************************************************/
 /*****************************************************************************/
 /*****************************************************************************/
@@ -98,7 +78,7 @@ int ne_id_lkup(int exoid, const char *ne_var_name, int64_t *idx, ex_entity_id ne
   if ((status = nc_inq_varid(exoid, ne_var_name, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
              ne_var_name, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     return (EX_FATAL);
   }
 
@@ -111,7 +91,7 @@ int ne_id_lkup(int exoid, const char *ne_var_name, int64_t *idx, ex_entity_id ne
                "ERROR: failed to find dimension ID for variable \"%s\" "
                "in file ID %d",
                ne_var_name, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       return (EX_FATAL);
     }
 
@@ -120,7 +100,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 dimension for variable \"%s\" in file ID %d", ne_var_name,
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       return (EX_FATAL);
     }
 
@@ -138,7 +118,7 @@ int ne_id_lkup(int exoid, const char *ne_var_name, int64_t *idx, ex_entity_id ne
     if (status != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable \"%s\" in file ID %d",
                ne_var_name, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       return (EX_FATAL);
     }
 
@@ -178,16 +158,16 @@ int ex_get_file_type(int exoid, char *ftype)
   if ((status = nc_get_var1_int(exoid, varid, NULL, &lftype)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get variable \"%s\" from file ID %d",
              VAR_FILE_TYPE, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
   /* Set the appropriate character */
   if (lftype == 0) {
-    strcpy(ftype, "p");
+    ex_copy_string(ftype, "p", 2);
   }
   else if (lftype == 1) {
-    strcpy(ftype, "s");
+    ex_copy_string(ftype, "s", 2);
   }
 
   EX_FUNC_LEAVE(EX_NOERR);
@@ -219,7 +199,7 @@ int ex_put_nemesis_version(int exoid)
                                    &file_ver)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to output nemesis file version in file ID %d",
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -228,7 +208,7 @@ int ex_put_nemesis_version(int exoid)
                                    &api_ver)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to output nemesis api version in file ID %d",
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -256,18 +236,19 @@ int ne_check_file_version(int exoid)
     snprintf(errmsg, MAX_ERR_LENGTH,
             "ERROR: failed to get the nemesis file version from file ID %d",
             exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
   if (fabs(NEMESIS_FILE_VERSION-file_ver) > 0.001) {
     snprintf(errmsg, MAX_ERR_LENGTH,
             "ERROR: Nemesis version mismatch in file ID %d!\n", exoid);
-    ex_err(__func__, errmsg, EX_MSG);
+    ex_err_fn(exoid, __func__, errmsg, EX_MSG);
     EX_FUNC_LEAVE(EX_FATAL);
   }
   EX_FUNC_LEAVE(EX_NOERR);
 #else
+  EX_UNUSED(exoid);
   return EX_NOERR;
 #endif
 }
@@ -321,7 +302,7 @@ int ex_get_idx(int exoid, const char *ne_var_name, int64_t *my_index, int pos)
     if (status != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable \"%s\" in file ID %d",
                ne_var_name, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(-1);
     }
 
diff --git a/src/ex_open.c b/src/ex_open.c
index e5f45d3d6f7..8a04394b372 100644
--- a/src/ex_open.c
+++ b/src/ex_open.c
@@ -54,8 +54,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
 /*!
 
 \note The ex_open_int() is an internal function called by
@@ -136,7 +134,7 @@ static int warning_output = 0;
 int ex_open_int(const char *path, int mode, int *comp_ws, int *io_ws, float *version,
                 int run_version)
 {
-  int     exoid;
+  int     exoid = -1;
   int     status, stat_att, stat_dim;
   nc_type att_type = NC_NAT;
   size_t  att_len  = 0;
@@ -207,12 +205,13 @@ int ex_open_int(const char *path, int mode, int *comp_ws, int *io_ws, float *ver
 
       if (type == 5) {
 #if NC_HAS_HDF5
-        fprintf(stderr,
-                "EXODUS: ERROR: Attempting to open the netcdf-4 "
-                "file:\n\t'%s'\n\t failed. The netcdf library supports "
-                "netcdf-4 so there must be a filesystem or some other "
-                "issue \n",
-                path);
+        snprintf(errmsg, MAX_ERR_LENGTH,
+                 "EXODUS: ERROR: Attempting to open the netcdf-4 "
+                 "file:\n\t'%s'\n\tfailed. The netcdf library supports "
+                 "netcdf-4 so there must be a filesystem or some other "
+                 "issue.\n",
+                 path);
+        ex_err(__func__, errmsg, status);
 #else
         /* This is an hdf5 (netcdf4) file. If NC_HAS_HDF5 is not defined,
            then we either don't have hdf5 support in this netcdf version,
@@ -222,23 +221,25 @@ int ex_open_int(const char *path, int mode, int *comp_ws, int *io_ws, float *ver
            assume that the netcdf doesn't have netcdf4 capabilities
            enabled.  Tell the user...
         */
-        fprintf(stderr,
-                "EXODUS: ERROR: Attempting to open the netcdf-4 "
-                "file:\n\t'%s'\n\t. Either the netcdf library does not "
-                "support netcdf-4 or there is a filesystem or some "
-                "other issue \n",
-                path);
+        snprintf(errmsg, MAX_ERR_LENGTH,
+                 "EXODUS: ERROR: Attempting to open the netcdf-4 "
+                 "file:\n\t'%s'.\n\tEither the netcdf library does not "
+                 "support netcdf-4 or there is a filesystem or some "
+                 "other issue.\n",
+                 path);
+        ex_err(__func__, errmsg, status);
 
 #endif
       }
       else if (type == 4) {
-#if defined(NC_64BIT_DATA)
-        fprintf(stderr,
-                "EXODUS: ERROR: Attempting to open the CDF5 "
-                "file:\n\t'%s'\n\t failed. The netcdf library supports "
-                "CDF5-type files so there must be a filesystem or some other "
-                "issue \n",
-                path);
+#if NC_HAS_CDF5
+        snprintf(errmsg, MAX_ERR_LENGTH,
+                 "EXODUS: ERROR: Attempting to open the CDF5 "
+                 "file:\n\t'%s'\n\tfailed. The netcdf library supports "
+                 "CDF5-type files so there must be a filesystem or some other "
+                 "issue \n",
+                 path);
+        ex_err(__func__, errmsg, status);
 #else
         /* This is an cdf5 (64BIT_DATA) file. If NC_64BIT_DATA is not defined,
            then we either don't have cdf5 support in this netcdf version,
@@ -248,12 +249,13 @@ int ex_open_int(const char *path, int mode, int *comp_ws, int *io_ws, float *ver
            assume that the netcdf doesn't have cdf5 capabilities
            enabled.  Tell the user...
         */
-        fprintf(stderr,
-                "EXODUS: ERROR: Attempting to open the CDF5 "
-                "file:\n\t'%s'\n\t. Either the netcdf library does not "
-                "support CDF5 or there is a filesystem or some "
-                "other issue \n",
-                path);
+        snprintf(errmsg, MAX_ERR_LENGTH,
+                 "EXODUS: ERROR: Attempting to open the CDF5 "
+                 "file:\n\t'%s'.\n\tEither the netcdf library does not "
+                 "support CDF5 or there is a filesystem or some "
+                 "other issue \n",
+                 path);
+        ex_err(__func__, errmsg, status);
 
 #endif
       }
@@ -271,6 +273,9 @@ int ex_open_int(const char *path, int mode, int *comp_ws, int *io_ws, float *ver
 #if NC_HAS_DISKLESS
     if (mode & EX_DISKLESS) {
       nc_mode |= NC_DISKLESS;
+#if defined NC_PERSIST
+      nc_mode |= NC_PERSIST;
+#endif
     }
 #endif
     if ((status = nc_open(path, nc_mode, &exoid)) != NC_NOERR) {
@@ -288,7 +293,7 @@ int ex_open_int(const char *path, int mode, int *comp_ws, int *io_ws, float *ver
     if ((status = nc_set_fill(exoid, NC_NOFILL, &old_fill)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to set nofill mode in file id %d named %s",
                exoid, path);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -298,7 +303,7 @@ int ex_open_int(const char *path, int mode, int *comp_ws, int *io_ws, float *ver
       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, path);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
 
@@ -316,14 +321,11 @@ int ex_open_int(const char *path, int mode, int *comp_ws, int *io_ws, float *ver
           snprintf(errmsg, MAX_ERR_LENGTH,
                    "ERROR: failed to define string name dimension in file id %d named %s", exoid,
                    path);
-          ex_err(__func__, errmsg, status);
+          ex_err_fn(exoid, __func__, errmsg, status);
           EX_FUNC_LEAVE(EX_FATAL);
         }
       }
-      if ((status = nc_enddef(exoid)) != NC_NOERR) {
-        snprintf(errmsg, MAX_ERR_LENGTH,
-                 "ERROR: failed to complete definition in file id %d named %s", exoid, path);
-        ex_err(__func__, errmsg, status);
+      if ((status = ex_leavedef(exoid, __func__)) != NC_NOERR) {
         EX_FUNC_LEAVE(EX_FATAL);
       }
     }
@@ -336,7 +338,7 @@ int ex_open_int(const char *path, int mode, int *comp_ws, int *io_ws, float *ver
   if ((status = nc_get_att_float(exoid, NC_GLOBAL, ATT_VERSION, version)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get database version for file id: %d",
              exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -344,7 +346,7 @@ int ex_open_int(const char *path, int mode, int *comp_ws, int *io_ws, float *ver
   if (*version < 2.0) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: Unsupported file version %.2f in file id: %d",
              *version, exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -354,7 +356,7 @@ int ex_open_int(const char *path, int mode, int *comp_ws, int *io_ws, float *ver
         NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get file wordsize from file id: %d",
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -386,7 +388,7 @@ int ex_open_int(const char *path, int mode, int *comp_ws, int *io_ws, float *ver
              "nc_close() called instead of ex_close() on an open Exodus "
              "file?\n",
              exoid, path);
-    ex_err(__func__, errmsg, EX_BADFILEID);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADFILEID);
     nc_close(exoid);
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -395,7 +397,7 @@ int ex_open_int(const char *path, int mode, int *comp_ws, int *io_ws, float *ver
   if (ex_conv_ini(exoid, comp_ws, io_ws, file_wordsize, int64_status, 0, 0, 0) != EX_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to initialize conversion routines in file id %d named %s", exoid, path);
-    ex_err(__func__, errmsg, EX_LASTERR);
+    ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
diff --git a/src/ex_open_par.c b/src/ex_open_par.c
index f379fc34964..86eae83fe29 100644
--- a/src/ex_open_par.c
+++ b/src/ex_open_par.c
@@ -55,12 +55,9 @@
 #include "exodusII.h"
 #if defined(PARALLEL_AWARE_EXODUS)
 
-#include "exodusII.h"     // for ex_err, etc
-#include "exodusII_int.h" // for EX_FATAL, etc
-#include <mpi.h>          // for MPI_Comm, MPI_Info, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <string.h>
+#include "exodusII.h"
+#include "exodusII_int.h"
+#include <mpi.h>
 /*!
 
 \note The ex_open_par_int() is an internal function called by
@@ -220,12 +217,13 @@ int ex_open_par_int(const char *path, int mode, int *comp_ws, int *io_ws, float
 
     if (type == 5) {
 #if NC_HAS_HDF5
-      fprintf(stderr,
-              "EXODUS: ERROR: Attempting to open the netcdf-4 "
-              "file:\n\t'%s'\n\t failed. The netcdf library supports "
-              "netcdf-4 so there must be a filesystem or some other "
-              "issue \n",
-              path);
+      snprintf(errmsg, MAX_ERR_LENGTH,
+               "EXODUS: ERROR: Attempting to open the netcdf-4 "
+               "file:\n\t'%s'\n\tfailed. The netcdf library supports "
+               "netcdf-4 so there must be a filesystem or some other "
+               "issue \n",
+               path);
+      ex_err(__func__, errmsg, status);
 #else
       /* This is an hdf5 (netcdf4) file. If NC_HAS_HDF5 is not defined,
          then we either don't have hdf5 support in this netcdf version,
@@ -235,22 +233,24 @@ int ex_open_par_int(const char *path, int mode, int *comp_ws, int *io_ws, float
          assume that the netcdf doesn't have netcdf4 capabilities
          enabled.  Tell the user...
       */
-      fprintf(stderr,
-              "EXODUS: ERROR: Attempting to open the netcdf-4 "
-              "file:\n\t'%s'\n\tEither the netcdf library does not "
-              "support netcdf-4 or there is a filesystem or some "
-              "other issue \n",
-              path);
+      snprintf(errmsg, MAX_ERR_LENGTH,
+               "EXODUS: ERROR: Attempting to open the netcdf-4 "
+               "file:\n\t'%s'\n\tEither the netcdf library does not "
+               "support netcdf-4 or there is a filesystem or some "
+               "other issue \n",
+               path);
+      ex_err(__func__, errmsg, status);
 #endif
     }
     else if (type == 4) {
-#if defined(NC_64BIT_DATA)
-      fprintf(stderr,
-              "EXODUS: ERROR: Attempting to open the CDF5 "
-              "file:\n\t'%s'\n\t failed. The netcdf library supports "
-              "CDF5-type files so there must be a filesystem or some other "
-              "issue \n",
-              path);
+#if NC_HAS_CDF5
+      snprintf(errmsg, MAX_ERR_LENGTH,
+               "EXODUS: ERROR: Attempting to open the CDF5 "
+               "file:\n\t'%s'\n\tfailed. The netcdf library supports "
+               "CDF5-type files so there must be a filesystem or some other "
+               "issue \n",
+               path);
+      ex_err(__func__, errmsg, status);
 #else
       /* This is an cdf5 (64BIT_DATA) file. If NC_64BIT_DATA is not defined,
          then we either don't have cdf5 support in this netcdf version,
@@ -260,34 +260,35 @@ int ex_open_par_int(const char *path, int mode, int *comp_ws, int *io_ws, float
          assume that the netcdf doesn't have cdf5 capabilities
          enabled.  Tell the user...
       */
-      fprintf(stderr,
-              "EXODUS: ERROR: Attempting to open the CDF5 "
-              "file:\n\t'%s'\n\tEither the netcdf library does not "
-              "support CDF5 or there is a filesystem or some "
-              "other issue \n",
-              path);
-
+      snprintf(errmsg, MAX_ERR_LENGTH,
+               "EXODUS: ERROR: Attempting to open the CDF5 "
+               "file:\n\t'%s'\n\tEither the netcdf library does not "
+               "support CDF5 or there is a filesystem or some "
+               "other issue \n",
+               path);
+      ex_err(__func__, errmsg, status);
 #endif
     }
     else if (type == 1 || type == 2) {
 #if NC_HAS_PNETCDF
-      fprintf(stderr,
-              "EXODUS: ERROR: Attempting to open the classic NetCDF "
-              "file:\n\t'%s'\n\t failed. The netcdf library supports "
-              "PNetCDF files as required for parallel readinf of this "
-              "file type, so there must be a filesystem or some other "
-              "issue \n",
-              path);
+      snprintf(errmsg, MAX_ERR_LENGTH,
+               "EXODUS: ERROR: Attempting to open the classic NetCDF "
+               "file:\n\t'%s'\n\tfailed. The netcdf library supports "
+               "PNetCDF files as required for parallel readinf of this "
+               "file type, so there must be a filesystem or some other "
+               "issue \n",
+               path);
+      ex_err(__func__, errmsg, status);
 #else
       /* This is an normal NetCDF format file, for parallel reading, the PNetCDF
          library is required but that is not compiled into this version.
       */
-      fprintf(stderr,
-              "EXODUS: ERROR: Attempting to open the NetCDF "
-              "file:\n\t'%s'\n\tThe NetCDF library was not "
-              "built with PNetCDF support as required for parallel access to this file.\n",
-              path);
-
+      snprintf(errmsg, MAX_ERR_LENGTH,
+               "EXODUS: ERROR: Attempting to open the NetCDF "
+               "file:\n\t'%s'\n\tThe NetCDF library was not "
+               "built with PNetCDF support as required for parallel access to this file.\n",
+               path);
+      ex_err(__func__, errmsg, status);
 #endif
     }
 
@@ -315,7 +316,7 @@ int ex_open_par_int(const char *path, int mode, int *comp_ws, int *io_ws, float
     if (is_pnetcdf) {
       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(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
       in_redef = 1;
@@ -323,7 +324,7 @@ int ex_open_par_int(const char *path, int mode, int *comp_ws, int *io_ws, float
 
     if ((status = nc_set_fill(exoid, NC_NOFILL, &old_fill)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to set nofill mode in file id %d", exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -334,7 +335,7 @@ int ex_open_par_int(const char *path, int mode, int *comp_ws, int *io_ws, float
         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(__func__, errmsg, status);
+          ex_err_fn(exoid, __func__, errmsg, status);
           EX_FUNC_LEAVE(EX_FATAL);
         }
         in_redef = 1;
@@ -354,10 +355,7 @@ int ex_open_par_int(const char *path, int mode, int *comp_ws, int *io_ws, float
     }
 
     if (in_redef) {
-      if ((status = nc_enddef(exoid)) != NC_NOERR) {
-        snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to complete definition in file id %d",
-                 exoid);
-        ex_err(__func__, errmsg, status);
+      if ((status = ex_leavedef(exoid, __func__)) != NC_NOERR) {
         EX_FUNC_LEAVE(EX_FATAL);
       }
       in_redef = 0;
@@ -403,7 +401,7 @@ int ex_open_par_int(const char *path, int mode, int *comp_ws, int *io_ws, float
   if ((status = nc_get_att_float(exoid, NC_GLOBAL, ATT_VERSION, version)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get database version for file id: %d",
              exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -411,7 +409,7 @@ int ex_open_par_int(const char *path, int mode, int *comp_ws, int *io_ws, float
   if (*version < 2.0) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: Unsupported file version %.2f in file id: %d",
              *version, exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -421,7 +419,7 @@ int ex_open_par_int(const char *path, int mode, int *comp_ws, int *io_ws, float
         NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get file wordsize from file id: %d",
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -453,7 +451,7 @@ int ex_open_par_int(const char *path, int mode, int *comp_ws, int *io_ws, float
              "nc_close() called instead of ex_close() on an open Exodus "
              "file?\n",
              exoid, path);
-    ex_err(__func__, errmsg, EX_BADFILEID);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADFILEID);
     nc_close(exoid);
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -463,7 +461,7 @@ int ex_open_par_int(const char *path, int mode, int *comp_ws, int *io_ws, float
       EX_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to initialize conversion routines in file id %d", exoid);
-    ex_err(__func__, errmsg, EX_LASTERR);
+    ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
diff --git a/src/ex_put_all_var_param_ext.c b/src/ex_put_all_var_param_ext.c
index 260f7b03902..8ff7de6428b 100644
--- a/src/ex_put_all_var_param_ext.c
+++ b/src/ex_put_all_var_param_ext.c
@@ -47,12 +47,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for ex_get_dimension, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_def_var, etc
-#include <inttypes.h>     // for PRId64
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <stdlib.h>    // for malloc, NULL, free
-#include <sys/types.h> // for int64_t
 
 static int  define_dimension(int exoid, const char *DIMENSION, int count, const char *label,
                              int *dimid);
@@ -78,7 +72,7 @@ static int  ex_define_vars(int exoid, ex_entity_type obj_type, const char *entit
     if (!(VIDS = malloc(sizeof(int64_t) * DVAL))) {                                                \
       snprintf(errmsg, MAX_ERR_LENGTH,                                                             \
                "ERROR: failed to allocate memory for " TNAME " id array for file id %d", exoid);   \
-      ex_err(__func__, errmsg, EX_MEMFAIL);                                                        \
+      ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);                                              \
       goto error_ret;                                                                              \
     }                                                                                              \
     ex_get_ids(exoid, EIDS, VIDS);                                                                 \
@@ -100,16 +94,16 @@ static int  ex_define_vars(int exoid, ex_entity_type obj_type, const char *entit
 int ex_put_all_var_param_ext(int exoid, const ex_var_params *vp)
 {
   int    in_define = 0;
-  int    status;
-  int    temp;
+  int    status    = 0;
+  int    temp      = 0;
   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;
+  size_t num_elem_blk = 0, num_edge_blk = 0, num_face_blk = 0;
+  size_t num_nset = 0, num_eset = 0, num_fset = 0, num_sset = 0, num_elset = 0;
   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 i           = 0;
 
   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;
@@ -142,7 +136,7 @@ int ex_put_all_var_param_ext(int exoid, const ex_var_params *vp)
 
   if ((status = nc_inq_dimid(exoid, DIM_TIME, &time_dim)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate time dimension in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     goto error_ret;
   }
 
@@ -153,7 +147,7 @@ int ex_put_all_var_param_ext(int exoid, const ex_var_params *vp)
   /* Check this now so we can use it later without checking for errors */
   if ((status = nc_inq_dimid(exoid, DIM_STR_NAME, &temp)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get string length in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     goto error_ret;
   }
 
@@ -177,7 +171,7 @@ int ex_put_all_var_param_ext(int exoid, const ex_var_params *vp)
   /* put file into define mode  */
   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(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     goto error_ret;
   }
   in_define = 1;
@@ -194,7 +188,7 @@ int ex_put_all_var_param_ext(int exoid, const ex_var_params *vp)
         NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define global variables in file id %d",
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       goto error_ret; /* exit define mode and return */
     }
     ex_compress_variable(exoid, varid, 2);
@@ -218,7 +212,7 @@ int ex_put_all_var_param_ext(int exoid, const ex_var_params *vp)
             NC_NOERR) {
           snprintf(errmsg, MAX_ERR_LENGTH,
                    "ERROR: failed to define nodal variable %d in file id %d", i, exoid);
-          ex_err(__func__, errmsg, status);
+          ex_err_fn(exoid, __func__, errmsg, status);
           goto error_ret; /* exit define mode and return */
         }
         ex_compress_variable(exoid, varid, 2);
@@ -290,9 +284,7 @@ int ex_put_all_var_param_ext(int exoid, const ex_var_params *vp)
   /* leave define mode  */
 
   in_define = 0;
-  if ((status = nc_enddef(exoid)) != NC_NOERR) {
-    snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to complete definition in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+  if ((status = ex_leavedef(exoid, __func__)) != NC_NOERR) {
     goto error_ret;
   }
 
@@ -350,11 +342,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 */
-      snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to complete definition for file id %d",
-               exoid);
-      ex_err(__func__, errmsg, status);
-    }
+    ex_leavedef(exoid, __func__);
   }
   free(eblk_ids);
   free(edblk_ids);
@@ -388,12 +376,12 @@ static int define_dimension(int exoid, const char *DIMENSION, int count, const c
                "ERROR: %s variable name parameters are already defined "
                "in file id %d",
                label, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
     }
     else {
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to define number of %s variables in file id %d", label, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
     }
   }
   return (status);
@@ -417,12 +405,12 @@ static int define_variable_name_variable(int exoid, const char *VARIABLE, int di
     if (status == NC_ENAMEINUSE) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: %s variable names are already defined in file id %d",
                label, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
     }
     else {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define %s variable names in file id %d",
                label, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
     }
   }
 #if NC_HAS_HDF5
@@ -441,7 +429,7 @@ static int *get_status_array(int exoid, int var_count, const char *VARIABLE, con
   if (!(stat_vals = malloc(var_count * sizeof(int)))) {
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to allocate memory for %s status array for file id %d", label, exoid);
-    ex_err(__func__, errmsg, EX_MEMFAIL);
+    ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
     return (NULL);
   }
 
@@ -454,7 +442,7 @@ static int *get_status_array(int exoid, int var_count, const char *VARIABLE, con
       free(stat_vals);
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get %s status array from file id %d",
                label, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       return (NULL);
     }
   }
@@ -478,7 +466,7 @@ static int put_truth_table(int exoid, int varid, int *table, const char *label)
   if (iresult != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to store %s variable truth table in file id %d",
              label, exoid);
-    ex_err(__func__, errmsg, iresult);
+    ex_err_fn(exoid, __func__, errmsg, iresult);
   }
   return iresult;
 }
@@ -496,14 +484,14 @@ static int define_truth_table(ex_entity_type obj_type, int exoid, int num_ent, i
 
   if ((status = nc_inq_dimid(exoid, DIM_TIME, &time_dim)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate time dimension in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     return -1;
   }
 
   if (var_tab == NULL) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: %s variable truth table is NULL in file id %d", label,
              exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     return -1;
   }
 
@@ -530,7 +518,7 @@ static int define_truth_table(ex_entity_type obj_type, int exoid, int num_ent, i
             snprintf(errmsg, MAX_ERR_LENGTH,
                      "ERROR: failed to locate number of entities in %s %" PRId64 " in file id %d",
                      label, id, exoid);
-            ex_err(__func__, errmsg, status);
+            ex_err_fn(exoid, __func__, errmsg, status);
             return (status);
           }
 
@@ -546,7 +534,7 @@ static int define_truth_table(ex_entity_type obj_type, int exoid, int num_ent, i
               snprintf(errmsg, MAX_ERR_LENGTH,
                        "ERROR: failed to define %s variable for %s %" PRId64 " in file id %d",
                        label, label, id, exoid);
-              ex_err(__func__, errmsg, status);
+              ex_err_fn(exoid, __func__, errmsg, status);
               return (status);
             }
           }
@@ -598,7 +586,7 @@ static int ex_define_vars(int exoid, ex_entity_type obj_type, const char *entity
     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);
+      ex_err_fn(exoid, __func__, errmsg, status);
       return status;
     }
   }
diff --git a/src/ex_put_attr.c b/src/ex_put_attr.c
index 9df86f1ff34..c7991760271 100644
--- a/src/ex_put_attr.c
+++ b/src/ex_put_attr.c
@@ -52,9 +52,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, ex_comp_ws, etc
-#include "vtk_netcdf.h"       // for nc_inq_varid, NC_NOERR, etc
-#include <inttypes.h>     // for PRId64
-#include <stdio.h>
 
 /*!
  * writes the attributes for an edge/face/element block
@@ -84,12 +81,12 @@ int ex_put_attr(int exoid, ex_entity_type blk_type, ex_entity_id blk_id, const v
           snprintf(errmsg, MAX_ERR_LENGTH,
                    "Warning: no attributes allowed for NULL %s %" PRId64 " in file id %d",
                    ex_name_of_object(blk_type), blk_id, exoid);
-          ex_err(__func__, errmsg, EX_NULLENTITY);
+          ex_err_fn(exoid, __func__, errmsg, EX_NULLENTITY);
           EX_FUNC_LEAVE(EX_WARN); /* no attributes for this block */
         }
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: no %s id %" PRId64 " in in file id %d",
                  ex_name_of_object(blk_type), blk_id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
     }
@@ -109,7 +106,7 @@ int ex_put_attr(int exoid, ex_entity_type blk_type, ex_entity_id blk_id, const v
     snprintf(errmsg, MAX_ERR_LENGTH,
              "Internal ERROR: unrecognized object type in switch: %d in file id %d", blk_type,
              exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL); /* number of attributes not defined */
   }
 
@@ -117,7 +114,7 @@ int ex_put_attr(int exoid, ex_entity_type blk_type, ex_entity_id blk_id, const v
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to locate attribute variable for %s %" PRId64 " in file id %d",
              ex_name_of_object(blk_type), blk_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -133,7 +130,7 @@ int ex_put_attr(int exoid, ex_entity_type blk_type, ex_entity_id blk_id, const v
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to put attributes for %s %" PRId64 " in file id %d",
              ex_name_of_object(blk_type), blk_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
   EX_FUNC_LEAVE(EX_NOERR);
diff --git a/src/ex_put_attr_names.c b/src/ex_put_attr_names.c
index 3c540eeb51b..6c2473d6ef6 100644
--- a/src/ex_put_attr_names.c
+++ b/src/ex_put_attr_names.c
@@ -53,10 +53,6 @@
 
 #include "exodusII.h"     // for ex_err, ex_name_of_object, etc
 #include "exodusII_int.h" // for EX_FATAL, ex_id_lkup, etc
-#include "vtk_netcdf.h"       // for nc_inq_dimid, nc_inq_varid, etc
-#include <inttypes.h>     // for PRId64
-#include <stddef.h>       // for size_t
-#include <stdio.h>
 
 /*!
  * writes the attribute names for a block
@@ -85,12 +81,12 @@ int ex_put_attr_names(int exoid, ex_entity_type blk_type, ex_entity_id blk_id, c
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "Warning: no attributes allowed for NULL %s %" PRId64 " in file id %d",
                  ex_name_of_object(blk_type), blk_id, exoid);
-        ex_err(__func__, errmsg, EX_NULLENTITY);
+        ex_err_fn(exoid, __func__, errmsg, EX_NULLENTITY);
         EX_FUNC_LEAVE(EX_WARN); /* no attributes for this block */
       }
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: no %s id %" PRId64 " in %s array in file id %d",
                ex_name_of_object(blk_type), blk_id, VAR_ID_EL_BLK, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -118,7 +114,7 @@ int ex_put_attr_names(int exoid, ex_entity_type blk_type, ex_entity_id blk_id, c
     snprintf(errmsg, MAX_ERR_LENGTH,
              "Internal ERROR: unrecognized object type in switch: %d in file id %d", blk_type,
              exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL); /* number of attributes not defined */
   }
 
@@ -126,7 +122,7 @@ int ex_put_attr_names(int exoid, ex_entity_type blk_type, ex_entity_id blk_id, c
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: number of attributes not defined for %s %" PRId64 " in file id %d",
              ex_name_of_object(blk_type), blk_id, exoid);
-    ex_err(__func__, errmsg, EX_MSG);
+    ex_err_fn(exoid, __func__, errmsg, EX_MSG);
     EX_FUNC_LEAVE(EX_FATAL); /* number of attributes not defined */
   }
 
@@ -134,7 +130,7 @@ int ex_put_attr_names(int exoid, ex_entity_type blk_type, ex_entity_id blk_id, c
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to get number of attributes for %s %" PRId64 " in file id %d",
              ex_name_of_object(blk_type), blk_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -152,7 +148,7 @@ int ex_put_attr_names(int exoid, ex_entity_type blk_type, ex_entity_id blk_id, c
     snprintf(errmsg, MAX_ERR_LENGTH,
              "Internal ERROR: unrecognized object type in switch: %d in file id %d", blk_type,
              exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL); /* number of attributes not defined */
   }
 
@@ -160,7 +156,7 @@ int ex_put_attr_names(int exoid, ex_entity_type blk_type, ex_entity_id blk_id, c
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to locate %s attribute names for %s %" PRId64 " in file id %d",
              ex_name_of_object(blk_type), ex_name_of_object(blk_type), blk_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
diff --git a/src/ex_put_attr_param.c b/src/ex_put_attr_param.c
index 4839ad6fa9f..e468d639998 100644
--- a/src/ex_put_attr_param.c
+++ b/src/ex_put_attr_param.c
@@ -50,9 +50,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, EX_WARN, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_def_var, etc
-#include <inttypes.h>     // for PRId64
-#include <stdio.h>
 
 /*!
  * defines the number of attributes.
@@ -97,13 +94,13 @@ int ex_put_attr_param(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, i
           snprintf(errmsg, MAX_ERR_LENGTH,
                    "Warning: no attributes found for NULL %s %" PRId64 " in file id %d",
                    ex_name_of_object(obj_type), obj_id, exoid);
-          ex_err(__func__, errmsg, EX_NULLENTITY);
+          ex_err_fn(exoid, __func__, errmsg, EX_NULLENTITY);
           EX_FUNC_LEAVE(EX_WARN); /* no attributes for this object */
         }
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "Warning: failed to locate %s id %" PRId64 " in id array in file id %d",
                  ex_name_of_object(obj_type), obj_id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_WARN);
       }
     }
@@ -167,7 +164,7 @@ int ex_put_attr_param(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, i
   default:
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: Bad block type (%d) specified for file id %d",
              obj_type, exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -175,14 +172,14 @@ int ex_put_attr_param(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, i
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to locate number of entries for %s %" PRId64 " in file id %d",
              ex_name_of_object(obj_type), obj_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
   /* put netcdf file into define mode  */
   if ((status = nc_redef(exoid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to place file id %d into define mode", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -190,7 +187,7 @@ int ex_put_attr_param(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, i
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to define number of attributes in %s %" PRId64 " in file id %d",
              ex_name_of_object(obj_type), obj_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     goto error_ret; /* exit define mode and return */
   }
 
@@ -201,7 +198,7 @@ int ex_put_attr_param(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, i
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR:  failed to define attributes for %s %" PRId64 " in file id %d",
              ex_name_of_object(obj_type), obj_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     goto error_ret; /* exit define mode and return */
   }
   ex_compress_variable(exoid, varid, 2);
@@ -209,7 +206,7 @@ int ex_put_attr_param(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, i
   /* inquire previously defined dimensions  */
   if ((status = nc_inq_dimid(exoid, DIM_STR_NAME, &strdim)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get string length in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -221,7 +218,7 @@ int ex_put_attr_param(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, i
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to define %s attribute name array in file id %d",
              ex_name_of_object(obj_type), exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     goto error_ret; /* exit define mode and return */
   }
 #if NC_HAS_HDF5
@@ -229,12 +226,7 @@ int ex_put_attr_param(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, i
 #endif
 
   /* leave define mode  */
-  if ((status = nc_enddef(exoid)) != NC_NOERR) {
-    snprintf(errmsg, MAX_ERR_LENGTH,
-             "ERROR: failed to complete %s attribute parameter "
-             "definition in file id %d",
-             ex_name_of_object(obj_type), exoid);
-    ex_err(__func__, errmsg, status);
+  if ((status = ex_leavedef(exoid, __func__)) != NC_NOERR) {
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -242,9 +234,6 @@ int ex_put_attr_param(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, i
 
 /* Fatal error: exit definition mode and return */
 error_ret:
-  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);
-  }
+  ex_leavedef(exoid, __func__);
   EX_FUNC_LEAVE(EX_FATAL);
 }
diff --git a/src/ex_put_block.c b/src/ex_put_block.c
index 3edb422b9cb..758413ced44 100644
--- a/src/ex_put_block.c
+++ b/src/ex_put_block.c
@@ -55,8 +55,7 @@
  *****************************************************************************/
 
 #include "exodusII.h" // for ex_block, MAX_STR_LENGTH, etc
-#include <stdint.h>   // for int64_t
-#include <string.h>   // for strncpy
+#include "exodusII_int.h"
 
 /*!
  * writes the parameters used to describe an element/face/edge block
@@ -80,7 +79,7 @@ int ex_put_block(int exoid, ex_entity_type blk_type, ex_entity_id blk_id, const
   ex_block block;
   block.type = blk_type;
   block.id   = blk_id;
-  strncpy(block.topology, entry_descrip, MAX_STR_LENGTH + 1);
+  ex_copy_string(block.topology, entry_descrip, MAX_STR_LENGTH + 1);
   block.topology[MAX_STR_LENGTH] = '\0';
   block.num_entry                = num_entries_this_blk;
   block.num_nodes_per_entry      = num_nodes_per_entry;
diff --git a/src/ex_put_block_params.c b/src/ex_put_block_params.c
index f1f34aa6e84..dfdaf491716 100644
--- a/src/ex_put_block_params.c
+++ b/src/ex_put_block_params.c
@@ -35,12 +35,6 @@
 
 #include "exodusII.h"     // for ex_block, ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_def_var, etc
-#include <inttypes.h>     // for PRId64
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <stdlib.h> // for free, malloc
-#include <string.h> // for NULL, strlen
 
 /*!
  * writes the parameters used to describe an element/face/edge block
@@ -115,7 +109,7 @@ int ex_put_block_params(int exoid, size_t block_count, const struct ex_block *bl
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: Bad block type (%d) specified for entry %d file id %d", blocks[i].type,
                (int)i, exoid);
-      ex_err(__func__, errmsg, EX_BADPARAM);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
       free(blocks_to_define);
       EX_FUNC_LEAVE(EX_FATAL);
     }
@@ -125,7 +119,7 @@ int ex_put_block_params(int exoid, size_t block_count, const struct ex_block *bl
                                    &dimid, __func__)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: No %ss defined in file id %d",
                ex_name_of_object(blocks[i].type), exoid);
-      ex_err(__func__, errmsg, EX_LASTERR);
+      ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
       free(blocks_to_define);
       EX_FUNC_LEAVE(EX_FATAL);
     }
@@ -140,7 +134,7 @@ int ex_put_block_params(int exoid, size_t block_count, const struct ex_block *bl
     if ((status = nc_inq_varid(exoid, vblkids, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate %s ids in file id %d",
                ex_name_of_object(blocks[i].type), exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       free(blocks_to_define);
       EX_FUNC_LEAVE(EX_FATAL);
     }
@@ -149,7 +143,7 @@ int ex_put_block_params(int exoid, size_t block_count, const struct ex_block *bl
     if (-status != EX_LOOKUPFAIL) { /* found the element block id */
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: %s id %" PRId64 " already exists in file id %d",
                ex_name_of_object(blocks[i].type), blocks[i].id, exoid);
-      ex_err(__func__, errmsg, EX_DUPLICATEID);
+      ex_err_fn(exoid, __func__, errmsg, EX_DUPLICATEID);
       free(blocks_to_define);
       EX_FUNC_LEAVE(EX_FATAL);
     }
@@ -163,7 +157,7 @@ int ex_put_block_params(int exoid, size_t block_count, const struct ex_block *bl
     if (cur_num_blk >= (int)num_blk) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: exceeded number of %ss (%d) defined in file id %d",
                ex_name_of_object(blocks[i].type), (int)num_blk, exoid);
-      ex_err(__func__, errmsg, EX_BADPARAM);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
       free(blocks_to_define);
       EX_FUNC_LEAVE(EX_FATAL);
     }
@@ -179,7 +173,7 @@ int ex_put_block_params(int exoid, size_t block_count, const struct ex_block *bl
     if (status != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to store %s id to file id %d",
                ex_name_of_object(blocks[i].type), exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       free(blocks_to_define);
       EX_FUNC_LEAVE(EX_FATAL);
     }
@@ -196,7 +190,7 @@ int ex_put_block_params(int exoid, size_t block_count, const struct ex_block *bl
     if ((status = nc_inq_varid(exoid, vblksta, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate %s status in file id %d",
                ex_name_of_object(blocks[i].type), exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       free(blocks_to_define);
       EX_FUNC_LEAVE(EX_FATAL);
     }
@@ -205,7 +199,7 @@ int ex_put_block_params(int exoid, size_t block_count, const struct ex_block *bl
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to store %s id %" PRId64 " status to file id %d",
                ex_name_of_object(blocks[i].type), blocks[i].id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       free(blocks_to_define);
       EX_FUNC_LEAVE(EX_FATAL);
     }
@@ -214,7 +208,7 @@ int ex_put_block_params(int exoid, size_t block_count, const struct ex_block *bl
   /* put netcdf file into define mode  */
   if ((status = nc_redef(exoid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to place file id %d into define mode", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     free(blocks_to_define);
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -273,13 +267,13 @@ int ex_put_block_params(int exoid, size_t block_count, const struct ex_block *bl
       if (status == NC_ENAMEINUSE) { /* duplicate entry */
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: %s %" PRId64 " already defined in file id %d",
                  ex_name_of_object(blocks[i].type), blocks[i].id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
       }
       else {
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to define number of entities/block for %s %" PRId64 " file id %d",
                  ex_name_of_object(blocks[i].type), blocks[i].id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
       }
       goto error_ret; /* exit define mode and return */
     }
@@ -291,7 +285,7 @@ int ex_put_block_params(int exoid, size_t block_count, const struct ex_block *bl
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to define number of nodes/entity for %s %" PRId64 " in file id %d",
                  ex_name_of_object(blocks[i].type), blocks[i].id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         goto error_ret; /* exit define mode and return */
       }
     }
@@ -302,7 +296,7 @@ int ex_put_block_params(int exoid, size_t block_count, const struct ex_block *bl
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to define number of edges/entity for %s %" PRId64 " in file id %d",
                  ex_name_of_object(blocks[i].type), blocks[i].id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         goto error_ret; /* exit define mode and return */
       }
     }
@@ -313,7 +307,7 @@ int ex_put_block_params(int exoid, size_t block_count, const struct ex_block *bl
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to define number of faces/entity for %s %" PRId64 " in file id %d",
                  ex_name_of_object(blocks[i].type), blocks[i].id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         goto error_ret; /* exit define mode and return */
       }
     }
@@ -325,7 +319,7 @@ int ex_put_block_params(int exoid, size_t block_count, const struct ex_block *bl
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to define number of attributes in %s %" PRId64 " in file id %d",
                  ex_name_of_object(blocks[i].type), blocks[i].id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         goto error_ret; /* exit define mode and return */
       }
 
@@ -336,7 +330,7 @@ int ex_put_block_params(int exoid, size_t block_count, const struct ex_block *bl
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR:  failed to define attributes for %s %" PRId64 " in file id %d",
                  ex_name_of_object(blocks[i].type), blocks[i].id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         goto error_ret; /* exit define mode and return */
       }
       ex_compress_variable(exoid, varid, 2);
@@ -359,7 +353,7 @@ int ex_put_block_params(int exoid, size_t block_count, const struct ex_block *bl
       /* inquire previously defined dimensions  */
       if ((status = nc_inq_dimid(exoid, DIM_STR_NAME, &strdim)) != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get string length in file id %d", exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         goto error_ret;
       }
 
@@ -371,7 +365,7 @@ int ex_put_block_params(int exoid, size_t block_count, const struct ex_block *bl
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to define %s attribute name array in file id %d",
                  ex_name_of_object(blocks[i].type), exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         goto error_ret; /* exit define mode and return */
       }
 #if NC_HAS_HDF5
@@ -407,7 +401,7 @@ int ex_put_block_params(int exoid, size_t block_count, const struct ex_block *bl
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: Bad block type (%d) for nsided/nfaced block in file id %d", blocks[i].type,
                  exoid);
-        ex_err(__func__, errmsg, EX_BADPARAM);
+        ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
         goto error_ret;
       }
 
@@ -439,7 +433,7 @@ int ex_put_block_params(int exoid, size_t block_count, const struct ex_block *bl
         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);
+        ex_err_fn(exoid, __func__, errmsg, status);
         goto error_ret; /* exit define mode and return */
       }
 
@@ -451,7 +445,7 @@ int ex_put_block_params(int exoid, size_t block_count, const struct ex_block *bl
                  "ERROR: failed to create face- or node- per-entity "
                  "count array for %s %" PRId64 " in file id %d",
                  ex_name_of_object(blocks[i].type), blocks[i].id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         goto error_ret; /* exit define mode and return */
       }
 
@@ -461,7 +455,7 @@ int ex_put_block_params(int exoid, size_t block_count, const struct ex_block *bl
                  "ERROR: failed to store entity type attribute text for %s %" PRId64
                  " in file id %d",
                  ex_name_of_object(blocks[i].type), blocks[i].id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         goto error_ret; /* exit define mode and return */
       }
       if ((status = nc_put_att_text(exoid, npeid, "entity_type2", strlen(entity_type2) + 1,
@@ -470,7 +464,7 @@ int ex_put_block_params(int exoid, size_t block_count, const struct ex_block *bl
                  "ERROR: failed to store entity type attribute text for %s %" PRId64
                  " in file id %d",
                  ex_name_of_object(blocks[i].type), blocks[i].id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         goto error_ret; /* exit define mode and return */
       }
     }
@@ -484,7 +478,7 @@ int ex_put_block_params(int exoid, size_t block_count, const struct ex_block *bl
           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);
+          ex_err_fn(exoid, __func__, errmsg, status);
           goto error_ret; /* exit define mode and return */
         }
         ex_compress_variable(exoid, connid, 1);
@@ -496,7 +490,7 @@ int ex_put_block_params(int exoid, size_t block_count, const struct ex_block *bl
                                     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);
+        ex_err_fn(exoid, __func__, errmsg, status);
         goto error_ret; /* exit define mode and return */
       }
     }
@@ -511,7 +505,7 @@ int ex_put_block_params(int exoid, size_t block_count, const struct ex_block *bl
                    "ERROR: failed to create edge 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);
+          ex_err_fn(exoid, __func__, errmsg, status);
           goto error_ret; /* exit define mode and return */
         }
       }
@@ -525,7 +519,7 @@ int ex_put_block_params(int exoid, size_t block_count, const struct ex_block *bl
                    "ERROR: failed to create face 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);
+          ex_err_fn(exoid, __func__, errmsg, status);
           goto error_ret; /* exit define mode and return */
         }
       }
@@ -535,10 +529,7 @@ int ex_put_block_params(int exoid, size_t block_count, const struct ex_block *bl
   free(blocks_to_define);
 
   /* leave define mode  */
-  if ((status = nc_enddef(exoid)) != NC_NOERR) {
-    snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to complete %s definition in file id %d",
-             ex_name_of_object(blocks[i].type), exoid);
-    ex_err(__func__, errmsg, status);
+  if ((status = ex_leavedef(exoid, __func__)) != NC_NOERR) {
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -577,9 +568,6 @@ int ex_put_block_params(int exoid, size_t block_count, const struct ex_block *bl
 error_ret:
   free(blocks_to_define);
 
-  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);
-  }
+  ex_leavedef(exoid, __func__);
   EX_FUNC_LEAVE(EX_FATAL);
 }
diff --git a/src/ex_put_cmap_params.c b/src/ex_put_cmap_params.c
index d4429624e5b..48bd79d1fc1 100644
--- a/src/ex_put_cmap_params.c
+++ b/src/ex_put_cmap_params.c
@@ -61,10 +61,6 @@
 
 #include <exodusII.h>     // for ex_err, etc
 #include <exodusII_int.h> // for EX_FATAL, ex_leavedef, etc
-#include <vtk_netcdf.h>       // for NC_NOERR, nc_def_var, etc
-#include <stddef.h>       // for size_t
-#include <stdint.h>       // for int64_t
-#include <stdio.h>
 
 int ex_put_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_node_cnts,
                        void_int *elem_cmap_ids, void_int *elem_cmap_elem_cnts, int64_t processor)
@@ -104,7 +100,7 @@ int ex_put_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_n
   /* Get the file type */
   if (ex_get_file_type(exoid, ftype) != EX_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get file type from file ID %d\n", exoid);
-    ex_err(__func__, errmsg, EX_MSG);
+    ex_err_fn(exoid, __func__, errmsg, EX_MSG);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -112,14 +108,14 @@ int ex_put_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_n
   if (ftype[0] != 'p') {
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: function for use with parallel files only, file ID %d\n", exoid);
-    ex_err(__func__, errmsg, EX_MSG);
+    ex_err_fn(exoid, __func__, errmsg, EX_MSG);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
   /* Put NetCDF file into define mode */
   if ((status = nc_redef(exoid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to file ID %d into define mode", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -132,7 +128,7 @@ int ex_put_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_n
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to find length of dimension \"%s\" in file ID %d", DIM_NUM_N_CMAPS,
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -148,7 +144,7 @@ int ex_put_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_n
         NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to add variable \"%s\" in file ID %d",
                VAR_N_COMM_DATA_IDX, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -171,7 +167,7 @@ int ex_put_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_n
     if ((status = nc_def_dim(exoid, DIM_NCNT_CMAP, ncnt_cmap, &dimid[0])) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to add dimension for \"%s\" in file ID %d",
                DIM_NCNT_CMAP, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -182,7 +178,7 @@ int ex_put_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_n
     if ((status = nc_def_var(exoid, VAR_N_COMM_NIDS, id_type, 1, dimid, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to add variable \"%s\" in file ID %d",
                VAR_N_COMM_NIDS, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -193,7 +189,7 @@ int ex_put_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_n
     if ((status = nc_def_var(exoid, VAR_N_COMM_PROC, NC_INT, 1, dimid, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to add variable \"%s\" in file ID %d",
                VAR_N_COMM_PROC, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -212,7 +208,7 @@ int ex_put_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_n
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to find length of dimension \"%s\" in file ID %d", DIM_NUM_E_CMAPS,
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -228,7 +224,7 @@ int ex_put_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_n
         NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to add variable \"%s\" in file ID %d",
                VAR_E_COMM_DATA_IDX, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -250,7 +246,7 @@ int ex_put_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_n
     if ((status = nc_def_dim(exoid, DIM_ECNT_CMAP, ecnt_cmap, &dimid[0])) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to add dimension for \"%s\" in file ID %d",
                DIM_ECNT_CMAP, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -261,7 +257,7 @@ int ex_put_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_n
     if ((status = nc_def_var(exoid, VAR_E_COMM_EIDS, id_type, 1, dimid, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to add variable \"%s\" in file ID %d",
                VAR_E_COMM_EIDS, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -272,7 +268,7 @@ int ex_put_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_n
     if ((status = nc_def_var(exoid, VAR_E_COMM_PROC, NC_INT, 1, dimid, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to add variable \"%s\" in file ID %d",
                VAR_E_COMM_PROC, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -283,7 +279,7 @@ int ex_put_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_n
     if ((status = nc_def_var(exoid, VAR_E_COMM_SIDS, NC_INT, 1, dimid, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to add variable \"%s\" in file ID %d",
                VAR_E_COMM_SIDS, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -302,7 +298,7 @@ int ex_put_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_n
     if ((status = nc_inq_varid(exoid, VAR_N_COMM_STAT, &n_varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
                VAR_N_COMM_STAT, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -327,7 +323,7 @@ int ex_put_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_n
 
       if ((status = nc_put_var1_int(exoid, n_varid, start, &nmstat)) != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: unable to output variable in file ID %d", exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
 
@@ -339,7 +335,7 @@ int ex_put_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_n
           NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to output int elem map index in file ID %d",
                  exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
     } /* End "for(icm=0; icm < num_n_comm_maps; icm++)" */
@@ -348,7 +344,7 @@ int ex_put_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_n
     if ((status = nc_inq_varid(exoid, VAR_N_COMM_IDS, &n_varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
                VAR_N_COMM_IDS, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -361,7 +357,7 @@ int ex_put_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_n
     }
     if (status != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to output variable in file ID %d", exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -374,7 +370,7 @@ int ex_put_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_n
     if ((status = nc_inq_varid(exoid, VAR_E_COMM_STAT, &e_varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
                VAR_E_COMM_STAT, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -397,7 +393,7 @@ int ex_put_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_n
 
       if ((status = nc_put_var1_int(exoid, e_varid, start, &nmstat)) != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: unable to output variable in file ID %d", exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
 
@@ -409,7 +405,7 @@ int ex_put_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_n
           NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to output int elem map index in file ID %d",
                  exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
     } /* End "for(icm=0; icm < num_e_comm_maps; icm++)" */
@@ -418,7 +414,7 @@ int ex_put_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_n
     if ((status = nc_inq_varid(exoid, VAR_E_COMM_IDS, &e_varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
                VAR_E_COMM_IDS, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -431,7 +427,7 @@ int ex_put_cmap_params(int exoid, void_int *node_cmap_ids, void_int *node_cmap_n
     }
     if (status != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to output variable in file ID %d", exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
 
       EX_FUNC_LEAVE(EX_FATAL);
     }
diff --git a/src/ex_put_cmap_params_cc.c b/src/ex_put_cmap_params_cc.c
index 0f8c77dbc96..ea2559866fe 100644
--- a/src/ex_put_cmap_params_cc.c
+++ b/src/ex_put_cmap_params_cc.c
@@ -61,11 +61,6 @@
 /*****************************************************************************/
 #include <exodusII.h>     // for ex_err, etc
 #include <exodusII_int.h> // for EX_FATAL, ex_leavedef, etc
-#include <vtk_netcdf.h>       // for NC_NOERR, nc_def_var, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <stdlib.h>    // for free, malloc
-#include <sys/types.h> // for int64_t
 
 int ex_put_cmap_params_cc(int exoid, void_int *node_cmap_ids, void_int *node_cmap_node_cnts,
                           void_int *node_proc_ptrs, void_int *elem_cmap_ids,
@@ -112,7 +107,7 @@ int ex_put_cmap_params_cc(int exoid, void_int *node_cmap_ids, void_int *node_cma
   if ((status = nc_inq_dimid(exoid, DIM_NUM_PROCS_F, &n_dimid[0])) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get dimension ID for \"%s\" in file ID %d",
              DIM_NUM_PROCS_F, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -120,7 +115,7 @@ int ex_put_cmap_params_cc(int exoid, void_int *node_cmap_ids, void_int *node_cma
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to find length of dimension \"%s\" in file ID %d", DIM_NUM_PROCS_F,
              exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -139,7 +134,7 @@ int ex_put_cmap_params_cc(int exoid, void_int *node_cmap_ids, void_int *node_cma
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find length of dimension \"%s\" in \
 file ID %d",
                DIM_NUM_N_CMAPS, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -149,7 +144,7 @@ file ID %d",
     if ((status = nc_inq_varid(exoid, VAR_N_COMM_INFO_IDX, &n_varid_idx)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
                VAR_N_COMM_INFO_IDX, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -163,7 +158,7 @@ file ID %d",
     if (!n_var_idx) {
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: insufficient memory to read index variable from file ID %d", exoid);
-      ex_err(__func__, errmsg, EX_MSG);
+      ex_err_fn(exoid, __func__, errmsg, EX_MSG);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -181,7 +176,7 @@ file ID %d",
     if (status != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get variable \"%s\" from file ID %d",
                VAR_N_COMM_INFO_IDX, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   } /* "if (num_n_comm_maps > 0)" */
@@ -195,7 +190,7 @@ file ID %d",
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find length of dimension \"%s\" in \
 file ID %d",
                DIM_NUM_E_CMAPS, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -205,7 +200,7 @@ file ID %d",
     if ((status = nc_inq_varid(exoid, VAR_E_COMM_INFO_IDX, &e_varid_idx)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
                VAR_E_COMM_INFO_IDX, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -219,7 +214,7 @@ file ID %d",
     if (!e_var_idx) {
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: insufficient memory to read index variable from file ID %d", exoid);
-      ex_err(__func__, errmsg, EX_MEMFAIL);
+      ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -235,7 +230,7 @@ file ID %d",
     if (status != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get variable \"%s\" from file ID %d",
                VAR_E_COMM_INFO_IDX, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   } /* "if (num_e_comm_maps >0)" */
@@ -243,7 +238,7 @@ file ID %d",
   /* Put NetCDF file into define mode */
   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(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -257,7 +252,7 @@ file ID %d",
         NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to add variable \"%s\" in file ID %d",
                VAR_N_COMM_DATA_IDX, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -287,7 +282,7 @@ file ID %d",
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to add dimension for \"%s\" of size %" ST_ZU " in file ID %d",
                DIM_NCNT_CMAP, ncnt_cmap, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -298,7 +293,7 @@ file ID %d",
     if ((status = nc_def_var(exoid, VAR_N_COMM_NIDS, bulk_type, 1, n_dimid, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to add variable \"%s\" in file ID %d",
                VAR_N_COMM_NIDS, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -309,7 +304,7 @@ file ID %d",
     if ((status = nc_def_var(exoid, VAR_N_COMM_PROC, NC_INT, 1, n_dimid, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to add variable \"%s\" in file ID %d",
                VAR_N_COMM_PROC, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -329,7 +324,7 @@ file ID %d",
         NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to add variable \"%s\" in file ID %d",
                VAR_E_COMM_DATA_IDX, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -359,7 +354,7 @@ file ID %d",
     if ((status = nc_def_dim(exoid, DIM_ECNT_CMAP, ecnt_cmap, &e_dimid[0])) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to add dimension for \"%s\" in file ID %d",
                DIM_ECNT_CMAP, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -370,7 +365,7 @@ file ID %d",
     if ((status = nc_def_var(exoid, VAR_E_COMM_EIDS, bulk_type, 1, e_dimid, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to add variable \"%s\" in file ID %d",
                VAR_E_COMM_EIDS, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -381,7 +376,7 @@ file ID %d",
     if ((status = nc_def_var(exoid, VAR_E_COMM_PROC, NC_INT, 1, e_dimid, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to add variable \"%s\" in file ID %d",
                VAR_E_COMM_PROC, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -392,7 +387,7 @@ file ID %d",
     if ((status = nc_def_var(exoid, VAR_E_COMM_SIDS, bulk_type, 1, e_dimid, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to add variable \"%s\" in file ID %d",
                VAR_E_COMM_SIDS, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -413,7 +408,7 @@ file ID %d",
     if ((status = nc_inq_varid(exoid, VAR_N_COMM_STAT, &n_varid[0])) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
                VAR_N_COMM_STAT, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -421,7 +416,7 @@ file ID %d",
     if ((status = nc_inq_varid(exoid, VAR_N_COMM_IDS, &n_varid[1])) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
                VAR_N_COMM_IDS, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -467,7 +462,7 @@ file ID %d",
 
         if ((status = nc_put_var1_int(exoid, n_varid[0], start, &nmstat)) != NC_NOERR) {
           snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: unable to output variable in file ID %d", exoid);
-          ex_err(__func__, errmsg, status);
+          ex_err_fn(exoid, __func__, errmsg, status);
           EX_FUNC_LEAVE(EX_FATAL);
         }
 
@@ -480,7 +475,7 @@ file ID %d",
         if (status != NC_NOERR) {
           snprintf(errmsg, MAX_ERR_LENGTH,
                    "ERROR: failed to output int elem map index in file ID %d", exoid);
-          ex_err(__func__, errmsg, status);
+          ex_err_fn(exoid, __func__, errmsg, status);
           EX_FUNC_LEAVE(EX_FATAL);
         }
       } /* End "for(icm=0; icm < num_icm; icm++)" */
@@ -504,7 +499,7 @@ file ID %d",
         }
         if (status != NC_NOERR) {
           snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to output variable in file ID %d", exoid);
-          ex_err(__func__, errmsg, status);
+          ex_err_fn(exoid, __func__, errmsg, status);
 
           EX_FUNC_LEAVE(EX_FATAL);
         }
@@ -525,7 +520,7 @@ file ID %d",
     if ((status = nc_inq_varid(exoid, VAR_E_COMM_STAT, &e_varid[0])) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
                VAR_E_COMM_STAT, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -533,7 +528,7 @@ file ID %d",
     if ((status = nc_inq_varid(exoid, VAR_E_COMM_IDS, &e_varid[1])) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
                VAR_E_COMM_IDS, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -579,7 +574,7 @@ file ID %d",
 
         if ((status = nc_put_var1_int(exoid, e_varid[0], start, &nmstat)) != NC_NOERR) {
           snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: unable to output variable in file ID %d", exoid);
-          ex_err(__func__, errmsg, status);
+          ex_err_fn(exoid, __func__, errmsg, status);
           EX_FUNC_LEAVE(EX_FATAL);
         }
 
@@ -592,7 +587,7 @@ file ID %d",
         if (status != NC_NOERR) {
           snprintf(errmsg, MAX_ERR_LENGTH,
                    "ERROR: failed to output int elem map index in file ID %d", exoid);
-          ex_err(__func__, errmsg, status);
+          ex_err_fn(exoid, __func__, errmsg, status);
           EX_FUNC_LEAVE(EX_FATAL);
         }
       } /* End "for(icm=0; icm < num_icm; icm++)" */
@@ -616,7 +611,7 @@ file ID %d",
         }
         if (status != NC_NOERR) {
           snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to output variable in file ID %d", exoid);
-          ex_err(__func__, errmsg, status);
+          ex_err_fn(exoid, __func__, errmsg, status);
           EX_FUNC_LEAVE(EX_FATAL);
         }
       }
diff --git a/src/ex_put_concat_all_blocks.c b/src/ex_put_concat_all_blocks.c
index 221b6c2fa8f..8805bd16fb3 100644
--- a/src/ex_put_concat_all_blocks.c
+++ b/src/ex_put_concat_all_blocks.c
@@ -45,13 +45,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_def_var, etc
-#include <inttypes.h>     // for PRId64
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <stdlib.h>    // for NULL, free, malloc
-#include <string.h>    // for strlen
-#include <sys/types.h> // for int64_t
 
 /*!
  * writes the parameters used to describe all element, edge, and face blocks
@@ -127,7 +120,7 @@ int ex_put_concat_all_blocks(int exoid, const ex_block_params *param)
   /* inquire previously defined dimensions  */
   if ((status = nc_inq_dimid(exoid, DIM_STR_NAME, &strdim)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get string length in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -136,13 +129,13 @@ int ex_put_concat_all_blocks(int exoid, const ex_block_params *param)
       if ((status = nc_inq_dimid(exoid, dim_num_maps[i], &dimid)) != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find node map size of file id %d",
                  exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
       if ((status = nc_inq_dimlen(exoid, dimid, num_maps + i)) != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to retrieve node map size of file id %d",
                  exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
     }
@@ -160,7 +153,7 @@ int ex_put_concat_all_blocks(int exoid, const ex_block_params *param)
     if ((status = nc_inq_dimlen(exoid, dimid, &LNUMNAME)) != NC_NOERR) {                           \
       snprintf(errmsg, MAX_ERR_LENGTH,                                                             \
                "ERROR: failed to get number of " TNAME " blocks in file id %d", exoid);            \
-      ex_err(__func__, errmsg, status);                                                            \
+      ex_err_fn(exoid, __func__, errmsg, status);                                                  \
       EX_FUNC_LEAVE(EX_FATAL);                                                                     \
     }                                                                                              \
                                                                                                    \
@@ -169,7 +162,7 @@ int ex_put_concat_all_blocks(int exoid, const ex_block_params *param)
       snprintf(errmsg, MAX_ERR_LENGTH,                                                             \
                "ERROR: failed to allocate space for " TNAME " block status array in file id %d",   \
                exoid);                                                                             \
-      ex_err(__func__, errmsg, EX_MEMFAIL);                                                        \
+      ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);                                              \
       EX_FUNC_LEAVE(EX_FATAL);                                                                     \
     }                                                                                              \
                                                                                                    \
@@ -184,7 +177,7 @@ int ex_put_concat_all_blocks(int exoid, const ex_block_params *param)
     if ((status = nc_inq_varid(exoid, VSTATNAME, &varid)) != NC_NOERR) {                           \
       snprintf(errmsg, MAX_ERR_LENGTH,                                                             \
                "ERROR: failed to locate " TNAME " block status in file id %d", exoid);             \
-      ex_err(__func__, errmsg, status);                                                            \
+      ex_err_fn(exoid, __func__, errmsg, status);                                                  \
       free(GSTAT);                                                                                 \
       EX_FUNC_LEAVE(EX_FATAL);                                                                     \
     }                                                                                              \
@@ -194,7 +187,7 @@ int ex_put_concat_all_blocks(int exoid, const ex_block_params *param)
     if (status != NC_NOERR) {                                                                      \
       snprintf(errmsg, MAX_ERR_LENGTH,                                                             \
                "ERROR: failed to store " TNAME " block status array to file id %d", exoid);        \
-      ex_err(__func__, errmsg, status);                                                            \
+      ex_err_fn(exoid, __func__, errmsg, status);                                                  \
       free(GSTAT);                                                                                 \
       EX_FUNC_LEAVE(EX_FATAL);                                                                     \
     }                                                                                              \
@@ -206,7 +199,7 @@ int ex_put_concat_all_blocks(int exoid, const ex_block_params *param)
     if ((status = nc_inq_varid(exoid, VIDNAME, &varid)) != NC_NOERR) {                             \
       snprintf(errmsg, MAX_ERR_LENGTH,                                                             \
                "ERROR: failed to locate " TNAME " block ids array in file id %d", exoid);          \
-      ex_err(__func__, errmsg, status);                                                            \
+      ex_err_fn(exoid, __func__, errmsg, status);                                                  \
       EX_FUNC_LEAVE(EX_FATAL);                                                                     \
     }                                                                                              \
                                                                                                    \
@@ -221,7 +214,7 @@ int ex_put_concat_all_blocks(int exoid, const ex_block_params *param)
     if (status != NC_NOERR) {                                                                      \
       snprintf(errmsg, MAX_ERR_LENGTH,                                                             \
                "ERROR: failed to store " TNAME " block id array in file id %d", exoid);            \
-      ex_err(__func__, errmsg, status);                                                            \
+      ex_err_fn(exoid, __func__, errmsg, status);                                                  \
       EX_FUNC_LEAVE(EX_FATAL);                                                                     \
     }                                                                                              \
   }
@@ -242,7 +235,7 @@ int ex_put_concat_all_blocks(int exoid, const ex_block_params *param)
   /* put netcdf file into define mode  */
   if ((status = nc_redef(exoid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to place file id %d into define mode", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -254,7 +247,7 @@ int ex_put_concat_all_blocks(int exoid, const ex_block_params *param)
                "ERROR: failed to define number of attributes in " TNAME " block %" PRId64          \
                " in file id %d",                                                                   \
                ID, exoid);                                                                         \
-      ex_err(__func__, errmsg, status);                                                            \
+      ex_err_fn(exoid, __func__, errmsg, status);                                                  \
       goto error_ret; /* exit define mode and return */                                            \
     }                                                                                              \
                                                                                                    \
@@ -267,7 +260,7 @@ int ex_put_concat_all_blocks(int exoid, const ex_block_params *param)
                "ERROR:  failed to define attributes for " TNAME " block %" PRId64                  \
                " in file id %d",                                                                   \
                ID, exoid);                                                                         \
-      ex_err(__func__, errmsg, status);                                                            \
+      ex_err_fn(exoid, __func__, errmsg, status);                                                  \
       goto error_ret; /* exit define mode and return */                                            \
     }                                                                                              \
     ex_compress_variable(exoid, temp, 2);                                                          \
@@ -279,7 +272,7 @@ int ex_put_concat_all_blocks(int exoid, const ex_block_params *param)
     if ((status = nc_def_var(exoid, VANNAME(CURBLK + 1), NC_CHAR, 2, dims, &temp)) != NC_NOERR) {  \
       snprintf(errmsg, MAX_ERR_LENGTH,                                                             \
                "ERROR: failed to define " TNAME " attribute name array in file id %d", exoid);     \
-      ex_err(__func__, errmsg, status);                                                            \
+      ex_err_fn(exoid, __func__, errmsg, status);                                                  \
       goto error_ret; /* exit define mode and return */                                            \
     }                                                                                              \
     nc_def_var_fill(exoid, temp, 0, &fill);                                                        \
@@ -292,7 +285,7 @@ int ex_put_concat_all_blocks(int exoid, const ex_block_params *param)
                "ERROR: failed to define number of attributes in " TNAME " block %" PRId64          \
                " in file id %d",                                                                   \
                ID, exoid);                                                                         \
-      ex_err(__func__, errmsg, status);                                                            \
+      ex_err_fn(exoid, __func__, errmsg, status);                                                  \
       goto error_ret; /* exit define mode and return */                                            \
     }                                                                                              \
                                                                                                    \
@@ -305,7 +298,7 @@ int ex_put_concat_all_blocks(int exoid, const ex_block_params *param)
                "ERROR:  failed to define attributes for " TNAME " block %" PRId64                  \
                " in file id %d",                                                                   \
                ID, exoid);                                                                         \
-      ex_err(__func__, errmsg, status);                                                            \
+      ex_err_fn(exoid, __func__, errmsg, status);                                                  \
       goto error_ret; /* exit define mode and return */                                            \
     }                                                                                              \
     ex_compress_variable(exoid, temp, 2);                                                          \
@@ -317,7 +310,7 @@ int ex_put_concat_all_blocks(int exoid, const ex_block_params *param)
     if ((status = nc_def_var(exoid, VANNAME(CURBLK + 1), NC_CHAR, 2, dims, &temp)) != NC_NOERR) {  \
       snprintf(errmsg, MAX_ERR_LENGTH,                                                             \
                "ERROR: failed to define " TNAME " attribute name array in file id %d", exoid);     \
-      ex_err(__func__, errmsg, status);                                                            \
+      ex_err_fn(exoid, __func__, errmsg, status);                                                  \
       goto error_ret; /* exit define mode and return */                                            \
     }                                                                                              \
   }
@@ -338,7 +331,7 @@ int ex_put_concat_all_blocks(int exoid, const ex_block_params *param)
                "ERROR: failed to create " TNAME " connectivity array for block %" PRId64           \
                " in file id %d",                                                                   \
                BLKID, exoid);                                                                      \
-      ex_err(__func__, errmsg, status);                                                            \
+      ex_err_fn(exoid, __func__, errmsg, status);                                                  \
       goto error_ret; /* exit define mode and return */                                            \
     }                                                                                              \
     ex_compress_variable(exoid, connid, 1);                                                        \
@@ -359,7 +352,7 @@ int ex_put_concat_all_blocks(int exoid, const ex_block_params *param)
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: exceeded number of edge blocks (%ld) defined in file id %d",
                (long)num_edge_blk, exoid);
-      ex_err(__func__, errmsg, EX_BADPARAM);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
       goto error_ret;
     }
 
@@ -383,7 +376,7 @@ int ex_put_concat_all_blocks(int exoid, const ex_block_params *param)
                  "ERROR: failed to define number of edges/block for block %" PRId64 " file id %d",
                  eb_id, exoid);
       }
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       goto error_ret; /* exit define mode and return */
     }
 
@@ -392,7 +385,7 @@ int ex_put_concat_all_blocks(int exoid, const ex_block_params *param)
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to define number of nodes/edge for block %" PRId64 " in file id %d",
                eb_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       goto error_ret; /* exit define mode and return */
     }
 
@@ -407,7 +400,7 @@ int ex_put_concat_all_blocks(int exoid, const ex_block_params *param)
                                   (void *)param->edge_type[iblk])) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to store edge type name %s in file id %d",
                param->edge_type[iblk], exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       goto error_ret; /* exit define mode and return */
     }
   }
@@ -427,7 +420,7 @@ int ex_put_concat_all_blocks(int exoid, const ex_block_params *param)
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: exceeded number of face blocks (%ld) defined in file id %d",
                (long)num_face_blk, exoid);
-      ex_err(__func__, errmsg, EX_BADPARAM);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
       goto error_ret;
     }
 
@@ -451,7 +444,7 @@ int ex_put_concat_all_blocks(int exoid, const ex_block_params *param)
                  "ERROR: failed to define number of faces/block for block %" PRId64 " file id %d",
                  fb_id, exoid);
       }
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       goto error_ret; /* exit define mode and return */
     }
 
@@ -460,7 +453,7 @@ int ex_put_concat_all_blocks(int exoid, const ex_block_params *param)
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to define number of nodes/face for block %" PRId64 " in file id %d",
                fb_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       goto error_ret; /* exit define mode and return */
     }
 
@@ -475,7 +468,7 @@ int ex_put_concat_all_blocks(int exoid, const ex_block_params *param)
                                   (void *)param->face_type[iblk])) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to store face type name %s in file id %d",
                param->face_type[iblk], exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       goto error_ret; /* exit define mode and return */
     }
   }
@@ -496,7 +489,7 @@ int ex_put_concat_all_blocks(int exoid, const ex_block_params *param)
                "ERROR: exceeded number of element blocks (%ld) defined "
                "in file id %d",
                (long)num_elem_blk, exoid);
-      ex_err(__func__, errmsg, EX_BADPARAM);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
       goto error_ret;
     }
 
@@ -521,7 +514,7 @@ int ex_put_concat_all_blocks(int exoid, const ex_block_params *param)
                  "block %" PRId64 " file id %d",
                  eb_id, exoid);
       }
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       goto error_ret; /* exit define mode and return */
     }
 
@@ -534,7 +527,7 @@ int ex_put_concat_all_blocks(int exoid, const ex_block_params *param)
                "ERROR: failed to define number of nodes/element for block %" PRId64
                " in file id %d",
                eb_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       goto error_ret; /* exit define mode and return */
     }
 
@@ -545,7 +538,7 @@ int ex_put_concat_all_blocks(int exoid, const ex_block_params *param)
                  "ERROR: failed to define number of edges/element for block %" PRId64
                  " in file id %d",
                  eb_id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         goto error_ret; /* exit define mode and return */
       }
     }
@@ -557,7 +550,7 @@ int ex_put_concat_all_blocks(int exoid, const ex_block_params *param)
                  "ERROR: failed to define number of faces/element for block %" PRId64
                  " in file id %d",
                  eb_id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         goto error_ret; /* exit define mode and return */
       }
     }
@@ -572,7 +565,7 @@ int ex_put_concat_all_blocks(int exoid, const ex_block_params *param)
                                   (void *)param->elem_type[iblk])) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to store element type name %s in file id %d",
                param->elem_type[iblk], exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       goto error_ret; /* exit define mode and return */
     }
 
@@ -588,7 +581,7 @@ int ex_put_concat_all_blocks(int exoid, const ex_block_params *param)
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: could not find map size dimension %s in file id %d",
                  dim_size_maps[map_type], exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
       }
       for (i = 1; i <= num_maps[map_type]; ++i) {
         const char *mapname = ex_name_of_map(map_enums[map_type], i);
@@ -607,7 +600,7 @@ int ex_put_concat_all_blocks(int exoid, const ex_block_params *param)
               snprintf(errmsg, MAX_ERR_LENGTH,
                        "ERROR: failed to create number map array %s in file id %d", mapname, exoid);
             }
-            ex_err(__func__, errmsg, status);
+            ex_err_fn(exoid, __func__, errmsg, status);
             goto error_ret; /* exit define mode and return */
           }
           ex_compress_variable(exoid, temp, 1);
@@ -617,10 +610,7 @@ int ex_put_concat_all_blocks(int exoid, const ex_block_params *param)
   }
 
   /* leave define mode  */
-  if ((status = nc_enddef(exoid)) != NC_NOERR) {
-    snprintf(errmsg, MAX_ERR_LENGTH,
-             "ERROR: failed to complete element block definition in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+  if ((status = ex_leavedef(exoid, __func__)) != NC_NOERR) {
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -628,9 +618,6 @@ int ex_put_concat_all_blocks(int exoid, const ex_block_params *param)
 
 /* Fatal error: exit definition mode and return */
 error_ret:
-  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);
-  }
+  ex_leavedef(exoid, __func__);
   EX_FUNC_LEAVE(EX_FATAL);
 }
diff --git a/src/ex_put_concat_elem_block.c b/src/ex_put_concat_elem_block.c
index 5c2c5d57a18..1286ea173eb 100644
--- a/src/ex_put_concat_elem_block.c
+++ b/src/ex_put_concat_elem_block.c
@@ -49,13 +49,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_def_var, etc
-#include <inttypes.h>     // for PRId64
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <stdlib.h>    // for free, malloc
-#include <string.h>    // for strlen
-#include <sys/types.h> // for int64_t
 
 /*!
  * writes the parameters used to describe an element block
@@ -98,7 +91,7 @@ int ex_put_concat_elem_block(int exoid, const void_int *elem_blk_id, char *elem_
   if ((status = nc_inq_dimlen(exoid, dimid, &length)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get number of element blocks in file id %d",
              exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
   num_elem_blk = length;
@@ -109,7 +102,7 @@ int ex_put_concat_elem_block(int exoid, const void_int *elem_blk_id, char *elem_
              "ERROR: failed to allocate space for element block status "
              "array in file id %d",
              exoid);
-    ex_err(__func__, errmsg, EX_MEMFAIL);
+    ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -128,7 +121,7 @@ int ex_put_concat_elem_block(int exoid, const void_int *elem_blk_id, char *elem_
   if ((status = nc_inq_varid(exoid, VAR_STAT_EL_BLK, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate element block status in file id %d",
              exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     free(eb_array);
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -138,7 +131,7 @@ int ex_put_concat_elem_block(int exoid, const void_int *elem_blk_id, char *elem_
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to store element block status array to file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     free(eb_array);
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -148,7 +141,7 @@ int ex_put_concat_elem_block(int exoid, const void_int *elem_blk_id, char *elem_
   if ((status = nc_inq_varid(exoid, VAR_ID_EL_BLK, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to locate element block ids array in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     free(eb_array);
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -164,7 +157,7 @@ int ex_put_concat_elem_block(int exoid, const void_int *elem_blk_id, char *elem_
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to store element block id array in file id %d",
              exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     free(eb_array);
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -172,7 +165,7 @@ int ex_put_concat_elem_block(int exoid, const void_int *elem_blk_id, char *elem_
   /* inquire previously defined dimensions  */
   if ((status = nc_inq_dimid(exoid, DIM_STR_NAME, &strdim)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get string length in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     free(eb_array);
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -180,7 +173,7 @@ int ex_put_concat_elem_block(int exoid, const void_int *elem_blk_id, char *elem_
   /* put netcdf file into define mode  */
   if ((status = nc_redef(exoid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to place file id %d into define mode", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     free(eb_array);
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -219,7 +212,7 @@ int ex_put_concat_elem_block(int exoid, const void_int *elem_blk_id, char *elem_
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: exceeded number of element blocks (%d) defined in file id %d", num_elem_blk,
                exoid);
-      ex_err(__func__, errmsg, EX_BADPARAM);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
       goto error_ret;
     }
 
@@ -244,7 +237,7 @@ int ex_put_concat_elem_block(int exoid, const void_int *elem_blk_id, char *elem_
                  "block %" PRId64 " file id %d",
                  eb_id, exoid);
       }
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       goto error_ret; /* exit define mode and return */
     }
 
@@ -254,7 +247,7 @@ int ex_put_concat_elem_block(int exoid, const void_int *elem_blk_id, char *elem_
                "ERROR: failed to define number of nodes/element for block %" PRId64
                " in file id %d",
                eb_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       goto error_ret; /* exit define mode and return */
     }
 
@@ -267,7 +260,7 @@ int ex_put_concat_elem_block(int exoid, const void_int *elem_blk_id, char *elem_
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to create connectivity array for block %" PRId64 " in file id %d",
                eb_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       goto error_ret; /* exit define mode and return */
     }
     ex_compress_variable(exoid, connid, 1);
@@ -277,7 +270,7 @@ int ex_put_concat_elem_block(int exoid, const void_int *elem_blk_id, char *elem_
                                   (void *)elem_type[iblk])) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to store element type name %s in file id %d",
                elem_type[iblk], exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       goto error_ret; /* exit define mode and return */
     }
 
@@ -288,7 +281,7 @@ int ex_put_concat_elem_block(int exoid, const void_int *elem_blk_id, char *elem_
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to define number of attributes in block %" PRId64 " in file id %d",
                  eb_id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         goto error_ret; /* exit define mode and return */
       }
 
@@ -302,7 +295,7 @@ int ex_put_concat_elem_block(int exoid, const void_int *elem_blk_id, char *elem_
                  "ERROR: failed to define element attribute name array "
                  "in file id %d",
                  exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         goto error_ret; /* exit define mode and return */
       }
 #if NC_HAS_HDF5
@@ -318,7 +311,7 @@ int ex_put_concat_elem_block(int exoid, const void_int *elem_blk_id, char *elem_
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR:  failed to define attributes for element block %" PRId64 " in file id %d",
                  eb_id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         goto error_ret; /* exit define mode and return */
       }
     }
@@ -344,7 +337,7 @@ int ex_put_concat_elem_block(int exoid, const void_int *elem_blk_id, char *elem_
             snprintf(errmsg, MAX_ERR_LENGTH,
                      "ERROR: failed to create element numbering map in file id %d", exoid);
           }
-          ex_err(__func__, errmsg, status);
+          ex_err_fn(exoid, __func__, errmsg, status);
           goto error_ret; /* exit define mode and return */
         }
         ex_compress_variable(exoid, temp, 1);
@@ -368,7 +361,7 @@ int ex_put_concat_elem_block(int exoid, const void_int *elem_blk_id, char *elem_
                      "in file id %d",
                      exoid);
           }
-          ex_err(__func__, errmsg, status);
+          ex_err_fn(exoid, __func__, errmsg, status);
           goto error_ret; /* exit define mode and return */
         }
         ex_compress_variable(exoid, temp, 1);
@@ -377,10 +370,7 @@ int ex_put_concat_elem_block(int exoid, const void_int *elem_blk_id, char *elem_
   }
 
   /* leave define mode  */
-  if ((status = nc_enddef(exoid)) != NC_NOERR) {
-    snprintf(errmsg, MAX_ERR_LENGTH,
-             "ERROR: failed to complete element block definition in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+  if ((status = ex_leavedef(exoid, __func__)) != NC_NOERR) {
     free(eb_array);
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -419,9 +409,6 @@ int ex_put_concat_elem_block(int exoid, const void_int *elem_blk_id, char *elem_
 /* Fatal error: exit definition mode and return */
 error_ret:
   free(eb_array);
-  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);
-  }
+  ex_leavedef(exoid, __func__);
   EX_FUNC_LEAVE(EX_FATAL);
 }
diff --git a/src/ex_put_concat_sets.c b/src/ex_put_concat_sets.c
index c510fdb600b..1256829344a 100644
--- a/src/ex_put_concat_sets.c
+++ b/src/ex_put_concat_sets.c
@@ -51,12 +51,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, ex_comp_ws, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_def_dim, etc
-#include <inttypes.h>     // for PRId64
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <stdlib.h>    // for NULL, free, malloc
-#include <sys/types.h> // for int64_t
 
 /*!
  * writes the set ID's, set entry count array, set entry pointers array,
@@ -131,7 +125,7 @@ int ex_put_concat_sets(int exoid, ex_entity_type set_type, const struct ex_set_s
   }
   else {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: invalid set type (%d)", set_type);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -140,12 +134,12 @@ int ex_put_concat_sets(int exoid, ex_entity_type set_type, const struct ex_set_s
     if (status == NC_EBADDIM) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: no %ss defined for file id %d",
                ex_name_of_object(set_type), exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
     }
     else {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate %ss defined in file id %d",
                ex_name_of_object(set_type), exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
     }
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -156,7 +150,7 @@ int ex_put_concat_sets(int exoid, ex_entity_type set_type, const struct ex_set_s
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get number of %ss defined for file id %d",
              ex_name_of_object(set_type), exoid);
     /* use error val from inquire */
-    ex_err(__func__, errmsg, EX_LASTERR);
+    ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -167,7 +161,7 @@ int ex_put_concat_sets(int exoid, ex_entity_type set_type, const struct ex_set_s
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to allocate space for %s status array in file id %d",
              ex_name_of_object(set_type), exoid);
-    ex_err(__func__, errmsg, EX_MEMFAIL);
+    ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -186,7 +180,7 @@ int ex_put_concat_sets(int exoid, ex_entity_type set_type, const struct ex_set_s
   if ((status = nc_inq_varid(exoid, statptr, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate %s status in file id %d",
              ex_name_of_object(set_type), exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     free(set_stat);
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -196,7 +190,7 @@ int ex_put_concat_sets(int exoid, ex_entity_type set_type, const struct ex_set_s
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to store %s status array to file id %d",
              ex_name_of_object(set_type), exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     free(set_stat);
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -204,7 +198,7 @@ int ex_put_concat_sets(int exoid, ex_entity_type set_type, const struct ex_set_s
   /* put netcdf file into define mode  */
   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(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     free(set_stat);
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -228,7 +222,7 @@ int ex_put_concat_sets(int exoid, ex_entity_type set_type, const struct ex_set_s
     if (cur_num_sets >= num_sets) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: exceeded number of %ss (%d) defined in file id %d",
                ex_name_of_object(set_type), num_sets, exoid);
-      ex_err(__func__, errmsg, EX_BADPARAM);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
       goto error_ret;
     }
 
@@ -290,13 +284,13 @@ int ex_put_concat_sets(int exoid, ex_entity_type set_type, const struct ex_set_s
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: %s entry count %" PRId64 " already defined in file id %d",
                  ex_name_of_object(set_type), set_id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
       }
       else {
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to define number of entries for %s %" PRId64 " in file id %d",
                  ex_name_of_object(set_type), set_id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
       }
       goto error_ret;
     }
@@ -313,13 +307,13 @@ int ex_put_concat_sets(int exoid, ex_entity_type set_type, const struct ex_set_s
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: element list already exists for %s %" PRId64 " in file id %d",
                  ex_name_of_object(set_type), set_id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
       }
       else {
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to create element list for %s %" PRId64 " in file id %d",
                  ex_name_of_object(set_type), set_id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
       }
       goto error_ret; /* exit define mode and return */
     }
@@ -333,13 +327,13 @@ int ex_put_concat_sets(int exoid, ex_entity_type set_type, const struct ex_set_s
           snprintf(errmsg, MAX_ERR_LENGTH,
                    "ERROR: extra list already exists for %s %" PRId64 " in file id %d",
                    ex_name_of_object(set_type), set_id, exoid);
-          ex_err(__func__, errmsg, status);
+          ex_err_fn(exoid, __func__, errmsg, status);
         }
         else {
           snprintf(errmsg, MAX_ERR_LENGTH,
                    "ERROR: failed to create extra list for %s %" PRId64 " in file id %d",
                    ex_name_of_object(set_type), set_id, exoid);
-          ex_err(__func__, errmsg, status);
+          ex_err_fn(exoid, __func__, errmsg, status);
         }
         goto error_ret; /* exit define mode and return */
       }
@@ -365,7 +359,7 @@ int ex_put_concat_sets(int exoid, ex_entity_type set_type, const struct ex_set_s
                    "ERROR: # dist fact (%" ST_ZU ") not equal to # nodes (%" ST_ZU
                    ") in node set %" PRId64 " file id %d",
                    num_df, num_entry, set_id, exoid);
-          ex_err(__func__, errmsg, EX_BADPARAM);
+          ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
           goto error_ret; /* exit define mode and return */
         }
 
@@ -377,13 +371,13 @@ int ex_put_concat_sets(int exoid, ex_entity_type set_type, const struct ex_set_s
             snprintf(errmsg, MAX_ERR_LENGTH,
                      "ERROR: %s df count %" PRId64 " already defined in file id %d",
                      ex_name_of_object(set_type), set_id, exoid);
-            ex_err(__func__, errmsg, status);
+            ex_err_fn(exoid, __func__, errmsg, status);
           }
           else {
             snprintf(errmsg, MAX_ERR_LENGTH,
                      "ERROR: failed to define %s df count for set %" PRId64 " in file id %d",
                      ex_name_of_object(set_type), set_id, exoid);
-            ex_err(__func__, errmsg, status);
+            ex_err_fn(exoid, __func__, errmsg, status);
           }
           goto error_ret;
         }
@@ -396,13 +390,13 @@ int ex_put_concat_sets(int exoid, ex_entity_type set_type, const struct ex_set_s
           snprintf(errmsg, MAX_ERR_LENGTH,
                    "ERROR: dist factor list already exists for %s %" PRId64 " in file id %d",
                    ex_name_of_object(set_type), set_id, exoid);
-          ex_err(__func__, errmsg, status);
+          ex_err_fn(exoid, __func__, errmsg, status);
         }
         else {
           snprintf(errmsg, MAX_ERR_LENGTH,
                    "ERROR: failed to create dist factor list for %s %" PRId64 " in file id %d",
                    ex_name_of_object(set_type), set_id, exoid);
-          ex_err(__func__, errmsg, status);
+          ex_err_fn(exoid, __func__, errmsg, status);
         }
         goto error_ret; /* exit define mode and return */
       }
@@ -411,9 +405,7 @@ int ex_put_concat_sets(int exoid, ex_entity_type set_type, const struct ex_set_s
   }
 
   /* leave define mode  */
-  if ((status = nc_enddef(exoid)) != NC_NOERR) {
-    snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to complete definition in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+  if ((status = ex_leavedef(exoid, __func__)) != NC_NOERR) {
     free(set_stat);
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -424,7 +416,7 @@ int ex_put_concat_sets(int exoid, ex_entity_type set_type, const struct ex_set_s
   if ((status = nc_inq_varid(exoid, idsptr, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate %s ids array in file id %d",
              ex_name_of_object(set_type), exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     free(set_stat);
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -440,7 +432,7 @@ int ex_put_concat_sets(int exoid, ex_entity_type set_type, const struct ex_set_s
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to store %s id array in file id %d",
              ex_name_of_object(set_type), exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     free(set_stat);
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -514,7 +506,7 @@ int ex_put_concat_sets(int exoid, ex_entity_type set_type, const struct ex_set_s
                    "ERROR: failed to store %s %" PRId64 " dist factors for file id %d",
                    ex_name_of_object(set_type), set_id, exoid);
           /* use error val from exodusII routine */
-          ex_err(__func__, errmsg, EX_LASTERR);
+          ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
           free(set_stat);
           EX_FUNC_LEAVE(EX_FATAL);
         }
@@ -528,7 +520,7 @@ int ex_put_concat_sets(int exoid, ex_entity_type set_type, const struct ex_set_s
                    "ERROR: failed to store %s %" PRId64 " dist factors for file id %d",
                    ex_name_of_object(set_type), set_id, exoid);
           /* use error val from exodusII routine */
-          ex_err(__func__, errmsg, EX_LASTERR);
+          ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
           free(set_stat);
           EX_FUNC_LEAVE(EX_FATAL);
         }
@@ -539,7 +531,7 @@ int ex_put_concat_sets(int exoid, ex_entity_type set_type, const struct ex_set_s
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: unsupported floating point word size %d for file id %d", ex_comp_ws(exoid),
                exoid);
-      ex_err(__func__, errmsg, EX_BADPARAM);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
       free(set_stat);
       EX_FUNC_LEAVE(EX_FATAL);
     }
@@ -551,10 +543,6 @@ int ex_put_concat_sets(int exoid, ex_entity_type set_type, const struct ex_set_s
 error_ret:
   free(set_stat);
 
-  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);
-  }
+  ex_leavedef(exoid, __func__);
   EX_FUNC_LEAVE(EX_FATAL);
 }
diff --git a/src/ex_put_conn.c b/src/ex_put_conn.c
index 6cd50a79acf..5ae3f3f6185 100644
--- a/src/ex_put_conn.c
+++ b/src/ex_put_conn.c
@@ -35,26 +35,28 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, ex_id_lkup, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_inq_varid, etc
-#include <inttypes.h>     // for PRId64
-#include <stddef.h>       // for size_t
-#include <stdio.h>
 
 /*! write out the connectivity array */
-#define EX_WRITE_CONN(TNAME, VARCONN, VARCONNVAL)                                                  \
-  if (ex_int64_status(exoid) & EX_BULK_INT64_API) {                                                \
-    status = nc_put_var_longlong(exoid, VARCONN, VARCONNVAL);                                      \
-  }                                                                                                \
-  else {                                                                                           \
-    status = nc_put_var_int(exoid, VARCONN, VARCONNVAL);                                           \
-  }                                                                                                \
-  if (status != NC_NOERR) {                                                                        \
-    snprintf(errmsg, MAX_ERR_LENGTH,                                                               \
-             "ERROR: failed to write connectivity array for %s block %" PRId64 " in file id %d",   \
-             TNAME, blk_id, exoid);                                                                \
-    ex_err(__func__, errmsg, status);                                                              \
-    EX_FUNC_LEAVE(EX_FATAL);                                                                       \
+int ex_int_write_conn(int exoid, ex_entity_id blk_id, const char *type, int var_id,
+                      const void_int *var_conn)
+{
+  int status = 0;
+  if (ex_int64_status(exoid) & EX_BULK_INT64_API) {
+    status = nc_put_var_longlong(exoid, var_id, var_conn);
+  }
+  else {
+    status = nc_put_var_int(exoid, var_id, var_conn);
   }
+  if (status != NC_NOERR) {
+    char errmsg[MAX_ERR_LENGTH];
+    snprintf(errmsg, MAX_ERR_LENGTH,
+             "ERROR: failed to write connectivity array for %s block %" PRId64 " in file id %d",
+             type, blk_id, exoid);
+    ex_err_fn(exoid, __func__, errmsg, status);
+    return (status);
+  }
+  return status;
+}
 
 /*!
  * writes the connectivity array for a block
@@ -84,13 +86,13 @@ int ex_put_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id, const v
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "Warning: connectivity array not allowed for NULL %s %" PRId64 " in file id %d",
                  ex_name_of_object(blk_type), blk_id, exoid);
-        ex_err(__func__, errmsg, EX_NULLENTITY);
+        ex_err_fn(exoid, __func__, errmsg, EX_NULLENTITY);
         EX_FUNC_LEAVE(EX_WARN);
       }
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to locate %s id %" PRId64 " in id array in file id %d",
                ex_name_of_object(blk_type), blk_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -105,18 +107,21 @@ int ex_put_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id, const v
       snprintf(errmsg, MAX_ERR_LENGTH,
                "Internal ERROR: unrecognized block type in switch: %d in file id %d", blk_type,
                exoid);
-      ex_err(__func__, errmsg, EX_BADPARAM);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
       EX_FUNC_LEAVE(EX_FATAL);
     }
     if (status != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to locate connectivity array for %s %" PRId64 " in file id %d",
                ex_name_of_object(blk_type), blk_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
-    EX_WRITE_CONN(ex_name_of_object(blk_type), connid, node_conn);
+    status = ex_int_write_conn(exoid, blk_id, ex_name_of_object(blk_type), connid, node_conn);
+    if (status != NC_NOERR) {
+      EX_FUNC_LEAVE(EX_FATAL);
+    }
   }
 
   /* If there are edge and face connectivity arrays that belong with the element
@@ -134,7 +139,7 @@ int ex_put_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id, const v
                  "ERROR: edge connectivity specified but failed to "
                  "locate number of edges/element in block %" PRId64 " in file id %d",
                  blk_id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
     }
@@ -146,28 +151,28 @@ int ex_put_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id, const v
                  "ERROR: face connectivity specified but failed to "
                  "locate number of faces/element in block %" PRId64 " in file id %d",
                  blk_id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
     }
 
     num_ed_per_elem = 0;
     if ((elem_edge_conn != 0) &&
-        (status = nc_inq_dimlen(exoid, nedpereldim, &num_ed_per_elem) != NC_NOERR)) {
+        ((status = nc_inq_dimlen(exoid, nedpereldim, &num_ed_per_elem)) != NC_NOERR)) {
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to get number of edges/elem in block %" PRId64 " in file id %d",
                blk_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
     num_fa_per_elem = 0;
     if ((elem_face_conn != 0) &&
-        (status = nc_inq_dimlen(exoid, nfapereldim, &num_fa_per_elem) != NC_NOERR)) {
+        ((status = nc_inq_dimlen(exoid, nfapereldim, &num_fa_per_elem)) != NC_NOERR)) {
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to get number of faces/elem in block %" PRId64 " in file id %d",
                blk_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -177,7 +182,7 @@ int ex_put_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id, const v
                "ERROR: number of edges per element (%ld) doesn't "
                "agree with elem_edge_conn (0x%p)",
                (long)num_ed_per_elem, (void *)elem_edge_conn);
-      ex_err(__func__, errmsg, EX_BADPARAM);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -187,7 +192,7 @@ int ex_put_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id, const v
                "ERROR: number of faces per element (%ld) doesn't "
                "agree with elem_face_conn (0x%p)",
                (long)num_fa_per_elem, (void *)elem_face_conn);
-      ex_err(__func__, errmsg, EX_BADPARAM);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -198,10 +203,13 @@ int ex_put_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id, const v
                  "ERROR: failed to locate connectivity array for "
                  "element edge block %" PRId64 " in file id %d",
                  blk_id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
+        EX_FUNC_LEAVE(EX_FATAL);
+      }
+      status = ex_int_write_conn(exoid, blk_id, "element edge", connid, elem_edge_conn);
+      if (status != NC_NOERR) {
         EX_FUNC_LEAVE(EX_FATAL);
       }
-      EX_WRITE_CONN("element edge", connid, elem_edge_conn);
     }
 
     if (num_fa_per_elem != 0) {
@@ -211,10 +219,13 @@ int ex_put_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id, const v
                  "ERROR: failed to locate connectivity array for "
                  "element face block %" PRId64 " in file id %d",
                  blk_id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
+        EX_FUNC_LEAVE(EX_FATAL);
+      }
+      status = ex_int_write_conn(exoid, blk_id, "element face", connid, elem_face_conn);
+      if (status != NC_NOERR) {
         EX_FUNC_LEAVE(EX_FATAL);
       }
-      EX_WRITE_CONN("element face", connid, elem_face_conn);
     }
   }
 
diff --git a/src/ex_put_coord.c b/src/ex_put_coord.c
index c6f1c7eec72..822cd8bc54d 100644
--- a/src/ex_put_coord.c
+++ b/src/ex_put_coord.c
@@ -50,11 +50,8 @@
  *
  *****************************************************************************/
 
-#include "exodusII.h"     // for ex_err, etc
-#include "exodusII_int.h" // for EX_FATAL, ex_comp_ws, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_inq_varid, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
+#include "exodusII.h"
+#include "exodusII_int.h"
 
 /*!
 The function ex_put_coord() writes the nodal coordinates of the nodes
@@ -138,21 +135,21 @@ int ex_put_coord(int exoid, const void *x_coor, const void *y_coor, const void *
   if ((status = nc_inq_dimlen(exoid, numnoddim, &num_nod)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: inquire failed to return number of nodes in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
   if ((status = nc_inq_dimid(exoid, DIM_NUM_DIM, &ndimdim)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate number of dimensions in file id %d",
              exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
   if ((status = nc_inq_dimlen(exoid, ndimdim, &num_dim)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get number of dimensions in file id %d",
              exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -160,7 +157,7 @@ int ex_put_coord(int exoid, const void *x_coor, const void *y_coor, const void *
   if ((status = nc_inq_varid(exoid, VAR_COORD_X, &coordidx)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate x nodal coordinates in file id %d",
              exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -168,7 +165,7 @@ int ex_put_coord(int exoid, const void *x_coor, const void *y_coor, const void *
     if ((status = nc_inq_varid(exoid, VAR_COORD_Y, &coordidy)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate y nodal coordinates in file id %d",
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -179,7 +176,7 @@ int ex_put_coord(int exoid, const void *x_coor, const void *y_coor, const void *
     if ((status = nc_inq_varid(exoid, VAR_COORD_Z, &coordidz)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate z nodal coordinates in file id %d",
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -219,7 +216,7 @@ int ex_put_coord(int exoid, const void *x_coor, const void *y_coor, const void *
       if (status != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to put %s coord array in file id %d", which,
                  exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
     }
diff --git a/src/ex_put_coord_names.c b/src/ex_put_coord_names.c
index 37c1c999ab7..2cd0b696db8 100644
--- a/src/ex_put_coord_names.c
+++ b/src/ex_put_coord_names.c
@@ -35,9 +35,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_inq_dimid, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
 
 /*!
 
@@ -86,21 +83,21 @@ int ex_put_coord_names(int exoid, char *coord_names[])
   if ((status = nc_inq_dimid(exoid, DIM_NUM_DIM, &ndimdim)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate number of dimensions in file id %d",
              exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
   if ((status = nc_inq_dimlen(exoid, ndimdim, &num_dim)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: inquire failed to get number of dimensions in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
   if ((status = nc_inq_varid(exoid, VAR_NAME_COOR, &varid)) == -1) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate coordinate names in file id %d",
              exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
diff --git a/src/ex_put_coordinate_frames.c b/src/ex_put_coordinate_frames.c
index 649c3cadc5d..c48b3091cf4 100644
--- a/src/ex_put_coordinate_frames.c
+++ b/src/ex_put_coordinate_frames.c
@@ -53,10 +53,6 @@
 
 #include "exodusII.h"     // for ex_err, EXERRVAL, etc
 #include "exodusII_int.h" // for EX_FATAL, EX_NOERR, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_def_var, etc
-#include <assert.h>       // for assert
-#include <stdio.h>
-#include <string.h> // for strchr
 
 int ex_put_coordinate_frames(int exoid, int nframes, const void_int *cf_ids, void *pt_coordinates,
                              const char *tags)
@@ -94,7 +90,7 @@ int ex_put_coordinate_frames(int exoid, int nframes, const void_int *cf_ids, voi
   /* go into define mode. define num_frames, num_frames9 */
   if ((status = nc_redef(exoid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to place file id %d into define mode", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -102,7 +98,7 @@ int ex_put_coordinate_frames(int exoid, int nframes, const void_int *cf_ids, voi
       (nc_def_dim(exoid, DIM_NUM_CFRAME9, nframes * 9, &dim9) != NC_NOERR)) {
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to define number of coordinate frames in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     goto error_ret;
   }
 
@@ -117,15 +113,12 @@ int ex_put_coordinate_frames(int exoid, int nframes, const void_int *cf_ids, voi
       (nc_def_var(exoid, VAR_FRAME_TAGS, NC_CHAR, 1, &dim, &vartags) != NC_NOERR)) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR:  failed to define coordinate frames in file id %d",
              exoid);
-    ex_err(__func__, errmsg, EX_FATAL);
+    ex_err_fn(exoid, __func__, errmsg, EX_FATAL);
     goto error_ret; /* exit define mode and return */
   }
 
   /* leave define mode */
-  if ((status = nc_enddef(exoid)) != NC_NOERR) {
-    snprintf(errmsg, MAX_ERR_LENGTH,
-             "ERROR: failed to complete coordinate frame definition in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+  if ((status = ex_leavedef(exoid, __func__)) != NC_NOERR) {
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -134,7 +127,7 @@ int ex_put_coordinate_frames(int exoid, int nframes, const void_int *cf_ids, voi
     if (strchr("RrCcSs", tags[i]) == 0) {
       snprintf(errmsg, MAX_ERR_LENGTH, "Warning: Unrecognized coordinate frame tag: '%c'.",
                tags[i]);
-      ex_err(__func__, errmsg, 2);
+      ex_err_fn(exoid, __func__, errmsg, 2);
     }
   }
   /* could also check vectors. Leave this up to the application */
@@ -142,7 +135,7 @@ int ex_put_coordinate_frames(int exoid, int nframes, const void_int *cf_ids, voi
   /* put the variables into the file */
   if (nc_put_var_text(exoid, vartags, tags) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed writing frame data in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -155,7 +148,7 @@ int ex_put_coordinate_frames(int exoid, int nframes, const void_int *cf_ids, voi
 
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed writing frame data in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -168,16 +161,12 @@ int ex_put_coordinate_frames(int exoid, int nframes, const void_int *cf_ids, voi
 
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed writing frame data in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
   EX_FUNC_LEAVE(EX_NOERR);
 
 error_ret:
-  if ((status = nc_enddef(exoid)) != NC_NOERR) { /* exit define mode */
-    snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to complete frame definition for file id %d",
-             exoid);
-    ex_err(__func__, errmsg, status);
-  }
+  ex_leavedef(exoid, __func__);
   EX_FUNC_LEAVE(EX_FATAL);
 }
diff --git a/src/ex_put_eb_info_global.c b/src/ex_put_eb_info_global.c
index 6808aa9660c..614628ffe15 100644
--- a/src/ex_put_eb_info_global.c
+++ b/src/ex_put_eb_info_global.c
@@ -49,9 +49,6 @@
 /*****************************************************************************/
 /*****************************************************************************/
 /*****************************************************************************/
-#include <stdio.h>
-
-#include <vtk_netcdf.h>
 
 #include <exodusII.h>
 #include <exodusII_int.h>
@@ -68,7 +65,7 @@ int ex_put_eb_info_global(int exoid, void_int *el_blk_ids, void_int *el_blk_cnts
   if ((status = nc_inq_varid(exoid, VAR_ELBLK_IDS_GLOBAL, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
              VAR_ELBLK_IDS_GLOBAL, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -83,7 +80,7 @@ int ex_put_eb_info_global(int exoid, void_int *el_blk_ids, void_int *el_blk_cnts
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to output variable \"%s\" in file ID %d",
              VAR_ELBLK_IDS_GLOBAL, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -92,7 +89,7 @@ int ex_put_eb_info_global(int exoid, void_int *el_blk_ids, void_int *el_blk_cnts
   if ((status = nc_inq_varid(exoid, VAR_ELBLK_CNT_GLOBAL, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
              VAR_ELBLK_CNT_GLOBAL, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -107,7 +104,7 @@ int ex_put_eb_info_global(int exoid, void_int *el_blk_ids, void_int *el_blk_cnts
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to output variable \"%s\" in file ID %d",
              VAR_ELBLK_CNT_GLOBAL, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
diff --git a/src/ex_put_elem_cmap.c b/src/ex_put_elem_cmap.c
index 5a0de0a1612..977912a120e 100644
--- a/src/ex_put_elem_cmap.c
+++ b/src/ex_put_elem_cmap.c
@@ -56,10 +56,6 @@
 
 #include <exodusII.h>     // for ex_err, etc
 #include <exodusII_int.h> // for EX_FATAL, DIM_ECNT_CMAP, etc
-#include <vtk_netcdf.h>       // for NC_NOERR, nc_inq_varid, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <sys/types.h> // for int64_t
 
 int ex_put_elem_cmap(int exoid, ex_entity_id map_id, void_int *elem_ids, void_int *side_ids,
                      void_int *proc_ids, int processor)
@@ -79,7 +75,7 @@ int ex_put_elem_cmap(int exoid, ex_entity_id map_id, void_int *elem_ids, void_in
   if (ex_get_idx(exoid, VAR_E_COMM_INFO_IDX, varidx, processor) == -1) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find index variable, \"%s\", in file ID %d",
              VAR_E_COMM_INFO_IDX, exoid);
-    ex_err(__func__, errmsg, EX_LASTERR);
+    ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -89,7 +85,7 @@ int ex_put_elem_cmap(int exoid, ex_entity_id map_id, void_int *elem_ids, void_in
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to find index for variable \"%s\" in file ID %d", VAR_E_COMM_IDS,
              exoid);
-    ex_err(__func__, errmsg, EX_LASTERR);
+    ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -100,7 +96,7 @@ int ex_put_elem_cmap(int exoid, ex_entity_id map_id, void_int *elem_ids, void_in
   if ((status = nc_inq_varid(exoid, VAR_E_COMM_STAT, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
              VAR_E_COMM_STAT, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -108,7 +104,7 @@ int ex_put_elem_cmap(int exoid, ex_entity_id map_id, void_int *elem_ids, void_in
   if ((status = nc_get_var1_int(exoid, varid, start, &value)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get variable \"%s\" from file ID %d",
              VAR_E_COMM_STAT, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -120,7 +116,7 @@ int ex_put_elem_cmap(int exoid, ex_entity_id map_id, void_int *elem_ids, void_in
   if (ex_get_idx(exoid, VAR_E_COMM_DATA_IDX, varidx, map_idx) == -1) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find index variable, \"%s\", in file ID %d",
              VAR_E_COMM_DATA_IDX, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -131,7 +127,7 @@ int ex_put_elem_cmap(int exoid, ex_entity_id map_id, void_int *elem_ids, void_in
     if ((status = nc_inq_dimid(exoid, DIM_ECNT_CMAP, &dimid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get dimension ID for \"%s\" in file ID %d",
                DIM_ECNT_CMAP, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -139,7 +135,7 @@ int ex_put_elem_cmap(int exoid, ex_entity_id map_id, void_int *elem_ids, void_in
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to get length of dimension \"%s\" in file ID %d", DIM_ECNT_CMAP,
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -153,7 +149,7 @@ int ex_put_elem_cmap(int exoid, ex_entity_id map_id, void_int *elem_ids, void_in
   if ((status = nc_inq_varid(exoid, VAR_E_COMM_EIDS, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
              VAR_E_COMM_EIDS, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -166,7 +162,7 @@ int ex_put_elem_cmap(int exoid, ex_entity_id map_id, void_int *elem_ids, void_in
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to output vector \"%s\" in file ID %d",
              VAR_E_COMM_EIDS, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -174,7 +170,7 @@ int ex_put_elem_cmap(int exoid, ex_entity_id map_id, void_int *elem_ids, void_in
   if ((status = nc_inq_varid(exoid, VAR_E_COMM_PROC, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
              VAR_E_COMM_PROC, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -187,14 +183,14 @@ int ex_put_elem_cmap(int exoid, ex_entity_id map_id, void_int *elem_ids, void_in
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to output variable \"%s\" in file ID %d",
              VAR_E_COMM_PROC, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
   if ((status = nc_inq_varid(exoid, VAR_E_COMM_SIDS, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
              VAR_E_COMM_SIDS, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -207,7 +203,7 @@ int ex_put_elem_cmap(int exoid, ex_entity_id map_id, void_int *elem_ids, void_in
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to output variable \"%s\" in file ID %d",
              VAR_E_COMM_SIDS, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
   EX_FUNC_LEAVE(EX_NOERR);
diff --git a/src/ex_put_entity_count_per_polyhedra.c b/src/ex_put_entity_count_per_polyhedra.c
index 88cfb921d72..a4b9c9fd582 100644
--- a/src/ex_put_entity_count_per_polyhedra.c
+++ b/src/ex_put_entity_count_per_polyhedra.c
@@ -40,9 +40,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, ex_id_lkup, etc
-#include "vtk_netcdf.h"       // for nc_inq_varid, NC_NOERR, etc
-#include <inttypes.h>     // for PRId64
-#include <stdio.h>
 
 /*!
  * writes out the number of entities (nodes/faces) per polyhedra
@@ -72,14 +69,14 @@ int ex_put_entity_count_per_polyhedra(int exoid, ex_entity_type blk_type, ex_ent
                  "Warning: entity_counts array not allowed for NULL %s block %" PRId64
                  " in file id %d",
                  ex_name_of_object(blk_type), blk_id, exoid);
-        ex_err(__func__, errmsg, EX_NULLENTITY);
+        ex_err_fn(exoid, __func__, errmsg, EX_NULLENTITY);
         EX_FUNC_LEAVE(EX_WARN);
       }
 
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to locate %s block id %" PRId64 " in id array in file id %d",
                ex_name_of_object(blk_type), blk_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -92,14 +89,14 @@ int ex_put_entity_count_per_polyhedra(int exoid, ex_entity_type blk_type, ex_ent
     snprintf(errmsg, MAX_ERR_LENGTH,
              "Internal ERROR: unrecognized block type in switch: %d in file id %d", blk_type,
              exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to locate entity_counts array for %s block %" PRId64 " in file id %d",
              ex_name_of_object(blk_type), blk_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -108,7 +105,7 @@ int ex_put_entity_count_per_polyhedra(int exoid, ex_entity_type blk_type, ex_ent
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to write node counts array for %s block %" PRId64 " in file id %d",
              ex_name_of_object(blk_type), blk_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
   EX_FUNC_LEAVE(EX_NOERR);
diff --git a/src/ex_put_id_map.c b/src/ex_put_id_map.c
index fa3af0f5b13..cdec9f7bab2 100644
--- a/src/ex_put_id_map.c
+++ b/src/ex_put_id_map.c
@@ -51,8 +51,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, EX_NOERR, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_enddef, etc
-#include <stdio.h>
 
 /*!
  * writes out the entity numbering map to the database; this allows
@@ -99,7 +97,7 @@ int ex_put_id_map(int exoid, ex_entity_type map_type, const void_int *map)
   default:
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: Bad map type (%d) specified for file id %d", map_type,
              exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -112,7 +110,7 @@ int ex_put_id_map(int exoid, ex_entity_type map_type, const void_int *map)
   if (nc_inq_varid(exoid, vmap, &mapid) != 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(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -129,21 +127,19 @@ int ex_put_id_map(int exoid, ex_entity_type map_type, const void_int *map)
       if (status == NC_ENAMEINUSE) {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: %s numbering map already exists in file id %d",
                  tname, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
       }
       else {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to create %s id map in file id %d", tname,
                  exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
       }
       goto error_ret; /* exit define mode and return */
     }
     ex_compress_variable(exoid, mapid, 1);
 
     /* leave define mode  */
-    if ((status = nc_enddef(exoid)) != NC_NOERR) {
-      snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to complete definition in file id %d", exoid);
-      ex_err(__func__, errmsg, status);
+    if ((status = ex_leavedef(exoid, __func__)) != NC_NOERR) {
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -159,7 +155,7 @@ int ex_put_id_map(int exoid, ex_entity_type map_type, const void_int *map)
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to store %s numbering map in file id %d", tname,
              exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -167,10 +163,6 @@ int ex_put_id_map(int exoid, ex_entity_type map_type, const void_int *map)
 
 /* Fatal error: exit definition mode and return */
 error_ret:
-  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);
-  }
+  ex_leavedef(exoid, __func__);
   EX_FUNC_LEAVE(EX_FATAL);
 }
diff --git a/src/ex_put_info.c b/src/ex_put_info.c
index 1d18dd0da80..0f88ef0ee1d 100644
--- a/src/ex_put_info.c
+++ b/src/ex_put_info.c
@@ -35,10 +35,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, DIM_NUM_INFO, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_enddef, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <string.h> // for strlen, NULL
 
 /*!
 The function ex_put_info() writes information records to the
@@ -126,7 +122,7 @@ int ex_put_info(int exoid, int num_info, char *info[])
       /* 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);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
 
@@ -135,12 +131,12 @@ int ex_put_info(int exoid, int num_info, char *info[])
         if (status == NC_ENAMEINUSE) { /* duplicate entry? */
           snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: info records already exist in file id %d",
                    rootid);
-          ex_err(__func__, errmsg, status);
+          ex_err_fn(exoid, __func__, errmsg, status);
         }
         else {
           snprintf(errmsg, MAX_ERR_LENGTH,
                    "ERROR: failed to define number of info records in file id %d", rootid);
-          ex_err(__func__, errmsg, status);
+          ex_err_fn(exoid, __func__, errmsg, status);
         }
 
         goto error_ret; /* exit define mode and return */
@@ -150,7 +146,7 @@ int ex_put_info(int exoid, int num_info, char *info[])
       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);
+        ex_err_fn(exoid, __func__, errmsg, status);
         goto error_ret; /* exit define mode and return */
       }
 
@@ -161,16 +157,13 @@ int ex_put_info(int exoid, int num_info, char *info[])
       if ((status = nc_def_var(rootid, VAR_INFO, NC_CHAR, 2, dims, &varid)) != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define info record in file id %d",
                  rootid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         goto error_ret; /* exit define mode and return */
       }
       ex_compress_variable(rootid, varid, 3);
 
       /*   leave define mode  */
-      if ((status = nc_enddef(rootid)) != NC_NOERR) {
-        snprintf(errmsg, MAX_ERR_LENGTH,
-                 "ERROR: failed to complete info record definition in file id %d", rootid);
-        ex_err(__func__, errmsg, status);
+      if ((status = ex_leavedef(rootid, __func__)) != NC_NOERR) {
         EX_FUNC_LEAVE(EX_FATAL);
       }
     }
@@ -178,7 +171,7 @@ int ex_put_info(int exoid, int num_info, char *info[])
       if ((status = nc_inq_varid(rootid, VAR_INFO, &varid)) != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find info record variable in file id %d",
                  rootid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
     }
@@ -196,7 +189,7 @@ int ex_put_info(int exoid, int num_info, char *info[])
         if ((status = nc_put_vara_text(rootid, varid, start, count, info[i])) != NC_NOERR) {
           snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to store info record in file id %d",
                    rootid);
-          ex_err(__func__, errmsg, status);
+          ex_err_fn(exoid, __func__, errmsg, status);
           EX_FUNC_LEAVE(EX_FATAL);
         }
       }
@@ -216,9 +209,6 @@ int ex_put_info(int exoid, int num_info, char *info[])
 
 /* Fatal error: exit definition mode and return */
 error_ret:
-  if ((status = nc_enddef(rootid)) != NC_NOERR) { /* exit define mode */
-    snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to complete definition for file id %d", rootid);
-    ex_err(__func__, errmsg, status);
-  }
+  ex_leavedef(rootid, __func__);
   EX_FUNC_LEAVE(EX_FATAL);
 }
diff --git a/src/ex_put_init.c b/src/ex_put_init.c
index 7b2fc5bfedd..a55401737e1 100644
--- a/src/ex_put_init.c
+++ b/src/ex_put_init.c
@@ -34,8 +34,7 @@
  */
 
 #include "exodusII.h" // for ex_init_params, etc
-#include <stdint.h>   // for int64_t
-#include <string.h>   // for strncpy
+#include "exodusII_int.h"
 
 /*!
 
@@ -82,8 +81,7 @@ int ex_put_init(int exoid, const char *title, int64_t num_dim, int64_t num_nodes
 {
   ex_init_params par;
 
-  strncpy(par.title, title, 80);
-  par.title[80] = '\0';
+  ex_copy_string(par.title, title, MAX_LINE_LENGTH + 1);
 
   par.num_dim       = num_dim;
   par.num_nodes     = num_nodes;
diff --git a/src/ex_put_init_ext.c b/src/ex_put_init_ext.c
index c38f34f5458..dd7c29b7a89 100644
--- a/src/ex_put_init_ext.c
+++ b/src/ex_put_init_ext.c
@@ -51,11 +51,6 @@
 
 #include "exodusII.h"     // for ex_init_params, ex_err, etc
 #include "exodusII_int.h" // for nc_flt_code, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_def_dim, etc
-#include <stddef.h>       // for size_t, NULL
-#include <stdio.h>        // for snprintf
-#include <stdlib.h>       // for free, malloc
-#include <string.h>       // for strlen
 
 static void write_dummy_names(int exoid, ex_entity_type obj_type, int num)
 {
@@ -99,7 +94,7 @@ static int ex_write_object_names(int exoid, const char *type, const char *dimens
     if ((status = nc_def_var(exoid, dimension_name, NC_CHAR, 2, dim, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define %s name array in file id %d", type,
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       return (status); /* exit define mode and return */
     }
 #if NC_HAS_HDF5
@@ -124,7 +119,7 @@ static int ex_write_object_params(int exoid, const char *type, const char *dimen
     if ((status = nc_def_dim(exoid, dimension_name, count, dimension)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define number of %ss in file id %d", type,
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       return (status); /* exit define mode and return */
     }
     /* ...and some variables */
@@ -133,7 +128,7 @@ static int ex_write_object_params(int exoid, const char *type, const char *dimen
     if ((status = nc_def_var(exoid, status_dim_name, NC_INT, 1, dim, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define %s status array in file id %d",
                type, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       return (status); /* exit define mode and return */
     }
 
@@ -145,7 +140,7 @@ static int ex_write_object_params(int exoid, const char *type, const char *dimen
     if ((status = nc_def_var(exoid, id_array_dim_name, int_type, 1, dim, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define %s id array in file id %d", type,
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       return (status); /* exit define mode and return */
     }
 
@@ -153,7 +148,7 @@ static int ex_write_object_params(int exoid, const char *type, const char *dimen
     if ((status = nc_put_att_text(exoid, varid, ATT_PROP_NAME, 3, "ID")) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to store %s property name %s in file id %d",
                type, "ID", exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       return (status);
     }
   }
@@ -178,7 +173,7 @@ static int ex_write_map_params(int exoid, const char *map_name, const char *map_
     if ((status = nc_def_dim(exoid, map_dim_name, map_count, map_dimension)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define number of %ss in file id %d",
                map_name, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       return (status); /* exit define mode and return */
     }
 
@@ -188,7 +183,7 @@ static int ex_write_map_params(int exoid, const char *map_name, const char *map_
     if ((status = nc_def_var(exoid, map_id_name, int_type, 1, dim, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define %s id array in file id %d",
                map_name, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       return (status); /* exit define mode and return */
     }
 
@@ -196,7 +191,7 @@ static int ex_write_map_params(int exoid, const char *map_name, const char *map_
     if ((status = nc_put_att_text(exoid, varid, ATT_PROP_NAME, 3, "ID")) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to store %s property name %s in file id %d",
                map_name, "ID", exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       return (EX_FATAL);
     }
   }
@@ -255,14 +250,14 @@ int ex_put_init_ext(int exoid, const ex_init_params *model)
 
   if (rootid == exoid && nc_inq_dimid(exoid, DIM_NUM_DIM, &temp) == NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: initialization already done for file id %d", exoid);
-    ex_err(__func__, errmsg, EX_MSG);
+    ex_err_fn(exoid, __func__, errmsg, EX_MSG);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
   /* put file into define mode */
   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(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -272,7 +267,7 @@ int ex_put_init_ext(int exoid, const ex_init_params *model)
                                 model->title)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define model->title attribute to file id %d",
              rootid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     goto error_ret; /* exit define mode and return */
   }
 
@@ -283,14 +278,14 @@ int ex_put_init_ext(int exoid, const ex_init_params *model)
     if ((status = nc_def_dim(rootid, DIM_STR_NAME, NC_MAX_NAME, &dim_str_name)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define name string length in file id %d",
                rootid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       goto error_ret;
     }
   }
 
   if ((status = nc_def_dim(exoid, DIM_TIME, NC_UNLIMITED, &timedim)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define time dimension in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     goto error_ret;
   }
 
@@ -298,7 +293,7 @@ int ex_put_init_ext(int exoid, const ex_init_params *model)
   if ((status = nc_def_var(exoid, VAR_WHOLE_TIME, nc_flt_code(exoid), 1, dim, &temp)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to define whole time step variable in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     goto error_ret;
   }
   {
@@ -311,7 +306,7 @@ int ex_put_init_ext(int exoid, const ex_init_params *model)
     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);
+      ex_err_fn(exoid, __func__, errmsg, status);
       goto error_ret; /* exit define mode and return */
     }
   }
@@ -328,7 +323,7 @@ int ex_put_init_ext(int exoid, const ex_init_params *model)
     if ((status = nc_def_dim(exoid, DIM_NUM_NODES, model->num_nodes, &numnoddim)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define number of nodes in file id %d",
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       goto error_ret; /* exit define mode and return */
     }
   }
@@ -339,14 +334,14 @@ int ex_put_init_ext(int exoid, const ex_init_params *model)
                "ERROR: Cannot have non-zero element count if node count "
                "is zero.in file id %d",
                exoid);
-      ex_err(__func__, errmsg, EX_BADPARAM);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
       goto error_ret; /* exit define mode and return */
     }
 
     if ((status = nc_def_dim(exoid, DIM_NUM_ELEM, model->num_elem, &temp)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define number of elements in file id %d",
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       goto error_ret; /* exit define mode and return */
     }
   }
@@ -357,14 +352,14 @@ int ex_put_init_ext(int exoid, const ex_init_params *model)
                "ERROR: Cannot have non-zero edge count if node count is "
                "zero.in file id %d",
                exoid);
-      ex_err(__func__, errmsg, EX_BADPARAM);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
       goto error_ret; /* exit define mode and return */
     }
 
     if ((status = nc_def_dim(exoid, DIM_NUM_EDGE, model->num_edge, &temp)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define number of edges in file id %d",
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       goto error_ret; /* exit define mode and return */
     }
   }
@@ -375,14 +370,14 @@ int ex_put_init_ext(int exoid, const ex_init_params *model)
                "ERROR: Cannot have non-zero face count if node count is "
                "zero.in file id %d",
                exoid);
-      ex_err(__func__, errmsg, EX_BADPARAM);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
       goto error_ret; /* exit define mode and return */
     }
 
     if ((status = nc_def_dim(exoid, DIM_NUM_FACE, model->num_face, &temp)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define number of faces in file id %d",
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       goto error_ret; /* exit define mode and return */
     }
   }
@@ -445,7 +440,7 @@ int ex_put_init_ext(int exoid, const ex_init_params *model)
           NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to define node x coordinate array in file id %d", exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         goto error_ret; /* exit define mode and return */
       }
       ex_compress_variable(exoid, temp, 2);
@@ -456,7 +451,7 @@ int ex_put_init_ext(int exoid, const ex_init_params *model)
           NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to define node y coordinate array in file id %d", exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         goto error_ret; /* exit define mode and return */
       }
       ex_compress_variable(exoid, temp, 2);
@@ -467,7 +462,7 @@ int ex_put_init_ext(int exoid, const ex_init_params *model)
           NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to define node z coordinate array in file id %d", exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         goto error_ret; /* exit define mode and return */
       }
       ex_compress_variable(exoid, temp, 2);
@@ -530,10 +525,7 @@ int ex_put_init_ext(int exoid, const ex_init_params *model)
   }
 
   /* leave define mode */
-  if ((status = nc_enddef(exoid)) != NC_NOERR) {
-    snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to complete variable definitions in file id %d",
-             exoid);
-    ex_err(__func__, errmsg, status);
+  if ((status = ex_leavedef(exoid, __func__)) != NC_NOERR) {
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -579,7 +571,7 @@ int ex_put_init_ext(int exoid, const ex_init_params *model)
     if (!(invalid_ids = malloc(maxset * sizeof(int)))) {
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to allocate memory for id/status array for file id %d", exoid);
-      ex_err(__func__, errmsg, EX_MEMFAIL);
+      ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -597,10 +589,8 @@ int ex_put_init_ext(int exoid, const ex_init_params *model)
     invalidate_id_status(exoid, 0, VAR_FAM_PROP(1), model->num_face_maps, invalid_ids);
     invalidate_id_status(exoid, 0, VAR_EM_PROP(1), model->num_elem_maps, invalid_ids);
 
-    if (invalid_ids != NULL) {
-      free(invalid_ids);
-      invalid_ids = NULL;
-    }
+    free(invalid_ids);
+    invalid_ids = NULL;
   }
 
   /* Write dummy values to the names arrays to avoid corruption issues on some
@@ -622,10 +612,6 @@ int ex_put_init_ext(int exoid, const ex_init_params *model)
 
 /* Fatal error: exit definition mode and return */
 error_ret:
-  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);
-  }
+  ex_leavedef(exoid, __func__);
   EX_FUNC_LEAVE(EX_FATAL);
 }
diff --git a/src/ex_put_init_global.c b/src/ex_put_init_global.c
index 25c1ec2c655..cc6c988029e 100644
--- a/src/ex_put_init_global.c
+++ b/src/ex_put_init_global.c
@@ -60,9 +60,6 @@
 
 #include <exodusII.h>     // for ex_err, etc
 #include <exodusII_int.h> // for ex_leavedef, EX_FATAL, etc
-#include <vtk_netcdf.h>       // for nc_def_var, NC_NOERR, etc
-#include <stdio.h>
-#include <sys/types.h> // for int64_t
 
 int ex_put_init_global(int exoid, int64_t num_nodes_g, int64_t num_elems_g, int64_t num_elem_blks_g,
                        int64_t num_node_sets_g, int64_t num_side_sets_g)
@@ -86,7 +83,7 @@ int ex_put_init_global(int exoid, int64_t num_nodes_g, int64_t num_elems_g, int6
   /* Put NetCDF file into define mode */
   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(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -99,7 +96,7 @@ int ex_put_init_global(int exoid, int64_t num_nodes_g, int64_t num_elems_g, int6
   if ((status = nc_def_dim(exoid, DIM_NUM_NODES_GLOBAL, num_nodes_g, &dimid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to dimension \"%s\" in file ID %d",
              DIM_NUM_NODES_GLOBAL, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     /* Leave define mode before returning */
     ex_leavedef(exoid, __func__);
 
@@ -110,7 +107,7 @@ int ex_put_init_global(int exoid, int64_t num_nodes_g, int64_t num_elems_g, int6
   if ((status = nc_def_dim(exoid, DIM_NUM_ELEMS_GLOBAL, num_elems_g, &dimid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to dimension \"%s\" in file ID %d",
              DIM_NUM_ELEMS_GLOBAL, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     /* Leave define mode before returning */
     ex_leavedef(exoid, __func__);
 
@@ -125,7 +122,7 @@ int ex_put_init_global(int exoid, int64_t num_nodes_g, int64_t num_elems_g, int6
   if ((status = nc_def_dim(exoid, DIM_NUM_ELBLK_GLOBAL, num_elem_blks_g, &dimid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to dimension \"%s\" in file ID %d",
              DIM_NUM_ELBLK_GLOBAL, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     /* Leave define mode before returning */
     ex_leavedef(exoid, __func__);
 
@@ -137,7 +134,7 @@ int ex_put_init_global(int exoid, int64_t num_nodes_g, int64_t num_elems_g, int6
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to put variable definition for \"%s\" into file ID %d",
              VAR_ELBLK_IDS_GLOBAL, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     /* Leave define mode before returning */
     ex_leavedef(exoid, __func__);
 
@@ -149,7 +146,7 @@ int ex_put_init_global(int exoid, int64_t num_nodes_g, int64_t num_elems_g, int6
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to put variable definition for \"%s\" into file ID %d",
              VAR_ELBLK_CNT_GLOBAL, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     /* Leave define mode before returning */
     ex_leavedef(exoid, __func__);
 
@@ -165,7 +162,7 @@ int ex_put_init_global(int exoid, int64_t num_nodes_g, int64_t num_elems_g, int6
     if ((status = nc_def_dim(exoid, DIM_NUM_NS_GLOBAL, num_node_sets_g, &dimid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to dimension \"%s\" in file ID %d",
                DIM_NUM_NS_GLOBAL, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -177,7 +174,7 @@ int ex_put_init_global(int exoid, int64_t num_nodes_g, int64_t num_elems_g, int6
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to put variable definition for \"%s\" into file ID %d",
                VAR_NS_IDS_GLOBAL, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
 
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
@@ -191,7 +188,7 @@ int ex_put_init_global(int exoid, int64_t num_nodes_g, int64_t num_elems_g, int6
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to put variable definition for \"%s\" into file ID %d",
                VAR_NS_NODE_CNT_GLOBAL, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -207,7 +204,7 @@ int ex_put_init_global(int exoid, int64_t num_nodes_g, int64_t num_elems_g, int6
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to put variable definition for \"%s\" into file ID %d",
                VAR_NS_DF_CNT_GLOBAL, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -225,7 +222,7 @@ int ex_put_init_global(int exoid, int64_t num_nodes_g, int64_t num_elems_g, int6
     if ((status = nc_def_dim(exoid, DIM_NUM_SS_GLOBAL, num_side_sets_g, &dimid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to dimension \"%s\" in file id %d",
                DIM_NUM_SS_GLOBAL, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -237,7 +234,7 @@ int ex_put_init_global(int exoid, int64_t num_nodes_g, int64_t num_elems_g, int6
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to put variable definition for \"%s\" into file id %d",
                VAR_SS_IDS_GLOBAL, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
 
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
@@ -254,7 +251,7 @@ int ex_put_init_global(int exoid, int64_t num_nodes_g, int64_t num_elems_g, int6
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to put variable definition for \"%s\" into file id %d",
                VAR_SS_SIDE_CNT_GLOBAL, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
 
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
@@ -271,7 +268,7 @@ int ex_put_init_global(int exoid, int64_t num_nodes_g, int64_t num_elems_g, int6
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to put variable definition for \"%s\" into file id %d",
                VAR_SS_DF_CNT_GLOBAL, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
 
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
diff --git a/src/ex_put_init_info.c b/src/ex_put_init_info.c
index b883b687d91..1ae2ced7755 100644
--- a/src/ex_put_init_info.c
+++ b/src/ex_put_init_info.c
@@ -35,26 +35,22 @@
 /*****************************************************************************/
 /*****************************************************************************/
 /* Function(s) contained in this file:
- * 	ex_put_init_info()
+ *      ex_put_init_info()
  *****************************************************************************
  * This function writes information about the processors for which the
  * decomposition was performed.
  *****************************************************************************
  * Variable Index:
- *	exoid		  - The NetCDF ID of an already open NemesisI file.
- *	num_proc	  - The number of processors in the decomposition.
- *	num_proc_in_f	  - The number of processors the file contains
- *			    information for.
+ *      exoid             - The NetCDF ID of an already open NemesisI file.
+ *      num_proc          - The number of processors in the decomposition.
+ *      num_proc_in_f     - The number of processors the file contains
+ *                          information for.
  *      ftype             - The type of Nemesis file.
  */
 /*****************************************************************************/
 /*****************************************************************************/
 /*****************************************************************************/
 
-#include <stdio.h>
-
-#include <vtk_netcdf.h>
-
 #include <exodusII.h>
 #include <exodusII_int.h>
 
@@ -73,7 +69,7 @@ int ex_put_init_info(int exoid, int num_proc, int num_proc_in_f, char *ftype)
   /* Check the file type */
   if (!ftype) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: NULL file type input for file ID %d", exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -87,7 +83,7 @@ int ex_put_init_info(int exoid, int num_proc, int num_proc_in_f, char *ftype)
   }
   else {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: unknown file type requested for file ID %d", exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -95,7 +91,7 @@ int ex_put_init_info(int exoid, int num_proc, int num_proc_in_f, char *ftype)
   /* Put file into define mode */
   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(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -105,7 +101,7 @@ int ex_put_init_info(int exoid, int num_proc, int num_proc_in_f, char *ftype)
     if ((status = nc_def_dim(exoid, DIM_NUM_PROCS, ltempsv, &dimid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to dimension \"%s\" in file ID %d",
                DIM_NUM_PROCS, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -119,7 +115,7 @@ int ex_put_init_info(int exoid, int num_proc, int num_proc_in_f, char *ftype)
     if ((status = nc_def_dim(exoid, DIM_NUM_PROCS_F, ltempsv, &dimid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to dimension \"%s\" in file ID %d",
                DIM_NUM_PROCS_F, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
 
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
@@ -132,7 +128,7 @@ int ex_put_init_info(int exoid, int num_proc, int num_proc_in_f, char *ftype)
   if (nc_inq_varid(exoid, VAR_FILE_TYPE, &varid) != NC_NOERR) {
     if ((status = nc_def_var(exoid, VAR_FILE_TYPE, NC_INT, 0, NULL, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define file type in file ID %d", exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
 
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
@@ -147,7 +143,7 @@ int ex_put_init_info(int exoid, int num_proc, int num_proc_in_f, char *ftype)
     if ((status = nc_put_var1_int(exoid, varid, NULL, &lftype)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: unable to output file type variable in file ID %d",
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
 
       EX_FUNC_LEAVE(EX_FATAL);
     }
diff --git a/src/ex_put_loadbal_param.c b/src/ex_put_loadbal_param.c
index 4f48023b1d9..34c2fad4341 100644
--- a/src/ex_put_loadbal_param.c
+++ b/src/ex_put_loadbal_param.c
@@ -57,9 +57,6 @@
 
 #include <exodusII.h>     // for ex_err, etc
 #include <exodusII_int.h> // for ex_leavedef, EX_FATAL, etc
-#include <vtk_netcdf.h>       // for NC_NOERR, nc_def_var, etc
-#include <stdio.h>
-#include <sys/types.h> // for int64_t
 
 int ex_put_loadbal_param(int exoid, int64_t num_int_nodes, int64_t num_bor_nodes,
                          int64_t num_ext_nodes, int64_t num_int_elems, int64_t num_bor_elems,
@@ -82,7 +79,7 @@ int ex_put_loadbal_param(int exoid, int64_t num_int_nodes, int64_t num_bor_nodes
   if (ex_int64_status(exoid) & EX_MAPS_INT64_DB) {
     map_type = NC_INT64;
   }
-  (void)processor;
+  EX_UNUSED(processor);
   /*-----------------------------Execution begins-----------------------------*/
 
   EX_FUNC_ENTER();
@@ -91,7 +88,7 @@ int ex_put_loadbal_param(int exoid, int64_t num_int_nodes, int64_t num_bor_nodes
   /* Get the file type */
   if (ex_get_file_type(exoid, ftype) != EX_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get file type from file ID %d\n", exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -99,7 +96,7 @@ int ex_put_loadbal_param(int exoid, int64_t num_int_nodes, int64_t num_bor_nodes
   if (ftype[0] != 'p') {
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: function for use with parallel files only, file ID %d\n", exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -110,7 +107,7 @@ int ex_put_loadbal_param(int exoid, int64_t num_int_nodes, int64_t num_bor_nodes
   if ((status = nc_inq_dimid(exoid, DIM_NUM_PROCS_F, &dimid_npf)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find dimension ID for \"%s\" in file ID %d",
              DIM_NUM_PROCS_F, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     /* Leave define mode before returning */
     ex_leavedef(exoid, __func__);
@@ -121,7 +118,7 @@ int ex_put_loadbal_param(int exoid, int64_t num_int_nodes, int64_t num_bor_nodes
   /* Put NetCDF file into define mode */
   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(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -135,7 +132,7 @@ int ex_put_loadbal_param(int exoid, int64_t num_int_nodes, int64_t num_bor_nodes
     if ((status = nc_def_var(exoid, VAR_INT_N_STAT, NC_INT, 1, &dimid_npf, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
                VAR_INT_N_STAT, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -148,7 +145,7 @@ int ex_put_loadbal_param(int exoid, int64_t num_int_nodes, int64_t num_bor_nodes
     if ((status = nc_def_var(exoid, VAR_BOR_N_STAT, NC_INT, 1, &dimid_npf, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
                VAR_BOR_N_STAT, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -160,7 +157,7 @@ int ex_put_loadbal_param(int exoid, int64_t num_int_nodes, int64_t num_bor_nodes
     if ((status = nc_def_var(exoid, VAR_EXT_N_STAT, NC_INT, 1, &dimid_npf, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
                VAR_EXT_N_STAT, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -173,7 +170,7 @@ int ex_put_loadbal_param(int exoid, int64_t num_int_nodes, int64_t num_bor_nodes
     if ((status = nc_def_var(exoid, VAR_INT_E_STAT, NC_INT, 1, &dimid_npf, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
                VAR_INT_E_STAT, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -185,7 +182,7 @@ int ex_put_loadbal_param(int exoid, int64_t num_int_nodes, int64_t num_bor_nodes
     if ((status = nc_def_var(exoid, VAR_BOR_E_STAT, NC_INT, 1, &dimid_npf, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: Failed to define variable \"%s\" in file ID %d",
                VAR_BOR_E_STAT, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -197,7 +194,7 @@ int ex_put_loadbal_param(int exoid, int64_t num_int_nodes, int64_t num_bor_nodes
   if ((status = nc_inq_varid(exoid, VAR_INT_N_STAT, &varid_nm[0])) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
              VAR_INT_N_STAT, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     /* Leave define mode before returning */
     ex_leavedef(exoid, __func__);
 
@@ -207,7 +204,7 @@ int ex_put_loadbal_param(int exoid, int64_t num_int_nodes, int64_t num_bor_nodes
   if ((status = nc_inq_varid(exoid, VAR_BOR_N_STAT, &varid_nm[1])) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
              VAR_BOR_N_STAT, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     /* Leave define mode before returning */
     ex_leavedef(exoid, __func__);
 
@@ -217,7 +214,7 @@ int ex_put_loadbal_param(int exoid, int64_t num_int_nodes, int64_t num_bor_nodes
   if ((status = nc_inq_varid(exoid, VAR_EXT_N_STAT, &varid_nm[2])) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
              VAR_EXT_N_STAT, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     /* Leave define mode before returning */
     ex_leavedef(exoid, __func__);
 
@@ -230,7 +227,7 @@ int ex_put_loadbal_param(int exoid, int64_t num_int_nodes, int64_t num_bor_nodes
     if ((status = nc_def_dim(exoid, DIM_NUM_INT_ELEMS, ltempsv, &dimid[0])) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to dimension \"%s\" in file id %d",
                DIM_NUM_INT_ELEMS, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -240,7 +237,7 @@ int ex_put_loadbal_param(int exoid, int64_t num_int_nodes, int64_t num_bor_nodes
     if ((status = nc_def_var(exoid, VAR_ELEM_MAP_INT, map_type, 1, dimid, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
                VAR_ELEM_MAP_INT, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -254,7 +251,7 @@ int ex_put_loadbal_param(int exoid, int64_t num_int_nodes, int64_t num_bor_nodes
   if ((status = nc_inq_varid(exoid, VAR_INT_E_STAT, &varid_em[0])) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
              VAR_INT_E_STAT, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     /* Leave define mode before returning */
     ex_leavedef(exoid, __func__);
 
@@ -264,7 +261,7 @@ int ex_put_loadbal_param(int exoid, int64_t num_int_nodes, int64_t num_bor_nodes
   if ((status = nc_inq_varid(exoid, VAR_BOR_E_STAT, &varid_em[1])) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
              VAR_BOR_E_STAT, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     /* Leave define mode before returning */
     ex_leavedef(exoid, __func__);
 
@@ -277,7 +274,7 @@ int ex_put_loadbal_param(int exoid, int64_t num_int_nodes, int64_t num_bor_nodes
     if ((status = nc_def_dim(exoid, DIM_NUM_BOR_ELEMS, ltempsv, &dimid[0])) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to dimension \"%s\" in file id %d",
                DIM_NUM_BOR_ELEMS, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -287,7 +284,7 @@ int ex_put_loadbal_param(int exoid, int64_t num_int_nodes, int64_t num_bor_nodes
     if ((status = nc_def_var(exoid, VAR_ELEM_MAP_BOR, map_type, 1, dimid, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
                VAR_ELEM_MAP_BOR, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -303,7 +300,7 @@ int ex_put_loadbal_param(int exoid, int64_t num_int_nodes, int64_t num_bor_nodes
     if ((status = nc_def_dim(exoid, DIM_NUM_INT_NODES, ltempsv, &dimid[0])) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to dimension \"%s\" in file id %d",
                DIM_NUM_INT_NODES, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -314,7 +311,7 @@ int ex_put_loadbal_param(int exoid, int64_t num_int_nodes, int64_t num_bor_nodes
         NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
                VAR_NODE_MAP_INT, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -330,7 +327,7 @@ int ex_put_loadbal_param(int exoid, int64_t num_int_nodes, int64_t num_bor_nodes
     if ((status = nc_def_dim(exoid, DIM_NUM_BOR_NODES, ltempsv, &dimid[1])) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to dimension \"%s\" in file id %d",
                DIM_NUM_BOR_NODES, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -341,7 +338,7 @@ int ex_put_loadbal_param(int exoid, int64_t num_int_nodes, int64_t num_bor_nodes
         NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
                VAR_NODE_MAP_BOR, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -357,7 +354,7 @@ int ex_put_loadbal_param(int exoid, int64_t num_int_nodes, int64_t num_bor_nodes
     if ((status = nc_def_dim(exoid, DIM_NUM_EXT_NODES, ltempsv, &dimid[2])) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to dimension \"%s\" in file id %d",
                DIM_NUM_EXT_NODES, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -368,7 +365,7 @@ int ex_put_loadbal_param(int exoid, int64_t num_int_nodes, int64_t num_bor_nodes
         NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
                VAR_NODE_MAP_EXT, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -384,7 +381,7 @@ int ex_put_loadbal_param(int exoid, int64_t num_int_nodes, int64_t num_bor_nodes
     if ((status = nc_def_dim(exoid, DIM_NUM_N_CMAPS, ltempsv, &dimid[0])) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to add dimension \"%s\" in file ID %d",
                DIM_NUM_N_CMAPS, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -395,7 +392,7 @@ int ex_put_loadbal_param(int exoid, int64_t num_int_nodes, int64_t num_bor_nodes
     if ((status = nc_def_var(exoid, VAR_N_COMM_IDS, id_type, 1, dimid, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
                VAR_N_COMM_IDS, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -407,7 +404,7 @@ int ex_put_loadbal_param(int exoid, int64_t num_int_nodes, int64_t num_bor_nodes
     if ((status = nc_def_var(exoid, VAR_N_COMM_STAT, NC_INT, 1, dimid, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
                VAR_N_COMM_STAT, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -422,7 +419,7 @@ int ex_put_loadbal_param(int exoid, int64_t num_int_nodes, int64_t num_bor_nodes
     if ((status = nc_def_dim(exoid, DIM_NUM_E_CMAPS, ltempsv, &dimid[0])) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to add dimension \"%s\" in file ID %d",
                DIM_NUM_E_CMAPS, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -433,7 +430,7 @@ int ex_put_loadbal_param(int exoid, int64_t num_int_nodes, int64_t num_bor_nodes
     if ((status = nc_def_var(exoid, VAR_E_COMM_IDS, id_type, 1, dimid, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
                VAR_E_COMM_IDS, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -444,7 +441,7 @@ int ex_put_loadbal_param(int exoid, int64_t num_int_nodes, int64_t num_bor_nodes
     if ((status = nc_def_var(exoid, VAR_E_COMM_STAT, NC_INT, 1, dimid, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
                VAR_E_COMM_STAT, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -469,7 +466,7 @@ int ex_put_loadbal_param(int exoid, int64_t num_int_nodes, int64_t num_bor_nodes
     if ((status = nc_put_var_int(exoid, varid_nm[0], &nmstat)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to output status for int node map in file ID %d", exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -478,7 +475,7 @@ int ex_put_loadbal_param(int exoid, int64_t num_int_nodes, int64_t num_bor_nodes
     if ((status = nc_put_var_int(exoid, varid_nm[0], &nmstat)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to output status for int node map in file ID %d", exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -491,7 +488,7 @@ int ex_put_loadbal_param(int exoid, int64_t num_int_nodes, int64_t num_bor_nodes
     if ((status = nc_put_var_int(exoid, varid_nm[1], &nmstat)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to output status for bor node map in file ID %d", exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -501,7 +498,7 @@ int ex_put_loadbal_param(int exoid, int64_t num_int_nodes, int64_t num_bor_nodes
     if ((status = nc_put_var_int(exoid, varid_nm[1], &nmstat)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to output status for bor node map in file ID %d", exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -514,7 +511,7 @@ int ex_put_loadbal_param(int exoid, int64_t num_int_nodes, int64_t num_bor_nodes
     if ((status = nc_put_var_int(exoid, varid_nm[2], &nmstat)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to output status for ext node map in file ID %d", exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -524,7 +521,7 @@ int ex_put_loadbal_param(int exoid, int64_t num_int_nodes, int64_t num_bor_nodes
     if ((status = nc_put_var_int(exoid, varid_nm[2], &nmstat)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to output status for ext node map in file ID %d", exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -537,7 +534,7 @@ int ex_put_loadbal_param(int exoid, int64_t num_int_nodes, int64_t num_bor_nodes
     if ((status = nc_put_var_int(exoid, varid_em[0], &nmstat)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to output status for int elem map in file ID %d", exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -547,7 +544,7 @@ int ex_put_loadbal_param(int exoid, int64_t num_int_nodes, int64_t num_bor_nodes
     if ((status = nc_put_var_int(exoid, varid_em[0], &nmstat)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to output status for int elem map in file ID %d", exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -560,7 +557,7 @@ int ex_put_loadbal_param(int exoid, int64_t num_int_nodes, int64_t num_bor_nodes
     if ((status = nc_put_var_int(exoid, varid_em[1], &nmstat)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to output status for bor elem map in file ID %d", exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -570,7 +567,7 @@ int ex_put_loadbal_param(int exoid, int64_t num_int_nodes, int64_t num_bor_nodes
     if ((status = nc_put_var_int(exoid, varid_em[1], &nmstat)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to output status for bor elem map in file ID %d", exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
diff --git a/src/ex_put_loadbal_param_cc.c b/src/ex_put_loadbal_param_cc.c
index bc1f2c0d7fb..1c1fd75e9db 100644
--- a/src/ex_put_loadbal_param_cc.c
+++ b/src/ex_put_loadbal_param_cc.c
@@ -44,15 +44,15 @@
  *  Variable Index:
  *      exoid             - The NetCDF ID of an already open NemesisI file.
  *      num_int_nodes    - Vector of number of internal FEM nodes for
- *			   "num_proc_in_f" processors.
+ *                         "num_proc_in_f" processors.
  *      num_bor_nodes    - Vector of number of border FEM nodes for
- *			   "num_proc_in_f" processors.
+ *                         "num_proc_in_f" processors.
  *      num_ext_nodes    - Vector of number of external FEM nodes for
- *			   "num_proc_in_f" processors.
+ *                         "num_proc_in_f" processors.
  *      num_int_elems    - Vector of number of internal FEM elems for
- *			   "num_proc_in_f" processors.
+ *                         "num_proc_in_f" processors.
  *      num_bor_elems    - Vector of number of border FEM elems for
- *			   "num_proc_in_f" processors.
+ *                         "num_proc_in_f" processors.
  *      num_node_cmaps   - Vector of number of nodal communication maps
  *                         for "num_proc_in_f" processors.
  *      num_elem_cmaps   - Vector of number of elemental communication maps
@@ -64,10 +64,6 @@
 
 #include <exodusII.h>     // for ex_err, etc
 #include <exodusII_int.h> // for ex_leavedef, EX_FATAL, etc
-#include <vtk_netcdf.h>       // for NC_NOERR, nc_def_var, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <sys/types.h> // for int64_t
 
 #ifndef NC_INT64
 #define NC_INT64 NC_INT
@@ -127,7 +123,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
   /* Get the processor information from the file */
   if (ex_get_init_info(exoid, &num_proc, &num_proc_in_f, ftype) != EX_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: Unable to get processor info from file ID %d", exoid);
-    ex_err(__func__, errmsg, EX_MSG);
+    ex_err_fn(exoid, __func__, errmsg, EX_MSG);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -139,7 +135,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
   if ((status = nc_inq_dimid(exoid, DIM_NUM_PROCS_F, &dimid_npf)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find dimension ID for \"%s\" in file ID %d",
              DIM_NUM_PROCS_F, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -147,14 +143,14 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
   /* Put NetCDF file into define mode */
   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(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
   /* Set the fill mode */
   if ((status = nc_set_fill(exoid, NC_NOFILL, &oldfill)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to put file ID %d into no-fill mode", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -167,7 +163,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
   if (nc_inq_varid(exoid, VAR_FILE_TYPE, &varid) != NC_NOERR) {
     if ((status = nc_def_var(exoid, VAR_FILE_TYPE, NC_INT, 0, NULL, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define file type in file ID %d", exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
 
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
@@ -181,7 +177,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
     if ((status = nc_def_var(exoid, VAR_INT_N_STAT, NC_INT, 1, &dimid_npf, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
                VAR_INT_N_STAT, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -194,7 +190,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
     if ((status = nc_def_var(exoid, VAR_BOR_N_STAT, NC_INT, 1, &dimid_npf, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
                VAR_BOR_N_STAT, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -206,7 +202,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
     if ((status = nc_def_var(exoid, VAR_EXT_N_STAT, NC_INT, 1, &dimid_npf, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
                VAR_EXT_N_STAT, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -219,7 +215,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
     if ((status = nc_def_var(exoid, VAR_INT_E_STAT, NC_INT, 1, &dimid_npf, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
                VAR_INT_E_STAT, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -242,7 +238,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
   if ((status = nc_inq_varid(exoid, VAR_INT_N_STAT, &varid_nm[0])) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
              VAR_INT_N_STAT, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     /* Leave define mode before returning */
     ex_leavedef(exoid, __func__);
 
@@ -252,7 +248,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
   if ((status = nc_inq_varid(exoid, VAR_BOR_N_STAT, &varid_nm[1])) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
              VAR_BOR_N_STAT, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     /* Leave define mode before returning */
     ex_leavedef(exoid, __func__);
 
@@ -262,7 +258,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
   if ((status = nc_inq_varid(exoid, VAR_EXT_N_STAT, &varid_nm[2])) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
              VAR_EXT_N_STAT, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     /* Leave define mode before returning */
     ex_leavedef(exoid, __func__);
 
@@ -273,7 +269,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
   if ((status = nc_inq_varid(exoid, VAR_INT_E_STAT, &varid_em[0])) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
              VAR_INT_E_STAT, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     /* Leave define mode before returning */
     ex_leavedef(exoid, __func__);
 
@@ -283,7 +279,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
   if ((status = nc_inq_varid(exoid, VAR_BOR_E_STAT, &varid_em[1])) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
              VAR_BOR_E_STAT, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     /* Leave define mode before returning */
     ex_leavedef(exoid, __func__);
 
@@ -323,7 +319,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
     if ((status = nc_def_dim(exoid, DIM_NUM_INT_ELEMS, num_int_elem, &dimid[0])) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to dimension \"%s\" in file id %d",
                DIM_NUM_INT_ELEMS, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -333,7 +329,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
     if ((status = nc_def_var(exoid, VAR_ELEM_MAP_INT, map_type, 1, dimid, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
                VAR_ELEM_MAP_INT, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -346,7 +342,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
                              &varid_idx[0])) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
                VAR_ELEM_MAP_INT_IDX, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -359,7 +355,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
     if ((status = nc_def_dim(exoid, DIM_NUM_BOR_ELEMS, num_bor_elem, &dimid[0])) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to dimension \"%s\" in file id %d",
                DIM_NUM_BOR_ELEMS, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -369,7 +365,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
     if ((status = nc_def_var(exoid, VAR_ELEM_MAP_BOR, map_type, 1, dimid, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
                VAR_ELEM_MAP_BOR, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -382,7 +378,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
                              &varid_idx[1])) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
                VAR_ELEM_MAP_BOR_IDX, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -396,7 +392,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
     if ((status = nc_def_dim(exoid, DIM_NUM_INT_NODES, num_int_node, &dimid[0])) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to dimension \"%s\" in file id %d",
                DIM_NUM_INT_NODES, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -407,7 +403,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
         NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
                VAR_NODE_MAP_INT, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -420,7 +416,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
                              &varid_idx[2])) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
                VAR_NODE_MAP_INT_IDX, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -434,7 +430,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
     if ((status = nc_def_dim(exoid, DIM_NUM_BOR_NODES, num_bor_node, &dimid[1])) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to dimension \"%s\" in file id %d",
                DIM_NUM_BOR_NODES, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -445,7 +441,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
         NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
                VAR_NODE_MAP_BOR, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -458,7 +454,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
                              &varid_idx[3])) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
                VAR_NODE_MAP_BOR_IDX, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -472,7 +468,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
     if ((status = nc_def_dim(exoid, DIM_NUM_EXT_NODES, num_ext_node, &dimid[2])) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to dimension \"%s\" in file id %d",
                DIM_NUM_EXT_NODES, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -483,7 +479,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
         NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
                VAR_NODE_MAP_EXT, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -496,7 +492,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
                              &varid_idx[4])) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
                VAR_NODE_MAP_EXT_IDX, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -510,7 +506,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
     if ((status = nc_def_dim(exoid, DIM_NUM_N_CMAPS, num_n_cmaps, &dimid[0])) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to add dimension \"%s\" in file ID %d",
                DIM_NUM_N_CMAPS, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -521,7 +517,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
     if ((status = nc_def_var(exoid, VAR_N_COMM_IDS, id_type, 1, dimid, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
                VAR_N_COMM_IDS, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -531,7 +527,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
     if ((status = nc_def_var(exoid, VAR_N_COMM_STAT, NC_INT, 1, dimid, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
                VAR_N_COMM_STAT, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -543,7 +539,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
                              &varid_idx[5])) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
                VAR_N_COMM_INFO_IDX, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -556,7 +552,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
     if ((status = nc_def_dim(exoid, DIM_NUM_E_CMAPS, num_e_cmaps, &dimid[0])) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to add dimension \"%s\" in file ID %d",
                DIM_NUM_E_CMAPS, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -567,7 +563,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
     if ((status = nc_def_var(exoid, VAR_E_COMM_IDS, id_type, 1, dimid, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
                VAR_E_COMM_IDS, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -577,7 +573,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
     if ((status = nc_def_var(exoid, VAR_E_COMM_STAT, NC_INT, 1, dimid, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
                VAR_E_COMM_STAT, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -589,7 +585,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
                              &varid_idx[6])) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define variable \"%s\" in file ID %d",
                VAR_E_COMM_INFO_IDX, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       /* Leave define mode before returning */
       ex_leavedef(exoid, __func__);
 
@@ -652,7 +648,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
     if ((status = nc_put_var1_int(exoid, varid_nm[0], start, &nmstat)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to output status int node map in file ID %d",
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -666,7 +662,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
     if ((status = nc_put_var1_int(exoid, varid_nm[1], start, &nmstat)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to output status bor node map in file ID %d",
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -680,7 +676,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
     if ((status = nc_put_var1_int(exoid, varid_nm[2], start, &nmstat)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to output status ext node map in file ID %d",
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -694,7 +690,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
     if ((status = nc_put_var1_int(exoid, varid_em[0], start, &nmstat)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to output status int elem map in file ID %d",
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -708,7 +704,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
     if ((status = nc_put_var1_int(exoid, varid_em[1], start, &nmstat)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to output status bor elem map in file ID %d",
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -724,7 +720,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
       if (status != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to output internal element map index in file ID %d", exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
     }
@@ -740,7 +736,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
       if (status != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to output border element map index in file ID %d", exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
     }
@@ -756,7 +752,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
       if (status != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to output internal node map index in file ID %d", exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
     }
@@ -772,7 +768,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
       if (status != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to output border node map index in file ID %d", exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
     }
@@ -788,7 +784,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
       if (status != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to output external node map index in file ID %d", exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
     }
@@ -806,7 +802,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
                  "ERROR: failed to output node communication map index "
                  "in file ID %d",
                  exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
     }
@@ -824,7 +820,7 @@ int ex_put_loadbal_param_cc(int exoid, void_int *num_int_nodes, void_int *num_bo
                  "ERROR: failed to output elem communication map index "
                  "in file ID %d",
                  exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
     }
diff --git a/src/ex_put_map.c b/src/ex_put_map.c
index e8456848715..de33b200353 100644
--- a/src/ex_put_map.c
+++ b/src/ex_put_map.c
@@ -50,8 +50,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, EX_NOERR, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_enddef, etc
-#include <stdio.h>
 
 /*!
 The function ex_put_map() writes out the optional element order map to
@@ -104,7 +102,7 @@ int ex_put_map(int exoid, const void_int *elem_map)
   /* put netcdf file into define mode  */
   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(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -119,21 +117,19 @@ int ex_put_map(int exoid, const void_int *elem_map)
   if ((status = nc_def_var(exoid, VAR_MAP, map_int_type, 1, dims, &mapid)) != NC_NOERR) {
     if (status == NC_ENAMEINUSE) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: element map already exists in file id %d", exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
     }
     else {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to create element map array in file id %d",
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
     }
     goto error_ret; /* exit define mode and return */
   }
   ex_compress_variable(exoid, mapid, 1);
 
   /* leave define mode  */
-  if ((status = nc_enddef(exoid)) != NC_NOERR) {
-    snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to complete definition in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+  if ((status = ex_leavedef(exoid, __func__)) != NC_NOERR) {
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -147,7 +143,7 @@ int ex_put_map(int exoid, const void_int *elem_map)
 
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to store element map in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -155,10 +151,6 @@ int ex_put_map(int exoid, const void_int *elem_map)
 
 /* Fatal error: exit definition mode and return */
 error_ret:
-  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);
-  }
+  ex_leavedef(exoid, __func__);
   EX_FUNC_LEAVE(EX_FATAL);
 }
diff --git a/src/ex_put_map_param.c b/src/ex_put_map_param.c
index 78abbbd0b43..2b14cfe0173 100644
--- a/src/ex_put_map_param.c
+++ b/src/ex_put_map_param.c
@@ -49,10 +49,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_def_var, etc
-#include <assert.h>       // for assert
-#include <stdio.h>
-#include <stdlib.h> // for free, malloc
 
 /*!
  * defines the number of node and element maps. It is more efficient
@@ -91,7 +87,7 @@ int ex_put_map_param(int exoid, int num_node_maps, int num_elem_maps)
   if ((num_node_maps > 0 && ((nc_inq_dimid(exoid, DIM_NUM_NM, &dimid)) == NC_NOERR)) ||
       (num_elem_maps > 0 && ((nc_inq_dimid(exoid, DIM_NUM_EM, &dimid)) == NC_NOERR))) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: number of maps already defined for file id %d", exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -100,14 +96,14 @@ int ex_put_map_param(int exoid, int num_node_maps, int num_elem_maps)
     /* inquire previously defined dimensions  */
     if ((status = nc_inq_dimid(exoid, DIM_STR_NAME, &strdim)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get string length in file id %d", exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
     /* put file into define mode */
     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(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -117,7 +113,7 @@ int ex_put_map_param(int exoid, int num_node_maps, int num_elem_maps)
       if ((status = nc_def_dim(exoid, DIM_NUM_NM, num_node_maps, &dimid)) != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to define number of node maps in file id %d", exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         goto error_ret; /* exit define mode and return */
       }
 
@@ -126,7 +122,7 @@ int ex_put_map_param(int exoid, int num_node_maps, int num_elem_maps)
       if ((status = nc_def_var(exoid, VAR_NM_PROP(1), id_type, 1, dim, &var_nm_id)) != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to create node maps property array in file id %d", exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         goto error_ret; /* exit define mode and return */
       }
 
@@ -134,7 +130,7 @@ int ex_put_map_param(int exoid, int num_node_maps, int num_elem_maps)
       if ((status = nc_put_att_text(exoid, var_nm_id, ATT_PROP_NAME, 3, "ID")) != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to store node map property name %s in file id %d", "ID", exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         goto error_ret; /* exit define mode and return */
       }
 
@@ -145,7 +141,7 @@ int ex_put_map_param(int exoid, int num_node_maps, int num_elem_maps)
       if (nc_def_var(exoid, VAR_NAME_NM, NC_CHAR, 2, dim, &varid) != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to define node map name array in file id %d", exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         goto error_ret; /* exit define mode and return */
       }
 #if NC_HAS_HDF5
@@ -156,7 +152,7 @@ int ex_put_map_param(int exoid, int num_node_maps, int num_elem_maps)
       if ((status = nc_inq_dimid(exoid, DIM_NUM_NODES, &dimid)) != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: couldn't determine number of nodes in file id %d",
                  exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         goto error_ret; /* exit define mode and return */
       }
 
@@ -169,12 +165,12 @@ int ex_put_map_param(int exoid, int num_node_maps, int num_elem_maps)
           if (status == NC_ENAMEINUSE) {
             snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: node map %d already defined in file id %d", i,
                      exoid);
-            ex_err(__func__, errmsg, status);
+            ex_err_fn(exoid, __func__, errmsg, status);
           }
           else {
             snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to create node map %d in file id %d", i,
                      exoid);
-            ex_err(__func__, errmsg, status);
+            ex_err_fn(exoid, __func__, errmsg, status);
           }
           goto error_ret; /* exit define mode and return */
         }
@@ -187,7 +183,7 @@ int ex_put_map_param(int exoid, int num_node_maps, int num_elem_maps)
       if ((status = nc_def_dim(exoid, DIM_NUM_EM, num_elem_maps, &dimid)) != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to define number of element maps in file id %d", exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         goto error_ret; /* exit define mode and return */
       }
 
@@ -196,7 +192,7 @@ int ex_put_map_param(int exoid, int num_node_maps, int num_elem_maps)
       if ((status = nc_def_var(exoid, VAR_EM_PROP(1), id_type, 1, dim, &var_em_id)) != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to create element maps property array in file id %d", exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         goto error_ret; /* exit define mode and return */
       }
 
@@ -204,7 +200,7 @@ int ex_put_map_param(int exoid, int num_node_maps, int num_elem_maps)
       if ((status = nc_put_att_text(exoid, var_em_id, ATT_PROP_NAME, 3, "ID")) != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to store element map property name %s in file id %d", "ID", exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         goto error_ret; /* exit define mode and return */
       }
 
@@ -215,7 +211,7 @@ int ex_put_map_param(int exoid, int num_node_maps, int num_elem_maps)
       if ((status = nc_def_var(exoid, VAR_NAME_EM, NC_CHAR, 2, dim, &varid)) != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to define element map name array in file id %d", exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         goto error_ret; /* exit define mode and return */
       }
 #if NC_HAS_HDF5
@@ -226,7 +222,7 @@ int ex_put_map_param(int exoid, int num_node_maps, int num_elem_maps)
       if ((status = nc_inq_dimid(exoid, DIM_NUM_ELEM, &dimid)) != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: couldn't determine number of elements in file id %d", exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         goto error_ret; /* exit define mode and return */
       }
 
@@ -238,12 +234,12 @@ int ex_put_map_param(int exoid, int num_node_maps, int num_elem_maps)
           if (status == NC_ENAMEINUSE) {
             snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: element map %d already defined in file id %d",
                      i, exoid);
-            ex_err(__func__, errmsg, status);
+            ex_err_fn(exoid, __func__, errmsg, status);
           }
           else {
             snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to create element map %d in file id %d",
                      i, exoid);
-            ex_err(__func__, errmsg, status);
+            ex_err_fn(exoid, __func__, errmsg, status);
           }
           goto error_ret; /* exit define mode and return */
         }
@@ -252,10 +248,7 @@ int ex_put_map_param(int exoid, int num_node_maps, int num_elem_maps)
     }
 
     /* leave define mode */
-    if ((status = nc_enddef(exoid)) != NC_NOERR) {
-      snprintf(errmsg, MAX_ERR_LENGTH,
-               "ERROR: failed to complete variable definitions in file id %d", exoid);
-      ex_err(__func__, errmsg, status);
+    if ((status = ex_leavedef(exoid, __func__)) != NC_NOERR) {
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -268,7 +261,7 @@ int ex_put_map_param(int exoid, int num_node_maps, int num_elem_maps)
                  "ERROR: failed to allocate memory for invalid id "
                  "storage in file id %d",
                  exoid);
-        ex_err(__func__, errmsg, EX_MEMFAIL);
+        ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
         EX_FUNC_LEAVE(EX_FATAL);
       }
       for (i = 0; i < maxset; i++) {
@@ -278,7 +271,7 @@ int ex_put_map_param(int exoid, int num_node_maps, int num_elem_maps)
         if ((status = nc_put_var_int(exoid, var_nm_id, invalid_ids)) != NC_NOERR) {
           snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to output node map ids in file id %d",
                    exoid);
-          ex_err(__func__, errmsg, status);
+          ex_err_fn(exoid, __func__, errmsg, status);
           free(invalid_ids);
           EX_FUNC_LEAVE(EX_FATAL);
         }
@@ -287,7 +280,7 @@ int ex_put_map_param(int exoid, int num_node_maps, int num_elem_maps)
         if ((status = nc_put_var_int(exoid, var_em_id, invalid_ids)) != NC_NOERR) {
           snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to output element map ids in file id %d",
                    exoid);
-          ex_err(__func__, errmsg, status);
+          ex_err_fn(exoid, __func__, errmsg, status);
           free(invalid_ids);
           EX_FUNC_LEAVE(EX_FATAL);
         }
@@ -300,10 +293,6 @@ int ex_put_map_param(int exoid, int num_node_maps, int num_elem_maps)
 
 /* Fatal error: exit definition mode and return */
 error_ret:
-  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);
-  }
+  ex_leavedef(exoid, __func__);
   EX_FUNC_LEAVE(EX_FATAL);
 }
diff --git a/src/ex_put_name.c b/src/ex_put_name.c
index 30d1753662f..f1ba2856c90 100644
--- a/src/ex_put_name.c
+++ b/src/ex_put_name.c
@@ -54,9 +54,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, ex_id_lkup, etc
-#include "vtk_netcdf.h"       // for nc_inq_varid, NC_NOERR
-#include <inttypes.h>     // for PRId64
-#include <stdio.h>
 
 /*!
  * writes the name of the specified entity to the database. The entity
@@ -93,14 +90,14 @@ int ex_put_name(int exoid, ex_entity_type obj_type, ex_entity_id entity_id, cons
   case EX_ELEM_MAP: vobj = VAR_NAME_EM; break;
   default:
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: Invalid type specified in file id %d", exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
   if ((status = nc_inq_varid(exoid, vobj, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate %s names in file id %d",
              ex_name_of_object(obj_type), exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -109,7 +106,7 @@ int ex_put_name(int exoid, ex_entity_type obj_type, ex_entity_id entity_id, cons
   if (ent_ndx == -EX_LOOKUPFAIL) { /* could not find the element block id */
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: %s id %" PRId64 " not found in file id %d",
              ex_name_of_object(obj_type), entity_id, exoid);
-    ex_err(__func__, errmsg, EX_LOOKUPFAIL);
+    ex_err_fn(exoid, __func__, errmsg, EX_LOOKUPFAIL);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
diff --git a/src/ex_put_names.c b/src/ex_put_names.c
index 15b0c4e177c..ed856b386a5 100644
--- a/src/ex_put_names.c
+++ b/src/ex_put_names.c
@@ -53,10 +53,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, etc
-#include "vtk_netcdf.h"       // for nc_inq_varid, NC_NOERR
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <string.h> // for NULL
 
 /*!
  * writes the entity names to the database
@@ -99,7 +95,7 @@ int ex_put_names(int exoid, ex_entity_type obj_type, char *names[])
   /*  ======== ERROR (Invalid type) ========= */
   default:
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: Invalid type specified in file id %d", exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -109,7 +105,7 @@ int ex_put_names(int exoid, ex_entity_type obj_type, char *names[])
   if ((status = nc_inq_varid(exoid, vname, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate %s names in file id %d",
              ex_name_of_object(obj_type), exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
diff --git a/src/ex_put_nodal_var.c b/src/ex_put_nodal_var.c
index 00a4f4006a2..2b1a47768ff 100644
--- a/src/ex_put_nodal_var.c
+++ b/src/ex_put_nodal_var.c
@@ -35,10 +35,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_WARN, ex_comp_ws, etc
-#include "vtk_netcdf.h"       // for nc_inq_varid, NC_NOERR, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <sys/types.h> // for int64_t
 
 /*!
 \deprecated Use ex_put_var()(exoid, time_step, EX_NODAL, nodal_var_index, 1, num_nodes,
diff --git a/src/ex_put_nodal_var_int.c b/src/ex_put_nodal_var_int.c
index 02308c9eb7b..a21860d7d95 100644
--- a/src/ex_put_nodal_var_int.c
+++ b/src/ex_put_nodal_var_int.c
@@ -35,10 +35,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_WARN, ex_comp_ws, etc
-#include "vtk_netcdf.h"       // for nc_inq_varid, NC_NOERR, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <sys/types.h> // for int64_t
 
 /*!
 The function ex_put_nodal_var() writes the values of a single nodal
@@ -113,7 +109,7 @@ int ex_put_nodal_var_int(int exoid, int time_step, int nodal_var_index, int64_t
   if ((status = nc_inq_varid(exoid, VAR_NOD_VAR_NEW(nodal_var_index), &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "Warning: could not find nodal variable %d in file id %d",
              nodal_var_index, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     return (EX_WARN);
   }
   start[0] = --time_step;
@@ -133,7 +129,7 @@ int ex_put_nodal_var_int(int exoid, int time_step, int nodal_var_index, int64_t
 
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to store nodal variables in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     return (EX_FATAL);
   }
   return (EX_NOERR);
diff --git a/src/ex_put_node_cmap.c b/src/ex_put_node_cmap.c
index 230ff7947b9..868becce5a9 100644
--- a/src/ex_put_node_cmap.c
+++ b/src/ex_put_node_cmap.c
@@ -56,10 +56,6 @@
 
 #include <exodusII.h>     // for ex_err, etc
 #include <exodusII_int.h> // for EX_FATAL, DIM_NCNT_CMAP, etc
-#include <vtk_netcdf.h>       // for NC_NOERR, nc_inq_varid, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <sys/types.h> // for int64_t
 
 int ex_put_node_cmap(int exoid, ex_entity_id map_id, void_int *node_ids, void_int *proc_ids,
                      int processor)
@@ -79,7 +75,7 @@ int ex_put_node_cmap(int exoid, ex_entity_id map_id, void_int *node_ids, void_in
   if (ex_get_idx(exoid, VAR_N_COMM_INFO_IDX, varidx, processor) == -1) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find index variable, \"%s\", in file ID %d",
              VAR_N_COMM_INFO_IDX, exoid);
-    ex_err(__func__, errmsg, EX_LASTERR);
+    ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -89,7 +85,7 @@ int ex_put_node_cmap(int exoid, ex_entity_id map_id, void_int *node_ids, void_in
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to find index for variable \"%s\" in file ID %d", VAR_N_COMM_IDS,
              exoid);
-    ex_err(__func__, errmsg, EX_LASTERR);
+    ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -100,7 +96,7 @@ int ex_put_node_cmap(int exoid, ex_entity_id map_id, void_int *node_ids, void_in
   if ((status = nc_inq_varid(exoid, VAR_N_COMM_STAT, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
              VAR_N_COMM_STAT, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -108,7 +104,7 @@ int ex_put_node_cmap(int exoid, ex_entity_id map_id, void_int *node_ids, void_in
   if ((status = nc_get_var1_int(exoid, varid, start, &value)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: unable to get variable \"%s\" from file ID %d",
              VAR_N_COMM_STAT, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -120,7 +116,7 @@ int ex_put_node_cmap(int exoid, ex_entity_id map_id, void_int *node_ids, void_in
   if (ex_get_idx(exoid, VAR_N_COMM_DATA_IDX, varidx, map_idx) == -1) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find index variable, \"%s\", in file ID %d",
              VAR_N_COMM_DATA_IDX, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -131,7 +127,7 @@ int ex_put_node_cmap(int exoid, ex_entity_id map_id, void_int *node_ids, void_in
     if ((status = nc_inq_dimid(exoid, DIM_NCNT_CMAP, &dimid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get dimension ID for \"%s\" in file ID %d",
                DIM_NCNT_CMAP, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -139,7 +135,7 @@ int ex_put_node_cmap(int exoid, ex_entity_id map_id, void_int *node_ids, void_in
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to find length of dimension \"%s\" in file ID %d", DIM_NCNT_CMAP,
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -153,7 +149,7 @@ int ex_put_node_cmap(int exoid, ex_entity_id map_id, void_int *node_ids, void_in
   if ((status = nc_inq_varid(exoid, VAR_N_COMM_NIDS, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
              VAR_N_COMM_NIDS, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -164,10 +160,9 @@ int ex_put_node_cmap(int exoid, ex_entity_id map_id, void_int *node_ids, void_in
     status = nc_put_vara_int(exoid, varid, start, count, node_ids);
   }
   if (status != NC_NOERR) {
-    fprintf(stderr, "Start, Count = %" ST_ZU "\t%" ST_ZU "\n", start[0], count[0]);
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to output vector \"%s\" in file ID %d",
              VAR_N_COMM_NIDS, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -175,7 +170,7 @@ int ex_put_node_cmap(int exoid, ex_entity_id map_id, void_int *node_ids, void_in
   if ((status = nc_inq_varid(exoid, VAR_N_COMM_PROC, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
              VAR_N_COMM_PROC, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -188,7 +183,7 @@ int ex_put_node_cmap(int exoid, ex_entity_id map_id, void_int *node_ids, void_in
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to output variable \"%s\" in file ID %d",
              VAR_N_COMM_PROC, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
diff --git a/src/ex_put_ns_param_global.c b/src/ex_put_ns_param_global.c
index e9532be89b2..edfbcb7181f 100644
--- a/src/ex_put_ns_param_global.c
+++ b/src/ex_put_ns_param_global.c
@@ -52,8 +52,6 @@
 /*****************************************************************************/
 /*****************************************************************************/
 /*****************************************************************************/
-#include <vtk_netcdf.h>
-#include <stdio.h>
 
 #include <exodusII.h>
 #include <exodusII_int.h>
@@ -72,7 +70,7 @@ int ex_put_ns_param_global(int exoid, void_int *global_ids, void_int *node_cnts,
   if ((status = nc_inq_varid(exoid, VAR_NS_IDS_GLOBAL, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
              VAR_NS_IDS_GLOBAL, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -87,7 +85,7 @@ int ex_put_ns_param_global(int exoid, void_int *global_ids, void_int *node_cnts,
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to output variable \"%s\" to file ID %d",
              VAR_NS_IDS_GLOBAL, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -96,7 +94,7 @@ int ex_put_ns_param_global(int exoid, void_int *global_ids, void_int *node_cnts,
   if ((status = nc_inq_varid(exoid, VAR_NS_NODE_CNT_GLOBAL, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
              VAR_NS_NODE_CNT_GLOBAL, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -111,7 +109,7 @@ int ex_put_ns_param_global(int exoid, void_int *global_ids, void_int *node_cnts,
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to put variable \"%s\" in file ID %d",
              VAR_NS_NODE_CNT_GLOBAL, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -120,7 +118,7 @@ int ex_put_ns_param_global(int exoid, void_int *global_ids, void_int *node_cnts,
   if ((status = nc_inq_varid(exoid, VAR_NS_DF_CNT_GLOBAL, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
              VAR_NS_DF_CNT_GLOBAL, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -135,7 +133,7 @@ int ex_put_ns_param_global(int exoid, void_int *global_ids, void_int *node_cnts,
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to output variable \"%s\" in file ID %d",
              VAR_NS_DF_CNT_GLOBAL, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
diff --git a/src/ex_put_num_map.c b/src/ex_put_num_map.c
index 6aeb7157353..cfd03317993 100644
--- a/src/ex_put_num_map.c
+++ b/src/ex_put_num_map.c
@@ -51,10 +51,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_inq_dimid, etc
-#include <inttypes.h>     // for PRId64
-#include <stddef.h>       // for size_t
-#include <stdio.h>
 
 /*!
  * writes a map; this is a vector of integers of the same length as the
@@ -109,7 +105,7 @@ int ex_put_num_map(int exoid, ex_entity_type map_type, ex_entity_id map_id, cons
   default:
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: Bad map type (%d) specified for file id %d", map_type,
              exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -122,7 +118,7 @@ int ex_put_num_map(int exoid, ex_entity_type map_type, ex_entity_id map_id, cons
   if ((status = nc_inq_dimid(exoid, dnummaps, &dimid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: no %ss specified in file id %d",
              ex_name_of_object(map_type), exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -131,7 +127,7 @@ int ex_put_num_map(int exoid, ex_entity_type map_type, ex_entity_id map_id, cons
   if (status != -EX_LOOKUPFAIL) { /* found the map id */
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: %s %" PRId64 " already defined in file id %d",
              ex_name_of_object(map_type), map_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -139,7 +135,7 @@ int ex_put_num_map(int exoid, ex_entity_type map_type, ex_entity_id map_id, cons
   if ((status = nc_inq_dimlen(exoid, dimid, &num_entries)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get number of %ss in file id %d",
              ex_name_of_object(map_type), exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
   num_maps = num_entries;
@@ -153,7 +149,7 @@ int ex_put_num_map(int exoid, ex_entity_type map_type, ex_entity_id map_id, cons
   if (cur_num_maps >= num_maps) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: exceeded number of %ss (%d) specified in file id %d",
              ex_name_of_object(map_type), num_maps, exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -167,7 +163,7 @@ int ex_put_num_map(int exoid, ex_entity_type map_type, ex_entity_id map_id, cons
   if ((status = nc_inq_varid(exoid, vmapids, &varid)) == -1) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate %s ids in file id %d",
              ex_name_of_object(map_type), exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -178,7 +174,7 @@ int ex_put_num_map(int exoid, ex_entity_type map_type, ex_entity_id map_id, cons
   if ((status = nc_put_var1_int(exoid, varid, start, &ldum)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to store %s id %" PRId64 " in file id %d",
              ex_name_of_object(map_type), map_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -190,7 +186,7 @@ int ex_put_num_map(int exoid, ex_entity_type map_type, ex_entity_id map_id, cons
   default:
     snprintf(errmsg, MAX_ERR_LENGTH,
              "Internal ERROR: unrecognized map type in switch: %d in file id %d", map_type, exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -203,13 +199,13 @@ int ex_put_num_map(int exoid, ex_entity_type map_type, ex_entity_id map_id, cons
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: couldn't determine number of %s entries in file id %d",
                ex_name_of_object(map_type), exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
     if ((status = nc_redef(exoid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to place file id %d into define mode", exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -222,15 +218,12 @@ int ex_put_num_map(int exoid, ex_entity_type map_type, ex_entity_id map_id, cons
     dims[0] = dimid;
     if ((status = nc_def_var(exoid, vmap, map_int_type, 1, dims, &varid)) == -1) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define map %s in file id %d", vmap, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
     }
     ex_compress_variable(exoid, varid, 1);
 
-    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);
-      varid = -1; /* force early exit */
+    if ((status = ex_leavedef(exoid, __func__)) != NC_NOERR) { /* exit define mode */
+      varid = -1;                                              /* force early exit */
     }
 
     if (varid == -1) { /* we couldn't define variable and have prepared error message. */
@@ -249,7 +242,7 @@ int ex_put_num_map(int exoid, ex_entity_type map_type, ex_entity_id map_id, cons
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to store %s in file id %d",
              ex_name_of_object(map_type), exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
diff --git a/src/ex_put_one_attr.c b/src/ex_put_one_attr.c
index 651999889da..91811041401 100644
--- a/src/ex_put_one_attr.c
+++ b/src/ex_put_one_attr.c
@@ -51,10 +51,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, ex_get_dimension, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_inq_varid, etc
-#include <inttypes.h>     // for PRId64
-#include <stddef.h>       // for size_t, ptrdiff_t
-#include <stdio.h>
 
 /*!
  * writes the specified attribute for a block
@@ -91,12 +87,12 @@ int ex_put_one_attr(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, int
           snprintf(errmsg, MAX_ERR_LENGTH,
                    "Warning: no attributes allowed for NULL %s %" PRId64 " in file id %d",
                    ex_name_of_object(obj_type), obj_id, exoid);
-          ex_err(__func__, errmsg, EX_NULLENTITY);
+          ex_err_fn(exoid, __func__, errmsg, EX_NULLENTITY);
           EX_FUNC_LEAVE(EX_WARN); /* no attributes for this element block */
         }
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: no %s id %" PRId64 " in id array in file id %d",
                  ex_name_of_object(obj_type), obj_id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
     }
@@ -152,7 +148,7 @@ int ex_put_one_attr(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, int
     snprintf(errmsg, MAX_ERR_LENGTH,
              "Internal ERROR: unrecognized object type in switch: %d in file id %d", obj_type,
              exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL); /* number of attributes not defined */
   }
 
@@ -171,7 +167,7 @@ int ex_put_one_attr(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, int
              "ERROR: Invalid attribute index specified: %d.  Valid "
              "range is 1 to %d for %s %" PRId64 " in file id %d",
              attrib_index, (int)num_attr, ex_name_of_object(obj_type), obj_id, exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -179,7 +175,7 @@ int ex_put_one_attr(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, int
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to locate attribute variable for %s %" PRId64 " in file id %d",
              ex_name_of_object(obj_type), obj_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -205,7 +201,7 @@ int ex_put_one_attr(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, int
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to put attribute %d for %s %" PRId64 " in file id %d", attrib_index,
              ex_name_of_object(obj_type), obj_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
   EX_FUNC_LEAVE(EX_NOERR);
diff --git a/src/ex_put_partial_attr.c b/src/ex_put_partial_attr.c
index 9b56963f80e..4d6565eb4da 100644
--- a/src/ex_put_partial_attr.c
+++ b/src/ex_put_partial_attr.c
@@ -52,11 +52,6 @@
 
 #include "exodusII.h"     // for ex_err, ex_name_of_object, etc
 #include "exodusII_int.h" // for ex_check_valid_file_id, etc
-#include "vtk_netcdf.h"       // for nc_inq_dimid, nc_inq_varid, etc
-#include <inttypes.h>     // for PRId64
-#include <stddef.h>       // for size_t
-#include <stdint.h>       // for int64_t
-#include <stdio.h>        // for snprintf
 
 /*!
  * writes the attributes for an edge/face/element block
@@ -93,12 +88,12 @@ int ex_put_partial_attr(int exoid, ex_entity_type blk_type, ex_entity_id blk_id,
           snprintf(errmsg, MAX_ERR_LENGTH,
                    "Warning: no attributes allowed for NULL %s %" PRId64 " in file id %d",
                    ex_name_of_object(blk_type), blk_id, exoid);
-          ex_err(__func__, errmsg, EX_NULLENTITY);
+          ex_err_fn(exoid, __func__, errmsg, EX_NULLENTITY);
           EX_FUNC_LEAVE(EX_WARN); /* no attributes for this block */
         }
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: no %s id %" PRId64 " in in file id %d",
                  ex_name_of_object(blk_type), blk_id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
     }
@@ -118,7 +113,7 @@ int ex_put_partial_attr(int exoid, ex_entity_type blk_type, ex_entity_id blk_id,
     snprintf(errmsg, MAX_ERR_LENGTH,
              "Internal ERROR: unrecognized object type in switch: %d in file id %d", blk_type,
              exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL); /* number of attributes not defined */
   }
 
@@ -126,7 +121,7 @@ int ex_put_partial_attr(int exoid, ex_entity_type blk_type, ex_entity_id blk_id,
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to locate attribute variable for %s %" PRId64 " in file id %d",
              ex_name_of_object(blk_type), blk_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -159,7 +154,7 @@ int ex_put_partial_attr(int exoid, ex_entity_type blk_type, ex_entity_id blk_id,
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: number of attributes not defined for %s %" PRId64 " in file id %d",
              ex_name_of_object(blk_type), blk_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL); /* number of attributes not defined */
   }
 
@@ -167,7 +162,7 @@ int ex_put_partial_attr(int exoid, ex_entity_type blk_type, ex_entity_id blk_id,
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to get number of attributes for %s %" PRId64 " in file id %d",
              ex_name_of_object(blk_type), blk_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -192,7 +187,7 @@ int ex_put_partial_attr(int exoid, ex_entity_type blk_type, ex_entity_id blk_id,
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to put attributes for %s %" PRId64 " in file id %d",
              ex_name_of_object(blk_type), blk_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
   EX_FUNC_LEAVE(EX_NOERR);
diff --git a/src/ex_put_partial_conn.c b/src/ex_put_partial_conn.c
index 2798cd512b8..9d36ce87968 100644
--- a/src/ex_put_partial_conn.c
+++ b/src/ex_put_partial_conn.c
@@ -56,11 +56,6 @@
  */
 #include "exodusII.h"     // for ex_err, ex_name_of_object, etc
 #include "exodusII_int.h" // for ex_check_valid_file_id, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_inq_dimid, etc
-#include <inttypes.h>     // for PRId64
-#include <stddef.h>       // for size_t, NULL
-#include <stdint.h>       // for int64_t
-#include <stdio.h>        // for snprintf
 
 /*
  * reads the connectivity array for an element block
@@ -104,7 +99,7 @@ int ex_put_partial_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id,
              "Warning: ex_put_partial_conn only supports nodal "
              "connectivity at this time. %s %" PRId64 " in file id %d",
              ex_name_of_object(blk_type), blk_id, exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
   }
 
   ex_check_valid_file_id(exoid, __func__);
@@ -120,14 +115,14 @@ int ex_put_partial_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id,
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "Warning: no connectivity array for NULL %s %" PRId64 " in file id %d",
                  ex_name_of_object(blk_type), blk_id, exoid);
-        ex_err(__func__, errmsg, EX_NULLENTITY);
+        ex_err_fn(exoid, __func__, errmsg, EX_NULLENTITY);
         EX_FUNC_LEAVE(EX_WARN); /* no connectivity array for this element block */
       }
 
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to locate %s id %" PRId64 " in id array in file id %d",
                ex_name_of_object(blk_type), blk_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -161,7 +156,7 @@ int ex_put_partial_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id,
     snprintf(errmsg, MAX_ERR_LENGTH,
              "Internal ERROR: unrecognized block type in switch: %d in file id %d", blk_type,
              exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL); /* number of attributes not defined */
   }
   /* inquire id's of previously defined dimensions  */
@@ -170,7 +165,7 @@ int ex_put_partial_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id,
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to locate number of nodes/entity for %s %" PRId64 " in file id %d",
              ex_name_of_object(blk_type), blk_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -178,7 +173,7 @@ int ex_put_partial_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id,
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to get number of nodes/entity for %s %" PRId64 " in file id %d",
              ex_name_of_object(blk_type), blk_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -192,7 +187,7 @@ int ex_put_partial_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id,
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to get number of edges/entry for %s %" PRId64 " in file id %d",
                  ex_name_of_object(blk_type), blk_id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
     }
@@ -208,7 +203,7 @@ int ex_put_partial_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id,
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to get number of faces/entry for %s %" PRId64 " in file id %d",
                  ex_name_of_object(blk_type), blk_id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
     }
@@ -218,7 +213,7 @@ int ex_put_partial_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id,
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to locate connectivity array for %s %" PRId64 " in file id %d",
              ex_name_of_object(blk_type), blk_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -228,7 +223,7 @@ int ex_put_partial_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id,
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to locate edge connectivity array for %s %" PRId64 " in file id %d",
              ex_name_of_object(blk_type), blk_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -237,7 +232,7 @@ int ex_put_partial_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id,
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to locate face connectivity array for %s %" PRId64 " in file id %d",
              ex_name_of_object(blk_type), blk_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -265,7 +260,7 @@ int ex_put_partial_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id,
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to put edge connectivity array for %s %" PRId64 " in file id %d",
                ex_name_of_object(blk_type), blk_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -293,7 +288,7 @@ int ex_put_partial_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id,
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to put face connectivity array for %s %" PRId64 " in file id %d",
                ex_name_of_object(blk_type), blk_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -321,7 +316,7 @@ int ex_put_partial_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id,
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to put connectivity array for %s %" PRId64 " in file id %d",
                ex_name_of_object(blk_type), blk_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
diff --git a/src/ex_put_partial_coord.c b/src/ex_put_partial_coord.c
index be677d93c03..49a9ca626c8 100644
--- a/src/ex_put_partial_coord.c
+++ b/src/ex_put_partial_coord.c
@@ -56,11 +56,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, ex_comp_ws, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_inq_varid, etc
-#include <inttypes.h>     // for PRId64
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <sys/types.h> // for int64_t
 
 /*!
  * writes the coordinates of some of the nodes in the model
@@ -102,7 +97,7 @@ int ex_put_partial_coord(int exoid, int64_t start_node_num, int64_t num_nodes, c
     if ((status = nc_inq_dimlen(exoid, numnoddim, &tmp)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: inquire failed to return number of nodes in file id %d", exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
     num_nod = tmp;
@@ -111,14 +106,14 @@ int ex_put_partial_coord(int exoid, int64_t start_node_num, int64_t num_nodes, c
   if ((status = nc_inq_dimid(exoid, DIM_NUM_DIM, &ndimdim)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate number of dimensions in file id %d",
              exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
   if ((status = nc_inq_dimlen(exoid, ndimdim, &num_dim)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get number of dimensions in file id %d",
              exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -128,7 +123,7 @@ int ex_put_partial_coord(int exoid, int64_t start_node_num, int64_t num_nodes, c
              "ERROR: start index (%" PRId64 ") + node count (%" PRId64
              ") is larger than total number of nodes (%" PRId64 ") in file id %d",
              start_node_num, num_nodes, num_nod, exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -137,7 +132,7 @@ int ex_put_partial_coord(int exoid, int64_t start_node_num, int64_t num_nodes, c
     if ((status = nc_inq_varid(exoid, VAR_COORD_X, &coordidx)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate x nodal coordinates in file id %d",
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -148,7 +143,7 @@ int ex_put_partial_coord(int exoid, int64_t start_node_num, int64_t num_nodes, c
     if ((status = nc_inq_varid(exoid, VAR_COORD_Y, &coordidy)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate y nodal coordinates in file id %d",
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -159,7 +154,7 @@ int ex_put_partial_coord(int exoid, int64_t start_node_num, int64_t num_nodes, c
     if ((status = nc_inq_varid(exoid, VAR_COORD_Z, &coordidz)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate z nodal coordinates in file id %d",
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -205,7 +200,7 @@ int ex_put_partial_coord(int exoid, int64_t start_node_num, int64_t num_nodes, c
       if (status != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to put %s coord array in file id %d", which,
                  exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
     }
diff --git a/src/ex_put_partial_coord_component.c b/src/ex_put_partial_coord_component.c
index 30e99c8eaa0..2d96c2f87ed 100644
--- a/src/ex_put_partial_coord_component.c
+++ b/src/ex_put_partial_coord_component.c
@@ -35,11 +35,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, ex_comp_ws, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_inq_varid, etc
-#include <inttypes.h>     // for PRId64
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <sys/types.h> // for int64_t
 
 /*!
  * writes the coordinates of some of the nodes in the model for the specified component
@@ -78,7 +73,7 @@ int ex_put_partial_coord_component(int exoid, int64_t start_node_num, int64_t nu
     if ((status = nc_inq_dimlen(exoid, numnoddim, &tmp)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: inquire failed to return number of nodes in file id %d", exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
     num_nod = tmp;
@@ -87,14 +82,14 @@ int ex_put_partial_coord_component(int exoid, int64_t start_node_num, int64_t nu
   if ((status = nc_inq_dimid(exoid, DIM_NUM_DIM, &ndimdim)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate number of dimensions in file id %d",
              exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
   if ((status = nc_inq_dimlen(exoid, ndimdim, &num_dim)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get number of dimensions in file id %d",
              exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -104,7 +99,7 @@ int ex_put_partial_coord_component(int exoid, int64_t start_node_num, int64_t nu
              "ERROR: start index (%" PRId64 ") + node count (%" PRId64
              ") is larger than total number of nodes (%" PRId64 ") in file id %d",
              start_node_num, num_nodes, num_nod, exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -112,7 +107,7 @@ int ex_put_partial_coord_component(int exoid, int64_t start_node_num, int64_t nu
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: Component (%d) is larger than number of dimensions (%" ST_ZU ") in file id %d",
              component, num_dim, exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
   --component;
@@ -144,7 +139,7 @@ int ex_put_partial_coord_component(int exoid, int64_t start_node_num, int64_t nu
     if ((status = nc_inq_varid(exoid, comp, &coordid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate %s nodal coordinates in file id %d",
                which, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -158,7 +153,7 @@ int ex_put_partial_coord_component(int exoid, int64_t start_node_num, int64_t nu
     if (status != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to put %s coord array in file id %d", which,
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
diff --git a/src/ex_put_partial_id_map.c b/src/ex_put_partial_id_map.c
index a86cfa2edcd..ffe31259723 100644
--- a/src/ex_put_partial_id_map.c
+++ b/src/ex_put_partial_id_map.c
@@ -51,10 +51,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, EX_NOERR, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_enddef, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <sys/types.h> // for int64_t
 
 /*!
  * writes out a portion of the entity numbering map to the database;
@@ -109,7 +105,7 @@ int ex_put_partial_id_map(int exoid, ex_entity_type map_type, int64_t start_enti
   default:
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: Bad map type (%d) specified for file id %d", map_type,
              exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -128,7 +124,7 @@ int ex_put_partial_id_map(int exoid, ex_entity_type map_type, int64_t start_enti
                "ERROR: The %s count is %" PRId64
                ", but the %s dimension is not defined on file id %d.",
                tname, num_entities, dnumentries, exoid);
-      ex_err(__func__, errmsg, EX_BADPARAM);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -137,7 +133,7 @@ int ex_put_partial_id_map(int exoid, ex_entity_type map_type, int64_t start_enti
   if (nc_inq_varid(exoid, vmap, &mapid) != 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(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -155,21 +151,19 @@ int ex_put_partial_id_map(int exoid, ex_entity_type map_type, int64_t start_enti
       if (status == NC_ENAMEINUSE) {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: %s numbering map already exists in file id %d",
                  tname, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
       }
       else {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to create %s id map in file id %d", tname,
                  exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
       }
       goto error_ret; /* exit define mode and return */
     }
     ex_compress_variable(exoid, mapid, 1);
 
     /* leave define mode  */
-    if ((status = nc_enddef(exoid)) != NC_NOERR) {
-      snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to complete definition in file id %d", exoid);
-      ex_err(__func__, errmsg, status);
+    if ((status = ex_leavedef(exoid, __func__)) != NC_NOERR) {
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -192,7 +186,7 @@ int ex_put_partial_id_map(int exoid, ex_entity_type map_type, int64_t start_enti
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to store %s numbering map in file id %d", tname,
              exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -200,10 +194,6 @@ int ex_put_partial_id_map(int exoid, ex_entity_type map_type, int64_t start_enti
 
 /* Fatal error: exit definition mode and return */
 error_ret:
-  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);
-  }
+  ex_leavedef(exoid, __func__);
   EX_FUNC_LEAVE(EX_FATAL);
 }
diff --git a/src/ex_put_partial_nodal_var_int.c b/src/ex_put_partial_nodal_var_int.c
index 41a1be27441..427ae0a5b86 100644
--- a/src/ex_put_partial_nodal_var_int.c
+++ b/src/ex_put_partial_nodal_var_int.c
@@ -54,10 +54,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_WARN, ex_comp_ws, etc
-#include "vtk_netcdf.h"       // for nc_inq_varid, NC_NOERR, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <sys/types.h> // for int64_t
 
 /*!
 \ingroup ResultsData
@@ -88,7 +84,7 @@ int ex_put_partial_nodal_var_int(int exoid, int time_step, int nodal_var_index,
   if ((status = nc_inq_varid(exoid, VAR_NOD_VAR_NEW(nodal_var_index), &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "Warning: could not find nodal variable %d in file id %d",
              nodal_var_index, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_WARN);
   }
 
@@ -110,7 +106,7 @@ int ex_put_partial_nodal_var_int(int exoid, int time_step, int nodal_var_index,
 
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to store nodal variables in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
   EX_FUNC_LEAVE(EX_NOERR);
diff --git a/src/ex_put_partial_num_map.c b/src/ex_put_partial_num_map.c
index 79c1ab3a954..7c5952a40b6 100644
--- a/src/ex_put_partial_num_map.c
+++ b/src/ex_put_partial_num_map.c
@@ -53,11 +53,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_inq_dimid, etc
-#include <inttypes.h>     // for PRId64
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <sys/types.h> // for int64_t
 
 /*!
  * writes a map; this is a vector of integers of length number of mesh
@@ -104,7 +99,7 @@ int ex_put_partial_num_map(int exoid, ex_entity_type map_type, ex_entity_id map_
   default:
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: Bad map type (%d) specified for file id %d", map_type,
              exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -117,7 +112,7 @@ int ex_put_partial_num_map(int exoid, ex_entity_type map_type, ex_entity_id map_
   if ((status = nc_inq_dimid(exoid, dnummaps, &dimid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: no %ss specified in file id %d",
              ex_name_of_object(map_type), exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -136,7 +131,7 @@ int ex_put_partial_num_map(int exoid, ex_entity_type map_type, ex_entity_id map_
     if ((status = nc_inq_dimlen(exoid, dimid, &num_maps)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get number of %ss in file id %d",
                ex_name_of_object(map_type), exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -150,7 +145,7 @@ int ex_put_partial_num_map(int exoid, ex_entity_type map_type, ex_entity_id map_
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: exceeded number of %ss (%" ST_ZU ") specified in file id %d",
                ex_name_of_object(map_type), num_maps, exoid);
-      ex_err(__func__, errmsg, EX_BADPARAM);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -167,32 +162,32 @@ int ex_put_partial_num_map(int exoid, ex_entity_type map_type, ex_entity_id map_
   if ((status = nc_inq_dimid(exoid, dnumentries, &dimid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: couldn't determine number of mesh objects in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
   if ((status = nc_inq_dimlen(exoid, dimid, &num_mobj)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get number of mesh objects in file id %d",
              exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
   /* Check input parameters for a valid range of numbers */
   if (ent_start <= 0 || ent_start > num_mobj) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: start count is invalid in file id %d", exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
   if (ent_count < 0) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: Invalid count value in file id %d", exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
   if (ent_start + ent_count - 1 > num_mobj) {
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: start+count-1 is larger than mesh object count in file id %d", exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -202,7 +197,7 @@ int ex_put_partial_num_map(int exoid, ex_entity_type map_type, ex_entity_id map_
   if ((status = nc_inq_varid(exoid, vmapids, &varid)) == -1) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate %s ids in file id %d",
              ex_name_of_object(map_type), exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -213,7 +208,7 @@ int ex_put_partial_num_map(int exoid, ex_entity_type map_type, ex_entity_id map_
       if ((status = nc_put_var1_longlong(exoid, varid, start, (long long *)&map_id)) != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to store %s id %" PRId64 " in file id %d",
                  ex_name_of_object(map_type), map_id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
     }
@@ -227,7 +222,7 @@ int ex_put_partial_num_map(int exoid, ex_entity_type map_type, ex_entity_id map_
   default:
     snprintf(errmsg, MAX_ERR_LENGTH,
              "Internal ERROR: unrecognized map type in switch: %d in file id %d", map_type, exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -235,7 +230,7 @@ int ex_put_partial_num_map(int exoid, ex_entity_type map_type, ex_entity_id map_
   if ((status = nc_inq_varid(exoid, vmap, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate %s %" PRId64 " in file id %d",
              ex_name_of_object(map_type), map_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -257,7 +252,7 @@ int ex_put_partial_num_map(int exoid, ex_entity_type map_type, ex_entity_id map_
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to store %s in file id %d",
              ex_name_of_object(map_type), exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
diff --git a/src/ex_put_partial_one_attr.c b/src/ex_put_partial_one_attr.c
index 0f1a2a62f01..c3febb37fc5 100644
--- a/src/ex_put_partial_one_attr.c
+++ b/src/ex_put_partial_one_attr.c
@@ -51,11 +51,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, ex_get_dimension, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_inq_varid, etc
-#include <inttypes.h>     // for PRId64
-#include <stddef.h>       // for size_t, ptrdiff_t
-#include <stdio.h>
-#include <sys/types.h> // for int64_t
 
 /*!
  * writes the specified attribute for a block
@@ -96,12 +91,12 @@ int ex_put_partial_one_attr(int exoid, ex_entity_type obj_type, ex_entity_id obj
           snprintf(errmsg, MAX_ERR_LENGTH,
                    "Warning: no attributes allowed for NULL %s %" PRId64 " in file id %d",
                    ex_name_of_object(obj_type), obj_id, exoid);
-          ex_err(__func__, errmsg, EX_NULLENTITY);
+          ex_err_fn(exoid, __func__, errmsg, EX_NULLENTITY);
           EX_FUNC_LEAVE(EX_WARN); /* no attributes for this element block */
         }
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: no %s id %" PRId64 " in id array in file id %d",
                  ex_name_of_object(obj_type), obj_id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
     }
@@ -157,7 +152,7 @@ int ex_put_partial_one_attr(int exoid, ex_entity_type obj_type, ex_entity_id obj
     snprintf(errmsg, MAX_ERR_LENGTH,
              "Internal ERROR: unrecognized object type in switch: %d in file id %d", obj_type,
              exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -172,7 +167,7 @@ int ex_put_partial_one_attr(int exoid, ex_entity_type obj_type, ex_entity_id obj
              "ERROR: start index (%" PRId64 ") + count (%" PRId64
              ") is larger than total number of entities (%" ST_ZU ") in file id %d",
              start_num, num_ent, num_entries_this_obj, exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -185,7 +180,7 @@ int ex_put_partial_one_attr(int exoid, ex_entity_type obj_type, ex_entity_id obj
              "ERROR: Invalid attribute index specified: %d.  Valid "
              "range is 1 to %" ST_ZU " for %s %" PRId64 " in file id %d",
              attrib_index, num_attr, ex_name_of_object(obj_type), obj_id, exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -193,7 +188,7 @@ int ex_put_partial_one_attr(int exoid, ex_entity_type obj_type, ex_entity_id obj
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to locate attribute variable for %s %" PRId64 " in file id %d",
              ex_name_of_object(obj_type), obj_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -223,7 +218,7 @@ int ex_put_partial_one_attr(int exoid, ex_entity_type obj_type, ex_entity_id obj
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to put attribute %d for %s %" PRId64 " in file id %d", attrib_index,
              ex_name_of_object(obj_type), obj_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
   EX_FUNC_LEAVE(EX_NOERR);
diff --git a/src/ex_put_partial_set.c b/src/ex_put_partial_set.c
index b3b020dcd3f..46c9fab199b 100644
--- a/src/ex_put_partial_set.c
+++ b/src/ex_put_partial_set.c
@@ -53,11 +53,6 @@
 
 #include "exodusII.h"     // for ex_err, ex_name_of_object, etc
 #include "exodusII_int.h" // for ex_is_parallel, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_inq_varid, etc
-#include <inttypes.h>     // for PRId64
-#include <stddef.h>       // for size_t, NULL
-#include <stdint.h>       // for int64_t
-#include <stdio.h>        // for snprintf
 
 /*!
  * writes the set entry list and set extra list for a single set
@@ -91,7 +86,7 @@ int ex_put_partial_set(int exoid, ex_entity_type set_type, ex_entity_id set_id,
   if ((status = nc_inq_dimid(exoid, ex_dim_num_objects(set_type), &dimid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: no %ss defined in file id %d",
              ex_name_of_object(set_type), exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -105,12 +100,12 @@ int ex_put_partial_set(int exoid, ex_entity_type set_type, ex_entity_id set_id,
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "Warning: no data allowed for NULL %s %" PRId64 " in file id %d",
                  ex_name_of_object(set_type), set_id, exoid);
-        ex_err(__func__, errmsg, EX_NULLENTITY);
+        ex_err_fn(exoid, __func__, errmsg, EX_NULLENTITY);
         EX_FUNC_LEAVE(EX_WARN);
       }
       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_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -141,7 +136,7 @@ int ex_put_partial_set(int exoid, ex_entity_type set_type, ex_entity_id set_id,
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to locate entry list for %s %" PRId64 " in file id %d",
              ex_name_of_object(set_type), set_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -164,7 +159,7 @@ int ex_put_partial_set(int exoid, ex_entity_type set_type, ex_entity_id set_id,
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to store entry list for %s %" PRId64 " in file id %d",
                ex_name_of_object(set_type), set_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -175,7 +170,7 @@ int ex_put_partial_set(int exoid, ex_entity_type set_type, ex_entity_id set_id,
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to locate extra list for %s %" PRId64 " in file id %d",
                ex_name_of_object(set_type), set_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -195,7 +190,7 @@ int ex_put_partial_set(int exoid, ex_entity_type set_type, ex_entity_id set_id,
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to store extra list for %s %" PRId64 " in file id %d",
                ex_name_of_object(set_type), set_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -205,7 +200,7 @@ int ex_put_partial_set(int exoid, ex_entity_type set_type, ex_entity_id set_id,
     snprintf(errmsg, MAX_ERR_LENGTH,
              "Warning: extra list was ignored for %s %" PRId64 " in file id %d",
              ex_name_of_object(set_type), set_id, exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_WARN);
   }
 
diff --git a/src/ex_put_partial_set_dist_fact.c b/src/ex_put_partial_set_dist_fact.c
index 5fa2dd5dd1e..dac3ead77ff 100644
--- a/src/ex_put_partial_set_dist_fact.c
+++ b/src/ex_put_partial_set_dist_fact.c
@@ -55,11 +55,6 @@ write
 
 #include "exodusII.h"     // for ex_err, ex_name_of_object, etc
 #include "exodusII_int.h" // for ex_check_valid_file_id, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_inq_dimid, etc
-#include <inttypes.h>     // for PRId64
-#include <stddef.h>       // for size_t, NULL
-#include <stdint.h>       // for int64_t
-#include <stdio.h>        // for snprintf
 
 /*!
  * writes the partial distribution factors for a single set
@@ -89,7 +84,7 @@ int ex_put_partial_set_dist_fact(int exoid, ex_entity_type set_type, ex_entity_i
   if ((status = nc_inq_dimid(exoid, ex_dim_num_objects(set_type), &dimid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: no %ss specified in file id %d",
              ex_name_of_object(set_type), exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -103,13 +98,13 @@ int ex_put_partial_set_dist_fact(int exoid, ex_entity_type set_type, ex_entity_i
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "Warning: no data allowed for NULL %s %" PRId64 " in file id %d",
                  ex_name_of_object(set_type), set_id, exoid);
-        ex_err(__func__, errmsg, EX_NULLENTITY);
+        ex_err_fn(exoid, __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",
                ex_name_of_object(set_type), set_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -142,13 +137,13 @@ int ex_put_partial_set_dist_fact(int exoid, ex_entity_type set_type, ex_entity_i
       snprintf(errmsg, MAX_ERR_LENGTH,
                "Warning: no dist factors defined for %s %" PRId64 " in file id %d",
                ex_name_of_object(set_type), set_id, exoid);
-      ex_err(__func__, errmsg, EX_BADPARAM);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
       EX_FUNC_LEAVE(EX_WARN);
     }
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to locate dist factors list for %s %" PRId64 " in file id %d",
              ex_name_of_object(set_type), set_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -170,7 +165,7 @@ int ex_put_partial_set_dist_fact(int exoid, ex_entity_type set_type, ex_entity_i
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to store dist factors for %s %" PRId64 " in file id %d",
              ex_name_of_object(set_type), set_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
   EX_FUNC_LEAVE(EX_NOERR);
diff --git a/src/ex_put_partial_var.c b/src/ex_put_partial_var.c
index ccec3acb935..ed833af8f7e 100644
--- a/src/ex_put_partial_var.c
+++ b/src/ex_put_partial_var.c
@@ -35,12 +35,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, ex_get_dimension, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_inq_varid, etc
-#include <inttypes.h>     // for PRId64
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <stdlib.h>    // for free, malloc
-#include <sys/types.h> // for int64_t
 
 /*!
 \ingroup ResultsData
@@ -85,14 +79,14 @@ int ex_put_partial_var(int exoid, int time_step, ex_entity_type var_type, int va
         snprintf(errmsg, MAX_ERR_LENGTH,                                                           \
                  "Warning: no variables allowed for NULL block %" PRId64 " in file id %d", obj_id, \
                  exoid);                                                                           \
-        ex_err(__func__, errmsg, EX_NULLENTITY);                                                   \
+        ex_err_fn(exoid, __func__, errmsg, EX_NULLENTITY);                                         \
         EX_FUNC_LEAVE(EX_WARN);                                                                    \
       }                                                                                            \
       else {                                                                                       \
         snprintf(errmsg, MAX_ERR_LENGTH,                                                           \
                  "ERROR: failed to locate %s id %" PRId64 " in %s array in file id %d",            \
                  ex_name_of_object(var_type), obj_id, VOBJID, exoid);                              \
-        ex_err(__func__, errmsg, status);                                                          \
+        ex_err_fn(exoid, __func__, errmsg, status);                                                \
         EX_FUNC_LEAVE(EX_FATAL);                                                                   \
       }                                                                                            \
     }                                                                                              \
@@ -119,7 +113,7 @@ int ex_put_partial_var(int exoid, int time_step, ex_entity_type var_type, int va
                    "ERROR: failed to allocate memory for %s variable "                             \
                    "truth table in file id %d",                                                    \
                    ex_name_of_object(var_type), exoid);                                            \
-          ex_err(__func__, errmsg, EX_MEMFAIL);                                                    \
+          ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);                                          \
           EX_FUNC_LEAVE(EX_FATAL);                                                                 \
         }                                                                                          \
                                                                                                    \
@@ -127,7 +121,7 @@ int ex_put_partial_var(int exoid, int time_step, ex_entity_type var_type, int va
         if ((status = nc_get_var_int(exoid, varid, obj_var_truth_tab)) != NC_NOERR) {              \
           snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get truth table from file id %d",     \
                    exoid);                                                                         \
-          ex_err(__func__, errmsg, status);                                                        \
+          ex_err_fn(exoid, __func__, errmsg, status);                                              \
           EX_FUNC_LEAVE(EX_FATAL);                                                                 \
         }                                                                                          \
                                                                                                    \
@@ -137,7 +131,7 @@ int ex_put_partial_var(int exoid, int time_step, ex_entity_type var_type, int va
                    "ERROR: Invalid %s variable %d, %s %" PRId64 " in file id %d",                  \
                    ex_name_of_object(var_type), var_index, ex_name_of_object(var_type), obj_id,    \
                    exoid);                                                                         \
-          ex_err(__func__, errmsg, EX_BADPARAM);                                                   \
+          ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);                                         \
           EX_FUNC_LEAVE(EX_FATAL);                                                                 \
         }                                                                                          \
         free(obj_var_truth_tab);                                                                   \
@@ -146,7 +140,7 @@ int ex_put_partial_var(int exoid, int time_step, ex_entity_type var_type, int va
       if ((status = nc_inq_dimid(exoid, DIM_TIME, &time_dim)) != NC_NOERR) {                       \
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate time dimension in file id %d",   \
                  exoid);                                                                           \
-        ex_err(__func__, errmsg, status);                                                          \
+        ex_err_fn(exoid, __func__, errmsg, status);                                                \
         goto error_ret; /* exit define mode and return */                                          \
       }                                                                                            \
                                                                                                    \
@@ -157,7 +151,7 @@ int ex_put_partial_var(int exoid, int time_step, ex_entity_type var_type, int va
       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(__func__, errmsg, status);                                                          \
+        ex_err_fn(exoid, __func__, errmsg, status);                                                \
         EX_FUNC_LEAVE(EX_FATAL);                                                                   \
       }                                                                                            \
                                                                                                    \
@@ -168,26 +162,21 @@ int ex_put_partial_var(int exoid, int time_step, ex_entity_type var_type, int va
                                &varid)) != NC_NOERR) {                                             \
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define %s variable %d in file id %d",   \
                  ex_name_of_object(var_type), var_index, exoid);                                   \
-        ex_err(__func__, errmsg, status);                                                          \
+        ex_err_fn(exoid, __func__, errmsg, status);                                                \
         goto error_ret;                                                                            \
       }                                                                                            \
       ex_compress_variable(exoid, varid, 2);                                                       \
                                                                                                    \
       /*    leave define mode  */                                                                  \
                                                                                                    \
-      if ((status = nc_enddef(exoid)) != NC_NOERR) {                                               \
-        snprintf(errmsg, MAX_ERR_LENGTH,                                                           \
-                 "ERROR: failed to complete %s variable %s definition "                            \
-                 "to file id %d",                                                                  \
-                 ex_name_of_object(var_type), VVAR(var_index, obj_id_ndx), exoid);                 \
-        ex_err(__func__, errmsg, status);                                                          \
+      if ((status = ex_leavedef(exoid, __func__)) != NC_NOERR) {                                   \
         EX_FUNC_LEAVE(EX_FATAL);                                                                   \
       }                                                                                            \
     }                                                                                              \
     else {                                                                                         \
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate %s variable %s in file id %d",     \
                ex_name_of_object(var_type), VVAR(var_index, obj_id_ndx), exoid);                   \
-      ex_err(__func__, errmsg, status);                                                            \
+      ex_err_fn(exoid, __func__, errmsg, status);                                                  \
       EX_FUNC_LEAVE(EX_FATAL);                                                                     \
     }                                                                                              \
   }
@@ -197,7 +186,7 @@ int ex_put_partial_var(int exoid, int time_step, ex_entity_type var_type, int va
     if (num_entities <= 0) {
       snprintf(errmsg, MAX_ERR_LENGTH, "Warning: no global variables specified for file id %d",
                exoid);
-      ex_err(__func__, errmsg, EX_BADPARAM);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
 
       EX_FUNC_LEAVE(EX_WARN);
     }
@@ -206,12 +195,12 @@ int ex_put_partial_var(int exoid, int time_step, ex_entity_type var_type, int va
     if ((status = nc_inq_varid(exoid, VAR_GLO_VAR, &varid)) != NC_NOERR) {
       if (status == NC_ENOTVAR) {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: no global variables defined in file id %d", exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
       }
       else {
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to get global variables parameters in file id %d", exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
       }
       EX_FUNC_LEAVE(EX_FATAL);
     }
@@ -248,7 +237,7 @@ int ex_put_partial_var(int exoid, int time_step, ex_entity_type var_type, int va
   default:
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: invalid variable type (%d) specified for file id %d",
              var_type, exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
   /* store element variable values */
@@ -283,7 +272,7 @@ int ex_put_partial_var(int exoid, int time_step, ex_entity_type var_type, int va
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to store %s %" PRId64 " variable %d in file id %d",
              ex_name_of_object(var_type), obj_id, var_index, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -291,10 +280,6 @@ int ex_put_partial_var(int exoid, int time_step, ex_entity_type var_type, int va
 
 /* Fatal error: exit definition mode and return */
 error_ret:
-  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);
-  }
+  ex_leavedef(exoid, __func__);
   EX_FUNC_LEAVE(EX_FATAL);
 }
diff --git a/src/ex_put_processor_elem_maps.c b/src/ex_put_processor_elem_maps.c
index 5aa67e80892..30fc112483b 100644
--- a/src/ex_put_processor_elem_maps.c
+++ b/src/ex_put_processor_elem_maps.c
@@ -52,10 +52,6 @@
 
 #include <exodusII.h>     // for ex_err, etc
 #include <exodusII_int.h> // for EX_FATAL, DIM_NUM_BOR_ELEMS, etc
-#include <vtk_netcdf.h>       // for NC_NOERR, nc_inq_varid, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <sys/types.h> // for int64_t
 
 int ex_put_processor_elem_maps(int exoid, void_int *elem_mapi, void_int *elem_mapb, int processor)
 {
@@ -74,7 +70,7 @@ int ex_put_processor_elem_maps(int exoid, void_int *elem_mapi, void_int *elem_ma
   /* Get the file type */
   if (ex_get_file_type(exoid, ftype) != EX_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: unable to find file type for file ID %d", exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -83,7 +79,7 @@ int ex_put_processor_elem_maps(int exoid, void_int *elem_mapi, void_int *elem_ma
   if ((status = nc_inq_varid(exoid, VAR_INT_E_STAT, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
              VAR_INT_E_STAT, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -98,7 +94,7 @@ int ex_put_processor_elem_maps(int exoid, void_int *elem_mapi, void_int *elem_ma
   if ((status = nc_get_var1_int(exoid, varid, start, &nmstat)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get variable \"%s\" from file ID %d",
              VAR_INT_E_STAT, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -109,7 +105,7 @@ int ex_put_processor_elem_maps(int exoid, void_int *elem_mapi, void_int *elem_ma
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to find index variable, \"%s\", in file ID %d", VAR_ELEM_MAP_INT_IDX,
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
 
       EX_FUNC_LEAVE(EX_FATAL);
     }
@@ -120,7 +116,7 @@ int ex_put_processor_elem_maps(int exoid, void_int *elem_mapi, void_int *elem_ma
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to find dimension ID for \"%s\" in file ID %d", DIM_NUM_INT_ELEMS,
                  exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
 
@@ -128,7 +124,7 @@ int ex_put_processor_elem_maps(int exoid, void_int *elem_mapi, void_int *elem_ma
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to find length of dimension \"%s\" in file ID %d",
                  DIM_NUM_INT_ELEMS, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
 
@@ -138,7 +134,7 @@ int ex_put_processor_elem_maps(int exoid, void_int *elem_mapi, void_int *elem_ma
     if ((status = nc_inq_varid(exoid, VAR_ELEM_MAP_INT, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
                VAR_ELEM_MAP_INT, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -154,7 +150,7 @@ int ex_put_processor_elem_maps(int exoid, void_int *elem_mapi, void_int *elem_ma
     if (status != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to output variable \"%s\" in file ID %d",
                VAR_ELEM_MAP_INT, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -164,7 +160,7 @@ int ex_put_processor_elem_maps(int exoid, void_int *elem_mapi, void_int *elem_ma
   if ((status = nc_inq_varid(exoid, VAR_BOR_E_STAT, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
              VAR_BOR_E_STAT, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -179,7 +175,7 @@ int ex_put_processor_elem_maps(int exoid, void_int *elem_mapi, void_int *elem_ma
   if ((status = nc_get_var1_int(exoid, varid, start, &nmstat)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get status for \"%s\" from file %d",
              VAR_BOR_E_STAT, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -190,7 +186,7 @@ int ex_put_processor_elem_maps(int exoid, void_int *elem_mapi, void_int *elem_ma
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to find index variable, \"%s\", in file ID %d", VAR_ELEM_MAP_BOR_IDX,
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
 
       EX_FUNC_LEAVE(EX_FATAL);
     }
@@ -201,7 +197,7 @@ int ex_put_processor_elem_maps(int exoid, void_int *elem_mapi, void_int *elem_ma
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to find dimension ID for \"%s\" in file ID %d", DIM_NUM_BOR_ELEMS,
                  exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
 
@@ -209,7 +205,7 @@ int ex_put_processor_elem_maps(int exoid, void_int *elem_mapi, void_int *elem_ma
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to find length of dimension \"%s\" in file ID %d",
                  DIM_NUM_BOR_ELEMS, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
 
@@ -219,7 +215,7 @@ int ex_put_processor_elem_maps(int exoid, void_int *elem_mapi, void_int *elem_ma
     if ((status = nc_inq_varid(exoid, VAR_ELEM_MAP_BOR, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
                VAR_ELEM_MAP_BOR, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -235,7 +231,7 @@ int ex_put_processor_elem_maps(int exoid, void_int *elem_mapi, void_int *elem_ma
     if (status != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to output variable \"%s\" in file ID %d",
                VAR_ELEM_MAP_BOR, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   } /* End "if (nmstat == 1)" */
diff --git a/src/ex_put_processor_node_maps.c b/src/ex_put_processor_node_maps.c
index 35f1c26460c..0162adc328a 100644
--- a/src/ex_put_processor_node_maps.c
+++ b/src/ex_put_processor_node_maps.c
@@ -52,10 +52,6 @@
 
 #include <exodusII.h>     // for ex_err, etc
 #include <exodusII_int.h> // for EX_FATAL, DIM_NUM_BOR_NODES, etc
-#include <vtk_netcdf.h>       // for NC_NOERR, nc_inq_varid, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <sys/types.h> // for int64_t
 
 int ex_put_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_mapb,
                                void_int *node_mape, int proc_id)
@@ -75,7 +71,7 @@ int ex_put_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_ma
   /* Get the file type */
   if (ex_get_file_type(exoid, ftype) != EX_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: unable to find file type for file ID %d", exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -84,7 +80,7 @@ int ex_put_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_ma
   if ((status = nc_inq_varid(exoid, VAR_INT_N_STAT, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" from file ID %d",
              VAR_INT_N_STAT, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -98,7 +94,7 @@ int ex_put_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_ma
   if ((status = nc_get_var1_int(exoid, varid, start, &nmstat)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get status for \"%s\" from file %d",
              VAR_INT_N_STAT, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -109,7 +105,7 @@ int ex_put_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_ma
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to find index variable, \"%s\", in file ID %d", VAR_NODE_MAP_INT_IDX,
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
 
       EX_FUNC_LEAVE(EX_FATAL);
     }
@@ -120,7 +116,7 @@ int ex_put_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_ma
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to find dimension ID for \"%s\" in file ID %d", DIM_NUM_INT_NODES,
                  exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
 
@@ -128,7 +124,7 @@ int ex_put_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_ma
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to find length of dimension \"%s\" in file ID %d",
                  DIM_NUM_INT_NODES, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
 
@@ -138,7 +134,7 @@ int ex_put_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_ma
     if ((status = nc_inq_varid(exoid, VAR_NODE_MAP_INT, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
                VAR_NODE_MAP_INT, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
 
       EX_FUNC_LEAVE(EX_FATAL);
     }
@@ -154,7 +150,7 @@ int ex_put_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_ma
     if (status != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to output variable \"%s\" in file ID %d",
                VAR_NODE_MAP_INT, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   } /* End "if (nmstat == 1)" */
@@ -163,7 +159,7 @@ int ex_put_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_ma
   if ((status = nc_inq_varid(exoid, VAR_BOR_N_STAT, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" from file ID %d",
              VAR_BOR_N_STAT, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -177,7 +173,7 @@ int ex_put_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_ma
   if ((status = nc_get_var1_int(exoid, varid, start, &nmstat)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get status for \"%s\" from file %d",
              VAR_BOR_N_STAT, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -188,7 +184,7 @@ int ex_put_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_ma
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to find index variable, \"%s\", in file ID %d", VAR_NODE_MAP_BOR_IDX,
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
 
       EX_FUNC_LEAVE(EX_FATAL);
     }
@@ -199,7 +195,7 @@ int ex_put_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_ma
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to find dimension ID for \"%s\" in file ID %d", DIM_NUM_BOR_NODES,
                  exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
 
@@ -207,7 +203,7 @@ int ex_put_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_ma
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to find length of dimension \"%s\" in file ID %d",
                  DIM_NUM_BOR_NODES, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
 
@@ -217,7 +213,7 @@ int ex_put_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_ma
     if ((status = nc_inq_varid(exoid, VAR_NODE_MAP_BOR, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
                VAR_NODE_MAP_BOR, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
 
       EX_FUNC_LEAVE(EX_FATAL);
     }
@@ -234,7 +230,7 @@ int ex_put_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_ma
     if (status != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to output variable \"%s\" in file ID %d",
                VAR_NODE_MAP_BOR, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   } /* End "if (nmstat == 1)" */
@@ -243,7 +239,7 @@ int ex_put_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_ma
   if ((status = nc_inq_varid(exoid, VAR_EXT_N_STAT, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" from file ID %d",
              VAR_EXT_N_STAT, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -257,7 +253,7 @@ int ex_put_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_ma
   if ((status = nc_get_var1_int(exoid, varid, start, &nmstat)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get status for \"%s\" from file %d",
              VAR_EXT_N_STAT, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -267,7 +263,7 @@ int ex_put_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_ma
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to find index variable, \"%s\", in file ID %d", VAR_NODE_MAP_EXT_IDX,
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
 
       EX_FUNC_LEAVE(EX_FATAL);
     }
@@ -278,7 +274,7 @@ int ex_put_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_ma
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to find dimension ID for \"%s\" in file ID %d", DIM_NUM_EXT_NODES,
                  exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
 
@@ -286,7 +282,7 @@ int ex_put_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_ma
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to find length of dimension \"%s\" in file ID %d",
                  DIM_NUM_EXT_NODES, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
       varidx[1] = count[0];
@@ -295,7 +291,7 @@ int ex_put_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_ma
     if ((status = nc_inq_varid(exoid, VAR_NODE_MAP_EXT, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
                VAR_NODE_MAP_EXT, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
 
       EX_FUNC_LEAVE(EX_FATAL);
     }
@@ -312,7 +308,7 @@ int ex_put_processor_node_maps(int exoid, void_int *node_mapi, void_int *node_ma
     if (status != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to output variable \"%s\" in file ID %d",
                VAR_NODE_MAP_EXT, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   } /* End "if (nmstat == 1)" */
diff --git a/src/ex_put_prop.c b/src/ex_put_prop.c
index 1a79b01f33c..4aeaca9c4b9 100644
--- a/src/ex_put_prop.c
+++ b/src/ex_put_prop.c
@@ -35,11 +35,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, ex_id_lkup, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_set_fill, etc
-#include <inttypes.h>     // for PRId64
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <string.h> // for memset, strcmp, etc
 
 /*!
 
@@ -149,14 +144,14 @@ int ex_put_prop(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, const c
       default:
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: object type %d not supported; file id %d",
                  obj_type, exoid);
-        ex_err(__func__, errmsg, EX_BADPARAM);
+        ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
         EX_FUNC_LEAVE(EX_FATAL);
       }
 
       if ((status = nc_inq_varid(exoid, name, &propid)) != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get property array id in file id %d",
                  exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
 
@@ -164,7 +159,7 @@ int ex_put_prop(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, const c
       memset(tmpstr, 0, MAX_STR_LENGTH + 1);
       if ((status = nc_get_att_text(exoid, propid, ATT_PROP_NAME, tmpstr)) != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get property name in file id %d", exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
 
@@ -183,7 +178,7 @@ int ex_put_prop(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, const c
     /* put netcdf file into define mode  */
     if ((status = nc_redef(exoid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to place file id %d into define mode", exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -242,7 +237,7 @@ int ex_put_prop(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, const c
     default:
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: object type %d not supported; file id %d", obj_type,
                exoid);
-      ex_err(__func__, errmsg, EX_BADPARAM);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
       goto error_ret; /* Exit define mode and return */
     }
 
@@ -250,7 +245,7 @@ int ex_put_prop(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, const c
     if ((status = nc_inq_dimid(exoid, dim_name, &dimid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate number of objects in file id %d",
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       goto error_ret; /* Exit define mode and return */
     }
 
@@ -265,7 +260,7 @@ int ex_put_prop(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, const c
     if ((status = nc_def_var(exoid, name, int_type, 1, dims, &propid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to create property array variable in file id %d", exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       goto error_ret; /* Exit define mode and return */
     }
 
@@ -275,7 +270,7 @@ int ex_put_prop(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, const c
     if ((status = nc_put_att_longlong(exoid, propid, _FillValue, int_type, 1, vals)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to create property name fill attribute in file id %d", exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       goto error_ret; /* Exit define mode and return */
     }
 
@@ -294,16 +289,14 @@ int ex_put_prop(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, const c
                                   (void *)prop_name)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to store property name %s in file id %d",
                prop_name, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       goto error_ret; /* Exit define mode and return */
     }
 
     ex_update_max_name_length(exoid, prop_name_len - 1);
 
     /* leave define mode  */
-    if ((status = nc_enddef(exoid)) != NC_NOERR) {
-      snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to leave define mode in file id %d", exoid);
-      ex_err(__func__, errmsg, status);
+    if ((status = ex_leavedef(exoid, __func__)) != NC_NOERR) {
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -321,7 +314,7 @@ int ex_put_prop(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, const c
       snprintf(errmsg, MAX_ERR_LENGTH,
                "Warning: attempt to assign duplicate %s ID %" PRId64 " in file id %d",
                ex_name_of_object(obj_type), value, exoid);
-      ex_err(__func__, errmsg, EX_DUPLICATEID);
+      ex_err_fn(exoid, __func__, errmsg, EX_DUPLICATEID);
       EX_FUNC_LEAVE(EX_WARN);
     }
   }
@@ -338,13 +331,13 @@ int ex_put_prop(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, const c
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "Warning: no properties allowed for NULL %s id %" PRId64 " in file id %d",
                  ex_name_of_object(obj_type), obj_id, exoid);
-        ex_err(__func__, errmsg, EX_NULLENTITY);
+        ex_err_fn(exoid, __func__, errmsg, EX_NULLENTITY);
         EX_FUNC_LEAVE(EX_WARN);
       }
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to find value %" PRId64 " in %s property array in file id %d", obj_id,
                ex_name_of_object(obj_type), exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -355,7 +348,7 @@ int ex_put_prop(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, const c
 
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to store property value in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -365,9 +358,6 @@ int ex_put_prop(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, const c
 error_ret:
   nc_set_fill(exoid, oldfill, &temp); /* default: nofill */
 
-  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);
-  }
+  ex_leavedef(exoid, __func__);
   EX_FUNC_LEAVE(EX_FATAL);
 }
diff --git a/src/ex_put_prop_array.c b/src/ex_put_prop_array.c
index ada177d5702..ad3988dc669 100644
--- a/src/ex_put_prop_array.c
+++ b/src/ex_put_prop_array.c
@@ -35,10 +35,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, ATT_PROP_NAME, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_set_fill, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <string.h> // for memset, strlen, etc
 
 /*!
 
@@ -144,14 +140,14 @@ int ex_put_prop_array(int exoid, ex_entity_type obj_type, const char *prop_name,
     default:
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: object type %d not supported; file id %d", obj_type,
                exoid);
-      ex_err(__func__, errmsg, EX_BADPARAM);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
     if ((status = nc_inq_varid(exoid, name, &propid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get property array id in file id %d",
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -159,7 +155,7 @@ int ex_put_prop_array(int exoid, ex_entity_type obj_type, const char *prop_name,
     memset(tmpstr, 0, MAX_STR_LENGTH + 1);
     if ((status = nc_get_att_text(exoid, propid, ATT_PROP_NAME, tmpstr)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get property name in file id %d", exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -175,7 +171,7 @@ int ex_put_prop_array(int exoid, ex_entity_type obj_type, const char *prop_name,
     /* put netcdf file into define mode  */
     if ((status = nc_redef(exoid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to place file id %d into define mode", exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -197,7 +193,7 @@ int ex_put_prop_array(int exoid, ex_entity_type obj_type, const char *prop_name,
     default:
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: object type %d not supported; file id %d", obj_type,
                exoid);
-      ex_err(__func__, errmsg, EX_BADPARAM);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
       goto error_ret; /* Exit define mode and return */
     }
 
@@ -212,7 +208,7 @@ int ex_put_prop_array(int exoid, ex_entity_type obj_type, const char *prop_name,
     if ((status = nc_def_var(exoid, name, int_type, 1, dims, &propid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to create property array variable in file id %d", exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       goto error_ret; /* Exit define mode and return */
     }
     nc_set_fill(exoid, oldfill, &temp); /* default: nofill */
@@ -222,15 +218,13 @@ int ex_put_prop_array(int exoid, ex_entity_type obj_type, const char *prop_name,
                                   prop_name)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to store property name %s in file id %d",
                prop_name, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       goto error_ret; /* Exit define mode and return */
     }
 
     /* leave define mode  */
 
-    if ((status = nc_enddef(exoid)) != NC_NOERR) {
-      snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to leave define mode in file id %d", exoid);
-      ex_err(__func__, errmsg, status);
+    if ((status = ex_leavedef(exoid, __func__)) != NC_NOERR) {
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -245,7 +239,7 @@ int ex_put_prop_array(int exoid, ex_entity_type obj_type, const char *prop_name,
 
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to store property values in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -253,10 +247,7 @@ int ex_put_prop_array(int exoid, ex_entity_type obj_type, const char *prop_name,
 
 /* Fatal error: exit definition mode and return */
 error_ret:
-  nc_set_fill(exoid, oldfill, &temp);            /* default: nofill */
-  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);
-  }
+  nc_set_fill(exoid, oldfill, &temp); /* default: nofill */
+  ex_leavedef(exoid, __func__);
   EX_FUNC_LEAVE(EX_FATAL);
 }
diff --git a/src/ex_put_prop_names.c b/src/ex_put_prop_names.c
index e28552eba82..ff0c5a80375 100644
--- a/src/ex_put_prop_names.c
+++ b/src/ex_put_prop_names.c
@@ -35,10 +35,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_enddef, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <string.h> // for strlen
 
 /*!
 
@@ -152,7 +148,7 @@ int ex_put_prop_names(int exoid, ex_entity_type obj_type, int num_props, char **
   if ((status = nc_inq_dimid(exoid, ex_dim_num_objects(obj_type), &dimid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate number of %s in file id %d",
              ex_name_of_object(obj_type), exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -161,7 +157,7 @@ int ex_put_prop_names(int exoid, ex_entity_type obj_type, int num_props, char **
   /* put netcdf file into define mode  */
   if ((status = nc_redef(exoid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to place file id %d into define mode", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -186,14 +182,14 @@ int ex_put_prop_names(int exoid, ex_entity_type obj_type, int num_props, char **
     default:
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: object type %d not supported; file id %d", obj_type,
                exoid);
-      ex_err(__func__, errmsg, EX_BADPARAM);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
       goto error_ret; /* Exit define mode and return */
     }
 
     if ((status = nc_def_var(exoid, name, int_type, 1, dims, &propid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to create property array variable in file id %d", exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       goto error_ret; /* Exit define mode and return */
     }
 
@@ -204,7 +200,7 @@ int ex_put_prop_names(int exoid, ex_entity_type obj_type, int num_props, char **
     if ((status = nc_put_att_longlong(exoid, propid, _FillValue, int_type, 1, vals)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to create property name fill attribute in file id %d", exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       goto error_ret; /* Exit define mode and return */
     }
 
@@ -227,15 +223,13 @@ int ex_put_prop_names(int exoid, ex_entity_type obj_type, int num_props, char **
         NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to store property name %s in file id %d",
                prop_names[i], exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       goto error_ret; /* Exit define mode and return */
     }
   }
 
   /* leave define mode  */
-  if ((status = nc_enddef(exoid)) != NC_NOERR) {
-    snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to leave define mode in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+  if ((status = ex_leavedef(exoid, __func__)) != NC_NOERR) {
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -247,9 +241,6 @@ int ex_put_prop_names(int exoid, ex_entity_type obj_type, int num_props, char **
 
 /* Fatal error: exit definition mode and return */
 error_ret:
-  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);
-  }
+  ex_leavedef(exoid, __func__);
   EX_FUNC_LEAVE(EX_FATAL);
 }
diff --git a/src/ex_put_qa.c b/src/ex_put_qa.c
index fb01d7b0c2b..b8f6286d509 100644
--- a/src/ex_put_qa.c
+++ b/src/ex_put_qa.c
@@ -35,10 +35,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, DIM_NUM_QA, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_inq_dimid, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <string.h> // for strlen, NULL
 
 /*!
 
@@ -117,7 +113,7 @@ int ex_put_qa(int exoid, int num_qa_records, char *qa_record[][4])
       if ((status = nc_redef(rootid)) != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to put file id %d into define mode",
                  rootid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
 
@@ -125,12 +121,12 @@ int ex_put_qa(int exoid, int num_qa_records, char *qa_record[][4])
       if ((status = nc_def_dim(rootid, DIM_NUM_QA, num_qa_records, &num_qa_dim)) != NC_NOERR) {
         if (status == NC_ENAMEINUSE) { /* duplicate entry? */
           snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: qa records already exist in file id %d", rootid);
-          ex_err(__func__, errmsg, status);
+          ex_err_fn(exoid, __func__, errmsg, status);
         }
         else {
           snprintf(errmsg, MAX_ERR_LENGTH,
                    "ERROR: failed to define qa record array size in file id %d", rootid);
-          ex_err(__func__, errmsg, status);
+          ex_err_fn(exoid, __func__, errmsg, status);
         }
 
         goto error_ret; /* exit define mode and return */
@@ -140,7 +136,7 @@ int ex_put_qa(int exoid, int num_qa_records, char *qa_record[][4])
       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);
+        ex_err_fn(exoid, __func__, errmsg, status);
         goto error_ret; /* exit define mode and return */
       }
 
@@ -152,7 +148,7 @@ int ex_put_qa(int exoid, int num_qa_records, char *qa_record[][4])
         else {
           snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define string length in file id %d",
                    rootid);
-          ex_err(__func__, errmsg, status);
+          ex_err_fn(exoid, __func__, errmsg, status);
           goto error_ret; /* exit define mode and return */
         }
       }
@@ -165,15 +161,12 @@ int ex_put_qa(int exoid, int num_qa_records, char *qa_record[][4])
       if ((status = nc_def_var(rootid, VAR_QA_TITLE, NC_CHAR, 3, dims, &varid)) != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define qa record array in file id %d",
                  rootid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         goto error_ret; /* exit define mode and return */
       }
 
       /*   leave define mode  */
-      if ((status = nc_enddef(rootid)) != NC_NOERR) {
-        snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to complete definition in file id %d",
-                 rootid);
-        ex_err(__func__, errmsg, status);
+      if ((status = ex_leavedef(rootid, __func__)) != NC_NOERR) {
         EX_FUNC_LEAVE(EX_FATAL);
       }
     }
@@ -181,7 +174,7 @@ int ex_put_qa(int exoid, int num_qa_records, char *qa_record[][4])
       if ((status = nc_inq_varid(rootid, VAR_QA_TITLE, &varid)) != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find qa records variable in file id %d",
                  rootid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         EX_FUNC_LEAVE(EX_FATAL);
       }
     }
@@ -203,7 +196,7 @@ int ex_put_qa(int exoid, int num_qa_records, char *qa_record[][4])
               NC_NOERR) {
             snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to store qa record in file id %d",
                      rootid);
-            ex_err(__func__, errmsg, status);
+            ex_err_fn(exoid, __func__, errmsg, status);
             EX_FUNC_LEAVE(EX_FATAL);
           }
         }
@@ -225,9 +218,6 @@ int ex_put_qa(int exoid, int num_qa_records, char *qa_record[][4])
 
 /* Fatal error: exit definition mode and return */
 error_ret:
-  if ((status = nc_enddef(rootid)) != NC_NOERR) { /* exit define mode */
-    snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to complete definition for file id %d", rootid);
-    ex_err(__func__, errmsg, status);
-  }
+  ex_leavedef(rootid, __func__);
   EX_FUNC_LEAVE(EX_FATAL);
 }
diff --git a/src/ex_put_set.c b/src/ex_put_set.c
index e258d51a582..45d74b93a2f 100644
--- a/src/ex_put_set.c
+++ b/src/ex_put_set.c
@@ -53,9 +53,6 @@
 
 #include "exodusII.h"     // for ex_err, ex_name_of_object, etc
 #include "exodusII_int.h" // for ex_check_valid_file_id, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_inq_varid, etc
-#include <inttypes.h>     // for PRId64
-#include <stdio.h>        // for snprintf, NULL
 
 /*!
  * writes the set entry list and set extra list for a single set
@@ -85,7 +82,7 @@ int ex_put_set(int exoid, ex_entity_type set_type, ex_entity_id set_id,
   if ((status = nc_inq_dimid(exoid, ex_dim_num_objects(set_type), &dimid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: no %ss defined in file id %d",
              ex_name_of_object(set_type), exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -99,13 +96,13 @@ int ex_put_set(int exoid, ex_entity_type set_type, ex_entity_id set_id,
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "Warning: no data allowed for NULL %s %" PRId64 " in file id %d",
                  ex_name_of_object(set_type), set_id, exoid);
-        ex_err(__func__, errmsg, EX_NULLENTITY);
+        ex_err_fn(exoid, __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",
                ex_name_of_object(set_type), set_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -137,7 +134,7 @@ int ex_put_set(int exoid, ex_entity_type set_type, ex_entity_id set_id,
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to locate entry list for %s %" PRId64 " in file id %d",
              ex_name_of_object(set_type), set_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -147,7 +144,7 @@ int ex_put_set(int exoid, ex_entity_type set_type, ex_entity_id set_id,
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to locate extra list for %s %" PRId64 " in file id %d",
                ex_name_of_object(set_type), set_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -166,7 +163,7 @@ int ex_put_set(int exoid, ex_entity_type set_type, ex_entity_id set_id,
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to store entry list for %s %" PRId64 " in file id %d",
                ex_name_of_object(set_type), set_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -185,7 +182,7 @@ int ex_put_set(int exoid, ex_entity_type set_type, ex_entity_id set_id,
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to store extra list for %s %" PRId64 " in file id %d",
                ex_name_of_object(set_type), set_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -195,7 +192,7 @@ int ex_put_set(int exoid, ex_entity_type set_type, ex_entity_id set_id,
     snprintf(errmsg, MAX_ERR_LENGTH,
              "Warning: extra list was ignored for %s %" PRId64 " in file id %d",
              ex_name_of_object(set_type), set_id, exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_WARN);
   }
 
diff --git a/src/ex_put_set_dist_fact.c b/src/ex_put_set_dist_fact.c
index 1dbec2d183b..06d499566b9 100644
--- a/src/ex_put_set_dist_fact.c
+++ b/src/ex_put_set_dist_fact.c
@@ -52,9 +52,6 @@
 
 #include "exodusII.h"     // for ex_err, ex_name_of_object, etc
 #include "exodusII_int.h" // for EX_FATAL, EX_WARN, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_inq_dimid, etc
-#include <inttypes.h>     // for PRId64
-#include <stdio.h>
 
 /*!
  * writes the distribution factors for a single set
@@ -81,7 +78,7 @@ int ex_put_set_dist_fact(int exoid, ex_entity_type set_type, ex_entity_id set_id
   if ((status = nc_inq_dimid(exoid, ex_dim_num_objects(set_type), &dimid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: no %ss specified in file id %d",
              ex_name_of_object(set_type), exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -95,13 +92,13 @@ int ex_put_set_dist_fact(int exoid, ex_entity_type set_type, ex_entity_id set_id
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "Warning: no data allowed for NULL %s %" PRId64 " in file id %d",
                  ex_name_of_object(set_type), set_id, exoid);
-        ex_err(__func__, errmsg, EX_NULLENTITY);
+        ex_err_fn(exoid, __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",
                ex_name_of_object(set_type), set_id, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -134,13 +131,13 @@ int ex_put_set_dist_fact(int exoid, ex_entity_type set_type, ex_entity_id set_id
       snprintf(errmsg, MAX_ERR_LENGTH,
                "Warning: no dist factors defined for %s %" PRId64 " in file id %d",
                ex_name_of_object(set_type), set_id, exoid);
-      ex_err(__func__, errmsg, EX_BADPARAM);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
       EX_FUNC_LEAVE(EX_WARN);
     }
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to locate dist factors list for %s %" PRId64 " in file id %d",
              ex_name_of_object(set_type), set_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -156,7 +153,7 @@ int ex_put_set_dist_fact(int exoid, ex_entity_type set_type, ex_entity_id set_id
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to store dist factors for %s %" PRId64 " in file id %d",
              ex_name_of_object(set_type), set_id, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
diff --git a/src/ex_put_set_param.c b/src/ex_put_set_param.c
index d562323e0f5..a26bba39123 100644
--- a/src/ex_put_set_param.c
+++ b/src/ex_put_set_param.c
@@ -53,8 +53,6 @@
  *****************************************************************************/
 
 #include "exodusII.h" // for ex_set, ex_put_sets, etc
-#include <stddef.h>   // for NULL
-#include <stdint.h>   // for int64_t
 
 /*!
  * writes the set id and the number of entries which describe a single set
diff --git a/src/ex_put_sets.c b/src/ex_put_sets.c
index cc51959bfdc..2ddcf6af5ad 100644
--- a/src/ex_put_sets.c
+++ b/src/ex_put_sets.c
@@ -35,12 +35,6 @@
 
 #include "exodusII.h"     // for ex_set, ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_def_var, etc
-#include <inttypes.h>     // for PRId64
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <stdlib.h>    // for NULL, free, malloc
-#include <sys/types.h> // for int64_t
 
 /*!
  * writes the set parameters and optionally set data for 1 or more sets
@@ -87,12 +81,12 @@ int ex_put_sets(int exoid, size_t set_count, const struct ex_set *sets)
       if (status == NC_EBADDIM) {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: no %ss defined for file id %d",
                  ex_name_of_object(sets[i].type), exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
       }
       else {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate %ss defined in file id %d",
                  ex_name_of_object(sets[i].type), exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
       }
       free(sets_to_define);
       EX_FUNC_LEAVE(EX_FATAL);
@@ -122,7 +116,7 @@ int ex_put_sets(int exoid, size_t set_count, const struct ex_set *sets)
     /* put netcdf file into define mode  */
     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(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       free(sets_to_define);
       EX_FUNC_LEAVE(EX_FATAL);
     }
@@ -193,13 +187,13 @@ int ex_put_sets(int exoid, size_t set_count, const struct ex_set *sets)
           snprintf(errmsg, MAX_ERR_LENGTH,
                    "ERROR: %s %" PRId64 " -- size already defined in file id %d",
                    ex_name_of_object(sets[i].type), sets[i].id, exoid);
-          ex_err(__func__, errmsg, status);
+          ex_err_fn(exoid, __func__, errmsg, status);
         }
         else {
           snprintf(errmsg, MAX_ERR_LENGTH,
                    "ERROR: failed to define number of entries in %s %" PRId64 " in file id %d",
                    ex_name_of_object(sets[i].type), sets[i].id, exoid);
-          ex_err(__func__, errmsg, status);
+          ex_err_fn(exoid, __func__, errmsg, status);
         }
         goto error_ret;
       }
@@ -216,13 +210,13 @@ int ex_put_sets(int exoid, size_t set_count, const struct ex_set *sets)
           snprintf(errmsg, MAX_ERR_LENGTH,
                    "ERROR: entry list already exists for %s %" PRId64 " in file id %d",
                    ex_name_of_object(sets[i].type), sets[i].id, exoid);
-          ex_err(__func__, errmsg, status);
+          ex_err_fn(exoid, __func__, errmsg, status);
         }
         else {
           snprintf(errmsg, MAX_ERR_LENGTH,
                    "ERROR: failed to create entry list for %s %" PRId64 " in file id %d",
                    ex_name_of_object(sets[i].type), sets[i].id, exoid);
-          ex_err(__func__, errmsg, status);
+          ex_err_fn(exoid, __func__, errmsg, status);
         }
         goto error_ret; /* exit define mode and return */
       }
@@ -234,13 +228,13 @@ int ex_put_sets(int exoid, size_t set_count, const struct ex_set *sets)
             snprintf(errmsg, MAX_ERR_LENGTH,
                      "ERROR: extra list already exists for %s %" PRId64 " in file id %d",
                      ex_name_of_object(sets[i].type), sets[i].id, exoid);
-            ex_err(__func__, errmsg, status);
+            ex_err_fn(exoid, __func__, errmsg, status);
           }
           else {
             snprintf(errmsg, MAX_ERR_LENGTH,
                      "ERROR: failed to create extra list for %s %" PRId64 " in file id %d",
                      ex_name_of_object(sets[i].type), sets[i].id, exoid);
-            ex_err(__func__, errmsg, status);
+            ex_err_fn(exoid, __func__, errmsg, status);
           }
           goto error_ret; /* exit define mode and return */
         }
@@ -256,7 +250,7 @@ int ex_put_sets(int exoid, size_t set_count, const struct ex_set *sets)
                      "ERROR: # dist fact (%" PRId64 ") not equal to # nodes (%" PRId64
                      ") in node  set %" PRId64 " file id %d",
                      sets[i].num_distribution_factor, sets[i].num_entry, sets[i].id, exoid);
-            ex_err(__func__, errmsg, EX_BADPARAM);
+            ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
             goto error_ret; /* exit define mode and return */
           }
         }
@@ -268,7 +262,7 @@ int ex_put_sets(int exoid, size_t set_count, const struct ex_set *sets)
                      "ERROR: failed to define number of dist factors in %s %" PRId64
                      " in file id %d",
                      ex_name_of_object(sets[i].type), sets[i].id, exoid);
-            ex_err(__func__, errmsg, status);
+            ex_err_fn(exoid, __func__, errmsg, status);
             goto error_ret; /* exit define mode and return */
           }
         }
@@ -282,13 +276,13 @@ int ex_put_sets(int exoid, size_t set_count, const struct ex_set *sets)
             snprintf(errmsg, MAX_ERR_LENGTH,
                      "ERROR: dist factors list already exists for %s %" PRId64 " in file id %d",
                      ex_name_of_object(sets[i].type), sets[i].id, exoid);
-            ex_err(__func__, errmsg, status);
+            ex_err_fn(exoid, __func__, errmsg, status);
           }
           else {
             snprintf(errmsg, MAX_ERR_LENGTH,
                      "ERROR: failed to create dist factors list for %s %" PRId64 " in file id %d",
                      ex_name_of_object(sets[i].type), sets[i].id, exoid);
-            ex_err(__func__, errmsg, status);
+            ex_err_fn(exoid, __func__, errmsg, status);
           }
           goto error_ret; /* exit define mode and return */
         }
@@ -297,9 +291,7 @@ int ex_put_sets(int exoid, size_t set_count, const struct ex_set *sets)
     }
 
     /* leave define mode  */
-    if ((status = nc_enddef(exoid)) != NC_NOERR) {
-      snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to complete definition in file id %d", exoid);
-      ex_err(__func__, errmsg, status);
+    if ((status = ex_leavedef(exoid, __func__)) != NC_NOERR) {
       free(sets_to_define);
       EX_FUNC_LEAVE(EX_FATAL);
     }
@@ -332,7 +324,7 @@ int ex_put_sets(int exoid, size_t set_count, const struct ex_set *sets)
       if ((status = nc_inq_varid(exoid, idsptr, &varid)) != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate %s %" PRId64 " in file id %d",
                  ex_name_of_object(sets[i].type), sets[i].id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         free(sets_to_define);
         EX_FUNC_LEAVE(EX_FATAL);
       }
@@ -348,7 +340,7 @@ int ex_put_sets(int exoid, size_t set_count, const struct ex_set *sets)
       if (status != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to store %s id %" PRId64 " in file id %d",
                  ex_name_of_object(sets[i].type), sets[i].id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         free(sets_to_define);
         EX_FUNC_LEAVE(EX_FATAL);
       }
@@ -358,7 +350,7 @@ int ex_put_sets(int exoid, size_t set_count, const struct ex_set *sets)
       if ((status = nc_inq_varid(exoid, statptr, &varid)) != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate %s status in file id %d",
                  ex_name_of_object(sets[i].type), exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         free(sets_to_define);
         EX_FUNC_LEAVE(EX_FATAL);
       }
@@ -367,7 +359,7 @@ int ex_put_sets(int exoid, size_t set_count, const struct ex_set *sets)
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to store %s %" PRId64 " status to file id %d",
                  ex_name_of_object(sets[i].type), sets[i].id, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         free(sets_to_define);
         EX_FUNC_LEAVE(EX_FATAL);
       }
@@ -405,9 +397,6 @@ int ex_put_sets(int exoid, size_t set_count, const struct ex_set *sets)
 error_ret:
   free(sets_to_define);
 
-  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);
-  }
+  ex_leavedef(exoid, __func__);
   EX_FUNC_LEAVE(EX_FATAL);
 }
diff --git a/src/ex_put_ss_param_global.c b/src/ex_put_ss_param_global.c
index 5fd686d7033..cc8e86405d6 100644
--- a/src/ex_put_ss_param_global.c
+++ b/src/ex_put_ss_param_global.c
@@ -52,9 +52,6 @@
 /*****************************************************************************/
 /*****************************************************************************/
 /*****************************************************************************/
-#include <stdio.h>
-
-#include <vtk_netcdf.h>
 
 #include <exodusII.h>
 #include <exodusII_int.h>
@@ -74,7 +71,7 @@ int ex_put_ss_param_global(int exoid, void_int *global_ids, void_int *side_cnts,
   if ((status = nc_inq_varid(exoid, VAR_SS_IDS_GLOBAL, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
              VAR_SS_IDS_GLOBAL, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -89,7 +86,7 @@ int ex_put_ss_param_global(int exoid, void_int *global_ids, void_int *side_cnts,
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to output variable \"%s\" to file ID %d",
              VAR_SS_IDS_GLOBAL, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -98,7 +95,7 @@ int ex_put_ss_param_global(int exoid, void_int *global_ids, void_int *side_cnts,
   if ((status = nc_inq_varid(exoid, VAR_SS_SIDE_CNT_GLOBAL, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
              VAR_SS_SIDE_CNT_GLOBAL, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -113,7 +110,7 @@ int ex_put_ss_param_global(int exoid, void_int *global_ids, void_int *side_cnts,
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to put variable \"%s\" in file ID %d",
              VAR_SS_SIDE_CNT_GLOBAL, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -122,7 +119,7 @@ int ex_put_ss_param_global(int exoid, void_int *global_ids, void_int *side_cnts,
   if ((status = nc_inq_varid(exoid, VAR_SS_DF_CNT_GLOBAL, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
              VAR_SS_DF_CNT_GLOBAL, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
@@ -137,7 +134,7 @@ int ex_put_ss_param_global(int exoid, void_int *global_ids, void_int *side_cnts,
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to output variable \"%s\" in file ID %d",
              VAR_SS_DF_CNT_GLOBAL, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
 
     EX_FUNC_LEAVE(EX_FATAL);
   }
diff --git a/src/ex_put_time.c b/src/ex_put_time.c
index 7ad2e4d2ed0..0ae902a5c51 100644
--- a/src/ex_put_time.c
+++ b/src/ex_put_time.c
@@ -35,10 +35,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, ex_comp_ws, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_inq_varid, etc
-#include <assert.h>
-#include <stddef.h> // for size_t
-#include <stdio.h>
 
 /*!
 
@@ -97,7 +93,7 @@ int ex_put_time(int exoid, int time_step, const void *time_value)
     if ((status = nc_inq_varid(exoid, VAR_WHOLE_TIME, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate time variable in file id %d",
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
     file->time_varid = varid;
@@ -115,7 +111,7 @@ int ex_put_time(int exoid, int time_step, const void *time_value)
 
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to store time value in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
diff --git a/src/ex_put_truth_table.c b/src/ex_put_truth_table.c
index bda716069d9..5cbbe172578 100644
--- a/src/ex_put_truth_table.c
+++ b/src/ex_put_truth_table.c
@@ -53,10 +53,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for ex_get_dimension, EX_FATAL, etc
-#include "vtk_netcdf.h"       // for nc_inq_varid, NC_NOERR, etc
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <stdlib.h> // for free, NULL, malloc
 
 /*!
 \ingroup ResultsData
@@ -198,14 +194,14 @@ int ex_put_truth_table(int exoid, ex_entity_type obj_type, int num_blk, int num_
   else { /* invalid variable type */
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: Invalid variable type %d specified in file id %d",
              obj_type, exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_WARN);
   }
 
   if ((int)num_entity != num_blk) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: # of %s doesn't match those defined in file id %d",
              ex_name_of_object(obj_type), exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -213,7 +209,7 @@ int ex_put_truth_table(int exoid, ex_entity_type obj_type, int num_blk, int num_
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: # of %s variables doesn't match those defined in file id %d",
              ex_name_of_object(obj_type), exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -222,7 +218,7 @@ int ex_put_truth_table(int exoid, ex_entity_type obj_type, int num_blk, int num_
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to allocate memory for %s status array for file id %d",
              ex_name_of_object(obj_type), exoid);
-    ex_err(__func__, errmsg, EX_MEMFAIL);
+    ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -237,7 +233,7 @@ int ex_put_truth_table(int exoid, ex_entity_type obj_type, int num_blk, int num_
       free(stat_vals);
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get %s status array from file id %d",
                ex_name_of_object(obj_type), exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
   }
@@ -252,7 +248,7 @@ int ex_put_truth_table(int exoid, ex_entity_type obj_type, int num_blk, int num_
   if ((status = nc_redef(exoid)) != NC_NOERR) {
     free(stat_vals);
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to put file id %d into define mode", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -260,7 +256,7 @@ int ex_put_truth_table(int exoid, ex_entity_type obj_type, int num_blk, int num_
   if ((status = nc_inq_dimid(exoid, DIM_TIME, &timedim)) != NC_NOERR) {
     free(stat_vals);
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate time variable in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     goto error_ret; /* exit define mode and return */
   }
 
@@ -290,7 +286,7 @@ int ex_put_truth_table(int exoid, ex_entity_type obj_type, int num_blk, int num_
                      "ERROR: failed to locate number of entities in "
                      "%d'th %s in file id %d",
                      i + 1, ex_name_of_object(obj_type), exoid);
-            ex_err(__func__, errmsg, status);
+            ex_err_fn(exoid, __func__, errmsg, status);
             goto error_ret; /* exit define mode and return */
           }
 
@@ -308,7 +304,7 @@ int ex_put_truth_table(int exoid, ex_entity_type obj_type, int num_blk, int num_
               snprintf(errmsg, MAX_ERR_LENGTH,
                        "ERROR: failed to define variable for %d'th %s in file id %d", i + 1,
                        ex_name_of_object(obj_type), exoid);
-              ex_err(__func__, errmsg, status);
+              ex_err_fn(exoid, __func__, errmsg, status);
               goto error_ret; /* exit define mode and return */
             }
             ex_compress_variable(exoid, varid, 2);
@@ -332,14 +328,12 @@ int ex_put_truth_table(int exoid, ex_entity_type obj_type, int num_blk, int num_
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to define %s variable truth table in file id %d",
              ex_name_of_object(obj_type), exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     goto error_ret; /* exit define mode and return */
   }
 
   /* leave define mode  */
-  if ((status = nc_enddef(exoid)) != NC_NOERR) {
-    snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to complete definitions in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+  if ((status = ex_leavedef(exoid, __func__)) != NC_NOERR) {
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -349,7 +343,7 @@ int ex_put_truth_table(int exoid, ex_entity_type obj_type, int num_blk, int num_
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to store variable truth table in file id %d",
              exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -357,10 +351,6 @@ int ex_put_truth_table(int exoid, ex_entity_type obj_type, int num_blk, int num_
 
 /* Fatal error: exit definition mode and return */
 error_ret:
-  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);
-  }
+  ex_leavedef(exoid, __func__);
   EX_FUNC_LEAVE(EX_FATAL);
 }
diff --git a/src/ex_put_var.c b/src/ex_put_var.c
index e893521154c..c99174bc398 100644
--- a/src/ex_put_var.c
+++ b/src/ex_put_var.c
@@ -35,12 +35,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_inq_varid, etc
-#include <inttypes.h>     // for PRId64
-#include <stddef.h>       // for size_t
-#include <stdio.h>
-#include <stdlib.h>    // for free, malloc
-#include <sys/types.h> // for int64_t
 
 static int ex_look_up_var(int exoid, ex_entity_type var_type, int var_index, ex_entity_id obj_id,
                           const char *VOBJID, const char *VOBJTAB, const char *DNUMOBJ,
@@ -67,14 +61,14 @@ static int ex_look_up_var(int exoid, ex_entity_type var_type, int var_index, ex_
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "Warning: no variables allowed for NULL block %" PRId64 " in file id %d", obj_id,
                  exoid);
-        ex_err(__func__, errmsg, EX_NULLENTITY);
+        ex_err_fn(exoid, __func__, errmsg, EX_NULLENTITY);
         return (EX_WARN);
       }
 
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to locate %s id %" PRId64 " in %s array in file id %d",
                ex_name_of_object(var_type), obj_id, VOBJID, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       return (EX_FATAL);
     }
   }
@@ -102,7 +96,7 @@ static int ex_look_up_var(int exoid, ex_entity_type var_type, int var_index, ex_
                    "ERROR: failed to allocate memory for %s variable "
                    "truth table in file id %d",
                    ex_name_of_object(var_type), exoid);
-          ex_err(__func__, errmsg, EX_MEMFAIL);
+          ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
           return (EX_FATAL);
         }
 
@@ -110,7 +104,7 @@ static int ex_look_up_var(int exoid, ex_entity_type var_type, int var_index, ex_
         if ((status = nc_get_var_int(exoid, *varid, obj_var_truth_tab)) != NC_NOERR) {
           snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get truth table from file id %d",
                    exoid);
-          ex_err(__func__, errmsg, status);
+          ex_err_fn(exoid, __func__, errmsg, status);
           return (EX_FATAL);
         }
 
@@ -119,7 +113,7 @@ static int ex_look_up_var(int exoid, ex_entity_type var_type, int var_index, ex_
           snprintf(
               errmsg, MAX_ERR_LENGTH, "ERROR: Invalid %s variable %d, %s %" PRId64 " in file id %d",
               ex_name_of_object(var_type), var_index, ex_name_of_object(var_type), obj_id, exoid);
-          ex_err(__func__, errmsg, EX_BADPARAM);
+          ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
           return (EX_FATAL);
         }
         free(obj_var_truth_tab);
@@ -128,7 +122,7 @@ static int ex_look_up_var(int exoid, ex_entity_type var_type, int var_index, ex_
       if ((status = nc_inq_dimid(exoid, DIM_TIME, &time_dim)) != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate time dimension in file id %d",
                  exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         goto error_ret; /* exit define mode and return */
       }
 
@@ -138,7 +132,7 @@ static int ex_look_up_var(int exoid, ex_entity_type var_type, int var_index, ex_
       /*    variable doesn't exist so put file into define mode  */
       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(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         return (EX_FATAL);
       }
 
@@ -149,18 +143,13 @@ static int ex_look_up_var(int exoid, ex_entity_type var_type, int var_index, ex_
                                nc_flt_code(exoid), 2, dims, varid)) != NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define %s variable %d in file id %d",
                  ex_name_of_object(var_type), var_index, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         goto error_ret;
       }
       ex_compress_variable(exoid, *varid, 2);
 
       /*    leave define mode  */
-      if ((status = nc_enddef(exoid)) != NC_NOERR) {
-        snprintf(errmsg, MAX_ERR_LENGTH,
-                 "ERROR: failed to complete %s variable %s definition to file id %d",
-                 ex_name_of_object(var_type),
-                 ex_name_var_of_object(var_type, var_index, obj_id_ndx), exoid);
-        ex_err(__func__, errmsg, status);
+      if ((status = ex_leavedef(exoid, __func__)) != NC_NOERR) {
         return (EX_FATAL);
       }
     }
@@ -168,7 +157,7 @@ static int ex_look_up_var(int exoid, ex_entity_type var_type, int var_index, ex_
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate %s variable %s in file id %d",
                ex_name_of_object(var_type), ex_name_var_of_object(var_type, var_index, obj_id_ndx),
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       return (EX_FATAL);
     }
   }
@@ -176,10 +165,7 @@ static int ex_look_up_var(int exoid, ex_entity_type var_type, int var_index, ex_
 
 /* Fatal error: exit definition mode and return */
 error_ret:
-  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);
-  }
+  ex_leavedef(exoid, __func__);
   return (EX_FATAL);
 }
 
@@ -216,7 +202,7 @@ int ex_put_var(int exoid, int time_step, ex_entity_type var_type, int var_index,
     if (num_entries_this_obj <= 0) {
       snprintf(errmsg, MAX_ERR_LENGTH, "Warning: no global variables specified for file id %d",
                exoid);
-      ex_err(__func__, errmsg, EX_BADPARAM);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
 
       EX_FUNC_LEAVE(EX_WARN);
     }
@@ -225,12 +211,12 @@ int ex_put_var(int exoid, int time_step, ex_entity_type var_type, int var_index,
     if ((status = nc_inq_varid(exoid, VAR_GLO_VAR, &varid)) != NC_NOERR) {
       if (status == NC_ENOTVAR) {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: no global variables defined in file id %d", exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
       }
       else {
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to get global variables parameters in file id %d", exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
       }
       EX_FUNC_LEAVE(EX_FATAL);
     }
@@ -274,7 +260,7 @@ int ex_put_var(int exoid, int time_step, ex_entity_type var_type, int var_index,
   default:
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: invalid variable type (%d) specified for file id %d",
              var_type, exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -311,7 +297,7 @@ int ex_put_var(int exoid, int time_step, ex_entity_type var_type, int var_index,
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to store %s %" PRId64 " variable %d in file id %d",
              ex_name_of_object(var_type), obj_id, var_index, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
diff --git a/src/ex_put_variable_name.c b/src/ex_put_variable_name.c
index 15a1ba9984a..68e1e2232d1 100644
--- a/src/ex_put_variable_name.c
+++ b/src/ex_put_variable_name.c
@@ -52,8 +52,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_WARN, etc
-#include "vtk_netcdf.h"       // for nc_inq_varid, NC_NOERR
-#include <stdio.h>
 
 /*!
 \ingroup ResultsData
@@ -91,14 +89,14 @@ int ex_put_variable_name(int exoid, ex_entity_type obj_type, int var_num, const
   default:
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: Invalid variable type (%d) given for file id %d",
              obj_type, exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_WARN);
   }
 
   if ((status = nc_inq_varid(exoid, vname, &varid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "Warning: no %s variables names stored in file id %d",
              ex_name_of_object(obj_type), exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_WARN);
   }
 
diff --git a/src/ex_put_variable_names.c b/src/ex_put_variable_names.c
index 3ebd64a7729..ef5fccd53ed 100644
--- a/src/ex_put_variable_names.c
+++ b/src/ex_put_variable_names.c
@@ -52,8 +52,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_inq_dimid, etc
-#include <stdio.h>
 
 static int ex_put_var_names_int(int exoid, char *tname, char *dnumvar, char *vnames, int *varid)
 {
@@ -65,12 +63,12 @@ static int ex_put_var_names_int(int exoid, char *tname, char *dnumvar, char *vna
     if (status == NC_EBADDIM) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: no %s variables defined in file id %d", tname,
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
     }
     else {
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to locate number of %s variables in file id %d", tname, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
     }
     return (EX_FATAL);
   }
@@ -79,12 +77,12 @@ static int ex_put_var_names_int(int exoid, char *tname, char *dnumvar, char *vna
     if (status == NC_ENOTVAR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: no %s variable names defined in file id %d", tname,
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
     }
     else {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: %s name variable names not found in file id %d",
                tname, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
     }
     return (EX_FATAL);
   }
@@ -192,7 +190,7 @@ int ex_put_variable_names(int exoid, ex_entity_type obj_type, int num_vars, char
   default:
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: Invalid variable type %d specified in file id %d",
              obj_type, exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
diff --git a/src/ex_put_variable_param.c b/src/ex_put_variable_param.c
index 045134edd62..1727d51d2b2 100644
--- a/src/ex_put_variable_param.c
+++ b/src/ex_put_variable_param.c
@@ -35,8 +35,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for ex_compress_variable, etc
-#include "vtk_netcdf.h"       // for NC_NOERR, nc_def_var, etc
-#include <stdio.h>
 
 /*! \cond INTERNAL */
 static int ex_prepare_result_var(int exoid, int num_vars, char *type_name, char *dim_name,
@@ -59,12 +57,12 @@ static int ex_prepare_result_var(int exoid, int num_vars, char *type_name, char
                "ERROR: %s variable name parameters are already defined "
                "in file id %d",
                type_name, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
     }
     else {
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to define number of %s variables in file id %d", type_name, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
     }
     return (EX_FATAL); /* exit define mode and return */
   }
@@ -72,7 +70,7 @@ static int ex_prepare_result_var(int exoid, int num_vars, char *type_name, char
   /* Now define type_name variable name variable */
   if ((status = nc_inq_dimid(exoid, DIM_STR_NAME, &dim_str_name)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get string length in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     return (EX_FATAL);
   }
 
@@ -82,12 +80,12 @@ static int ex_prepare_result_var(int exoid, int num_vars, char *type_name, char
     if (status == NC_ENAMEINUSE) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: %s variable names are already defined in file id %d",
                type_name, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
     }
     else {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define %s variable names in file id %d",
                type_name, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
     }
     return (EX_FATAL); /* exit define mode and return */
   }
@@ -165,7 +163,7 @@ int ex_put_variable_param(int exoid, ex_entity_type obj_type, int num_vars)
   if (num_vars == 0) {
     snprintf(errmsg, MAX_ERR_LENGTH, "Warning: zero %s variables specified for file id %d",
              ex_name_of_object(obj_type), exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
 
     EX_FUNC_LEAVE(EX_WARN);
   }
@@ -176,14 +174,14 @@ int ex_put_variable_param(int exoid, ex_entity_type obj_type, int num_vars)
       obj_type != EX_GLOBAL) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: Invalid variable type %d specified in file id %d",
              obj_type, exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     EX_FUNC_LEAVE(EX_WARN);
   }
 
   /* inquire previously defined dimensions  */
   if ((status = nc_inq_dimid(exoid, DIM_TIME, &time_dim)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate time dimension in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -197,14 +195,14 @@ int ex_put_variable_param(int exoid, ex_entity_type obj_type, int num_vars)
   if ((status = nc_inq_dimid(exoid, DIM_STR_NAME, &dim_str_name)) < 0) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get name string length in file id %d",
              exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
   /* put file into define mode  */
   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(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -218,7 +216,7 @@ int ex_put_variable_param(int exoid, ex_entity_type obj_type, int num_vars)
     if ((status = nc_inq_dimid(exoid, DIM_NUM_GLO_VAR, &dimid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get global variable count in file id %d",
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       EX_FUNC_LEAVE(EX_FATAL);
     }
     dims[0] = time_dim;
@@ -227,7 +225,7 @@ int ex_put_variable_param(int exoid, ex_entity_type obj_type, int num_vars)
         NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define global variables in file id %d",
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       goto error_ret; /* exit define mode and return */
     }
     ex_compress_variable(exoid, varid, 2);
@@ -253,12 +251,12 @@ int ex_put_variable_param(int exoid, ex_entity_type obj_type, int num_vars)
                  "ERROR: nodal variable name parameters are already "
                  "defined in file id %d",
                  exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
       }
       else {
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to define number of nodal variables in file id %d", exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
       }
       goto error_ret; /* exit define mode and return */
     }
@@ -271,7 +269,7 @@ int ex_put_variable_param(int exoid, ex_entity_type obj_type, int num_vars)
           NC_NOERR) {
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to define nodal variable %d in file id %d",
                  i, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         goto error_ret; /* exit define mode and return */
       }
       ex_compress_variable(exoid, varid, 2);
@@ -284,12 +282,12 @@ int ex_put_variable_param(int exoid, ex_entity_type obj_type, int num_vars)
       if (status == NC_ENAMEINUSE) {
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: nodal variable names are already defined in file id %d", exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
       }
       else {
         snprintf(errmsg, MAX_ERR_LENGTH,
                  "ERROR: failed to define nodal variable names in file id %d", exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
       }
       goto error_ret; /* exit define mode and return */
     }
@@ -350,9 +348,7 @@ int ex_put_variable_param(int exoid, ex_entity_type obj_type, int num_vars)
   }
 
   /* leave define mode  */
-  if ((status = nc_enddef(exoid)) != NC_NOERR) {
-    snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to complete definition in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+  if ((status = ex_leavedef(exoid, __func__)) != NC_NOERR) {
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -360,9 +356,6 @@ int ex_put_variable_param(int exoid, ex_entity_type obj_type, int num_vars)
 
 /* Fatal error: exit definition mode and return */
 error_ret:
-  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);
-  }
+  ex_leavedef(exoid, __func__);
   EX_FUNC_LEAVE(EX_FATAL);
 }
diff --git a/src/ex_threadsafe.c b/src/ex_threadsafe.c
index 888ad532ee4..607daf93aa6 100644
--- a/src/ex_threadsafe.c
+++ b/src/ex_threadsafe.c
@@ -39,9 +39,6 @@
 
 #include "exodusII_int.h"
 
-#include <stdio.h>
-#include <string.h>
-
 /* NOTE: All code in this file is based on the thread-safe code from the
  * hdf5 library.
  */
diff --git a/src/ex_update.c b/src/ex_update.c
index 1cbbee74207..34c5a70cae4 100644
--- a/src/ex_update.c
+++ b/src/ex_update.c
@@ -47,8 +47,6 @@
 
 #include "exodusII.h"     // for ex_err, etc
 #include "exodusII_int.h" // for EX_FATAL, EX_NOERR
-#include "vtk_netcdf.h"       // for nc_sync, NC_NOERR
-#include <stdio.h>
 
 /*!
  * updates an opened EXODUS file (or EXODUS history file)
@@ -66,7 +64,7 @@ int ex_update(int exoid)
 
   if ((status = nc_sync(exoid)) != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to update file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
   EX_FUNC_LEAVE(EX_NOERR);
diff --git a/src/ex_utils.c b/src/ex_utils.c
index e8b6741d708..8111f8d8f32 100644
--- a/src/ex_utils.c
+++ b/src/ex_utils.c
@@ -39,16 +39,9 @@
  *****************************************************************************/
 
 #if defined(DEBUG_QSORT)
-#include <assert.h>
 #endif
 
-#include <ctype.h>
 #include <errno.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
 
 #include "exodusII.h"
 #include "exodusII_int.h"
@@ -82,6 +75,76 @@ struct obj_stats *exoII_nm  = 0;
 static char  ret_string[10 * (MAX_VAR_NAME_LENGTH + 1)];
 static char *cur_string = &ret_string[0];
 
+#if NC_HAS_HDF5
+extern int H5get_libversion(unsigned *, unsigned *, unsigned *);
+#endif
+
+#if NC_HAS_PNETCDF
+extern char *ncmpi_inq_libvers();
+#endif
+
+void ex_print_config(void)
+{
+  fprintf(stderr, "\tExodus Version %.2f\n", EX_API_VERS);
+#if defined(PARALLEL_AWARE_EXODUS)
+  fprintf(stderr, "\t\tParallel enabled\n");
+#else
+  fprintf(stderr, "\t\tParallel NOT enabled\n");
+#endif
+#if defined(EXODUS_THREADSAFE)
+  fprintf(stderr, "\t\tThread Safe enabled\n");
+#else
+  fprintf(stderr, "\t\tThread Safe NOT enabled\n");
+#endif
+#if defined(SEACAS_HIDE_DEPRECATED_CODE)
+  fprintf(stderr, "\t\tDeprecated Functions NOT built\n\n");
+#else
+  fprintf(stderr, "\t\tDeprecated Functions available\n\n");
+#endif
+#if defined(NC_VERSION)
+  fprintf(stderr, "\tNetCDF Version %s\n", NC_VERSION);
+#else
+  fprintf(stderr, "\tNetCDF Version < 4.3.3\n");
+#endif
+#if NC_HAS_CDF5
+  fprintf(stderr, "\t\tCDF5 enabled\n");
+#endif
+#if NC_HAS_HDF5
+  {
+    unsigned major, minor, release;
+    H5get_libversion(&major, &minor, &release);
+    fprintf(stderr, "\t\tHDF5 enabled (%u.%u.%u)\n", major, minor, release);
+  }
+#endif
+#if NC_HAS_PARALLEL
+  fprintf(stderr, "\t\tparallel IO enabled via HDF5 and/or PnetCDF\n");
+#endif
+#if NC_HAS_PARALLEL4
+  fprintf(stderr, "\t\tparallel IO enabled via HDF5\n");
+#endif
+#if NC_HAS_PNETCDF
+  {
+    char *libver = ncmpi_inq_libvers();
+    fprintf(stderr, "\t\tparallel IO enabled via PnetCDF (%s)\n", libver);
+  }
+#endif
+#if NC_HAS_ERANGE_FILL
+  fprintf(stderr, "\t\tERANGE_FILL support\n");
+#endif
+#if NC_RELAX_COORD_BOUND
+  fprintf(stderr, "\t\tRELAX_COORD_BOUND defined\n");
+#endif
+#if defined(NC_HAVE_META_H)
+  fprintf(stderr, "\t\tNC_HAVE_META_H defined\n");
+#endif
+#if defined(NC_HAS_NC2)
+  fprintf(stderr, "\t\tAPI Version 2 support enabled\n");
+#else
+  fprintf(stderr, "\t\tAPI Version 2 support NOT enabled\n");
+#endif
+  fprintf(stderr, "\n");
+}
+
 int ex_check_file_type(const char *path, int *type)
 {
   /* Based on (stolen from?) NC_check_file_type from netcdf sources.
@@ -141,13 +204,13 @@ int ex_set_max_name_length(int exoid, int length)
   ex_check_valid_file_id(exoid, __func__);
   if (length <= 0) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: Max name length must be positive.");
-    ex_err(__func__, errmsg, NC_EMAXNAME);
+    ex_err_fn(exoid, __func__, errmsg, NC_EMAXNAME);
     EX_FUNC_LEAVE(EX_FATAL);
   }
   if (length > NC_MAX_NAME) {
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: Max name length (%d) exceeds netcdf max name size (%d).", length, NC_MAX_NAME);
-    ex_err(__func__, errmsg, NC_EMAXNAME);
+    ex_err_fn(exoid, __func__, errmsg, NC_EMAXNAME);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -170,7 +233,7 @@ void ex_update_max_name_length(int exoid, int length)
     char errmsg[MAX_ERR_LENGTH];
     snprintf(errmsg, MAX_ERR_LENGTH,
              "ERROR: failed to update 'max_name_length' attribute in file id %d", exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
   }
 
   if (length > db_length) {
@@ -205,9 +268,8 @@ int ex_put_names_internal(int exoid, int varid, size_t num_entity, char **names,
   for (i = 0; i < num_entity; i++) {
     if (names != NULL && *names != NULL && *names[i] != '\0') {
       found_name = 1;
-      strncpy(&int_names[idx], names[i], name_length - 1);
-      int_names[idx + name_length - 1] = '\0';
-      length                           = strlen(names[i]) + 1;
+      ex_copy_string(&int_names[idx], names[i], name_length);
+      length = strlen(names[i]) + 1;
       if (length > name_length) {
         fprintf(stderr,
                 "Warning: The %s %s name '%s' is too long.\n\tIt will "
@@ -228,7 +290,7 @@ int ex_put_names_internal(int exoid, int varid, size_t num_entity, char **names,
     free(int_names);
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to store %s names in file id %d",
              ex_name_of_object(obj_type), exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     EX_FUNC_LEAVE(EX_FATAL);
   }
 
@@ -275,7 +337,7 @@ int ex_put_name_internal(int exoid, int varid, size_t index, const char *name,
     if ((status = nc_put_vara_text(exoid, varid, start, count, name)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to store %s name in file id %d",
                ex_name_of_object(obj_type), exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       return (EX_FATAL);
     }
 
@@ -333,7 +395,7 @@ int ex_get_name_internal(int exoid, int varid, size_t index, char *name, int nam
   if (status != NC_NOERR) {
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get %s name at index %d from file id %d",
              ex_name_of_object(obj_type), (int)index, exoid);
-    ex_err(__func__, errmsg, status);
+    ex_err_fn(exoid, __func__, errmsg, status);
     return (EX_FATAL);
   }
 
@@ -634,7 +696,7 @@ int ex_id_lkup(int exoid, ex_entity_type id_type, ex_entity_id num)
   default:
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: unsupported id array type %d for file id %d", id_type,
              exoid);
-    ex_err(__func__, errmsg, EX_BADPARAM);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
     return (EX_FATAL);
   }
 
@@ -648,7 +710,7 @@ int ex_id_lkup(int exoid, ex_entity_type id_type, ex_entity_id num)
     if ((status = nc_inq_dimid(exoid, id_dim, &dimid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate id array dimension in file id %d",
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       return (EX_FATAL);
     }
 
@@ -656,7 +718,7 @@ int ex_id_lkup(int exoid, ex_entity_type id_type, ex_entity_id num)
     if ((status = nc_inq_dimlen(exoid, dimid, &dim_len)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate %s array length in file id %d",
                id_table, exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       return (EX_FATAL);
     }
 
@@ -664,7 +726,7 @@ int ex_id_lkup(int exoid, ex_entity_type id_type, ex_entity_id num)
     if ((status = nc_inq_varid(exoid, id_table, &varid)) != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate %s array in file id %d", id_table,
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       return (EX_FATAL);
     }
 
@@ -673,7 +735,7 @@ int ex_id_lkup(int exoid, ex_entity_type id_type, ex_entity_id num)
     if (!(id_vals = calloc(dim_len, sizeof(int64_t)))) {
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to allocate memory for %s array for file id %d", id_table, exoid);
-      ex_err(__func__, errmsg, EX_MEMFAIL);
+      ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
       return (EX_FATAL);
     }
 
@@ -687,7 +749,7 @@ int ex_id_lkup(int exoid, ex_entity_type id_type, ex_entity_id num)
                  "ERROR: failed to allocate memory for temporary array "
                  "id_vals_int for file id %d",
                  exoid);
-        ex_err(__func__, errmsg, EX_MEMFAIL);
+        ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
         free(id_vals);
         return (EX_FATAL);
       }
@@ -703,7 +765,7 @@ int ex_id_lkup(int exoid, ex_entity_type id_type, ex_entity_id num)
     if (status != NC_NOERR) {
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get %s array from file id %d", id_table,
                exoid);
-      ex_err(__func__, errmsg, status);
+      ex_err_fn(exoid, __func__, errmsg, status);
       free(id_vals);
       return (EX_FATAL);
     }
@@ -766,7 +828,7 @@ int ex_id_lkup(int exoid, ex_entity_type id_type, ex_entity_id num)
       free(id_vals);
       snprintf(errmsg, MAX_ERR_LENGTH,
                "ERROR: failed to allocate memory for %s array for file id %d", id_table, exoid);
-      ex_err(__func__, errmsg, EX_MEMFAIL);
+      ex_err_fn(exoid, __func__, errmsg, EX_MEMFAIL);
       return (EX_FATAL);
     }
 
@@ -781,7 +843,7 @@ int ex_id_lkup(int exoid, ex_entity_type id_type, ex_entity_id num)
         free(stat_vals);
         snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get %s array from file id %d",
                  stat_table, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
         return (EX_FATAL);
       }
     }
@@ -802,7 +864,7 @@ int ex_id_lkup(int exoid, ex_entity_type id_type, ex_entity_id num)
   }
 
   if (stat_vals[i] == 0) /* is this object null? */ {
-    ex_err(__func__, "", EX_NULLENTITY);
+    ex_err_fn(exoid, __func__, "", EX_NULLENTITY);
     if (!(tmp_stats->valid_stat)) {
       free(stat_vals);
     }
@@ -1109,7 +1171,7 @@ int ex_get_num_props(int exoid, ex_entity_type obj_type)
     default:
       snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: object type %d not supported; file id %d", obj_type,
                exoid);
-      ex_err(__func__, errmsg, EX_BADPARAM);
+      ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
       EX_FUNC_LEAVE(EX_FATAL);
     }
 
@@ -1345,7 +1407,7 @@ void ex_iqsort64(int64_t v[], int64_t iv[], int64_t N)
   ex_int_iisort64(v, iv, N);
 
 #if defined(DEBUG_QSORT)
-  fprintf(stderr, "Checking sort of %d values\n", N + 1);
+  fprintf(stderr, "Checking sort of %" PRId64 " values\n", N + 1);
   int i;
   for (i = 1; i < N; i++) {
     assert(v[iv[i - 1]] <= v[iv[i]]);
@@ -1413,13 +1475,13 @@ int ex_get_dimension(int exoid, const char *DIMENSION, const char *label, size_t
       if (status == NC_EBADDIM) {
         snprintf(errmsg, MAX_ERR_LENGTH, "Warning: no dimension defining '%s' found in file id %d",
                  label, exoid);
-        ex_err(__func__, errmsg, status);
+        ex_err_fn(exoid, __func__, errmsg, status);
       }
       else {
         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);
+        ex_err_fn(exoid, __func__, errmsg, status);
       }
     }
     return status;
@@ -1430,7 +1492,7 @@ int ex_get_dimension(int exoid, const char *DIMENSION, const char *label, size_t
       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);
+      ex_err_fn(exoid, __func__, errmsg, status);
     }
     return status;
   }
@@ -1451,14 +1513,16 @@ void ex_compress_variable(int exoid, int varid, int type)
     char errmsg[MAX_ERR_LENGTH];
     snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: unknown file id %d for ex_compress_variable().",
              exoid);
-    ex_err(__func__, errmsg, EX_BADFILEID);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADFILEID);
   }
   else {
     int deflate_level = file->compression_level;
     int compress      = 1;
     int shuffle       = file->shuffle;
-    if (!file->is_parallel && deflate_level > 0 && (file->file_type == 2 || file->file_type == 3)) {
-      nc_def_var_deflate(exoid, varid, shuffle, compress, deflate_level);
+    if (deflate_level > 0 && file->is_hdf5) {
+      if (type != 3) { /* Do not try to compress character data */
+        nc_def_var_deflate(exoid, varid, shuffle, compress, deflate_level);
+      }
     }
 #if defined(PARALLEL_AWARE_EXODUS)
     if (type != 3 && file->is_parallel && file->is_hdf5) {
@@ -1468,3 +1532,490 @@ void ex_compress_variable(int exoid, int varid, int type)
   }
 #endif
 }
+
+int ex_leavedef(int exoid, const char *call_rout)
+{
+  char errmsg[MAX_ERR_LENGTH];
+  int  status;
+
+  if ((status = nc_enddef(exoid)) != NC_NOERR) {
+    snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to complete definition for file id %d", exoid);
+    ex_err_fn(exoid, call_rout, errmsg, status);
+
+    return (EX_FATAL);
+  }
+  return (EX_NOERR);
+}
+
+static int warning_output = 0;
+
+int ex_int_handle_mode(unsigned int my_mode, int is_parallel, int run_version)
+{
+  char       errmsg[MAX_ERR_LENGTH];
+  int        nc_mode      = 0;
+  static int netcdf4_mode = -1;
+#if NC_HAS_CDF5
+  static int netcdf5_mode = -1;
+#endif
+
+  int filesiz = 1;
+  int int64_status;
+  int pariomode = 0;
+
+  /* Contains a 1 in all bits corresponding to file modes */
+  /* Do not include EX_64BIT_DATA in this list */
+  static unsigned int all_modes = EX_NORMAL_MODEL | EX_64BIT_OFFSET | EX_NETCDF4 | EX_PNETCDF;
+
+  if (run_version != EX_API_VERS_NODOT && warning_output == 0) {
+    int run_version_major = run_version / 100;
+    int run_version_minor = run_version % 100;
+    int lib_version_major = EX_API_VERS_NODOT / 100;
+    int lib_version_minor = EX_API_VERS_NODOT % 100;
+    fprintf(stderr,
+            "EXODUS: Warning: This code was compiled with exodusII "
+            "version %d.%02d,\n          but was linked with exodusII "
+            "library version %d.%02d\n          This is probably an "
+            "error in the build process of this code.\n",
+            run_version_major, run_version_minor, lib_version_major, lib_version_minor);
+    warning_output = 1;
+  }
+
+/*
+ * See if specified mode is supported in the version of netcdf we
+ * are using
+ */
+#if !NC_HAS_HDF5
+  if (my_mode & EX_NETCDF4) {
+    snprintf(errmsg, MAX_ERR_LENGTH,
+             "EXODUS: ERROR: File format specified as netcdf-4, but the "
+             "NetCDF library being used was not configured to enable "
+             "this format\n");
+    ex_err(__func__, errmsg, EX_BADPARAM);
+    EX_FUNC_LEAVE(EX_FATAL);
+  }
+#endif
+
+#if !NC_HAS_CDF5
+  if (my_mode & EX_64BIT_DATA) {
+    snprintf(errmsg, MAX_ERR_LENGTH,
+             "EXODUS: ERROR: File format specified as 64bit_data, but "
+             "the NetCDF library being used does not support this "
+             "format\n");
+    ex_err(__func__, errmsg, EX_BADPARAM);
+    EX_FUNC_LEAVE(EX_FATAL);
+  }
+#endif
+
+  /* EX_64_BIT_DATA is 64-bit integer version of EX_PNETCDF.  If
+     EX_64_BIT_DATA and EX_PNETCDF is not set, then set EX_PNETCDF... */
+  if (my_mode & EX_64BIT_DATA) {
+    my_mode |= EX_PNETCDF;
+  }
+
+  /* Check that one and only one format mode is specified... */
+  {
+    unsigned int set_modes = all_modes & my_mode;
+
+    if (set_modes == 0) {
+      my_mode |= EX_64BIT_OFFSET; /* Default if nothing specified */
+    }
+    else {
+      /* Checks that only a single bit is set */
+      set_modes = set_modes && !(set_modes & (set_modes - 1));
+      if (!set_modes) {
+        snprintf(errmsg, MAX_ERR_LENGTH,
+                 "EXODUS: ERROR: More than 1 file format "
+                 "(EX_NORMAL_MODEL, EX_LARGE_MODEL, EX_64BIT_OFFSET, "
+                 "or EX_NETCDF4)\nwas specified in the "
+                 "mode argument of the ex_create call. Only a single "
+                 "format can be specified.\n");
+        ex_err(__func__, errmsg, EX_BADPARAM);
+        EX_FUNC_LEAVE(EX_FATAL);
+      }
+    }
+  }
+
+  /*
+   * See if any integer data is to be stored as int64 (long long). If
+   * so, then need to set NC_NETCDF4 and unset NC_CLASSIC_MODEL (or
+   * set EX_NOCLASSIC.  Output meaningful error message if the library
+   * is not NetCDF-4 enabled...
+   *
+   * As of netcdf-4.4.0, can also use NC_64BIT_DATA (CDF5) mode for this...
+   */
+  int64_status = my_mode & (EX_ALL_INT64_DB | EX_ALL_INT64_API);
+
+  if ((int64_status & EX_ALL_INT64_DB) != 0) {
+#if NC_HAS_HDF5 || NC_HAS_CDF5
+    /* Library DOES support netcdf4 and/or cdf5 ... See if user
+     * specified either of these and use that one; if not, pick
+     * netcdf4, non-classic as default.
+     */
+    if (my_mode & EX_NETCDF4) {
+      my_mode |= EX_NOCLASSIC;
+    }
+#if NC_HAS_CDF5
+    else if (my_mode & EX_64BIT_DATA) {
+      ; /* Do nothing, already set */
+    }
+    else if (my_mode & EX_PNETCDF) {
+      my_mode |= EX_64BIT_DATA;
+    }
+#endif
+    else {
+      /* Unset the current mode so we don't have multiples specified */
+      /* ~all_modes sets to 1 all bits not associated with file format */
+      my_mode &= ~all_modes;
+#if NC_HAS_HDF5
+      /* Pick netcdf4 as default mode for 64-bit integers */
+      my_mode |= EX_NOCLASSIC;
+      my_mode |= EX_NETCDF4;
+#else
+      /* Pick 64bit_data as default mode for 64-bit integers */
+      my_mode |= EX_64BIT_DATA;
+#endif
+    }
+#else
+    /* Library does NOT support netcdf4 or cdf5 */
+    snprintf(errmsg, MAX_ERR_LENGTH,
+             "EXODUS: ERROR: 64-bit integer storage requested, but the "
+             "netcdf library does not support the required netcdf-4 or "
+             "64BIT_DATA extensions.\n");
+    ex_err(__func__, errmsg, EX_BADPARAM);
+    EX_FUNC_LEAVE(EX_FATAL);
+#endif
+  }
+
+#if defined(PARALLEL_AWARE_EXODUS)
+  /* 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.
+   */
+  if (is_parallel) {
+    int tmp_mode = 0;
+    if (my_mode & EX_MPIPOSIX) {
+      pariomode = NC_MPIIO;
+      tmp_mode  = EX_NETCDF4;
+#if !NC_HAS_HDF5
+      snprintf(errmsg, MAX_ERR_LENGTH,
+               "EXODUS: ERROR: EX_MPIPOSIX 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_MPIIO) {
+      pariomode = NC_MPIIO;
+      tmp_mode  = EX_NETCDF4;
+#if !NC_HAS_HDF5
+      snprintf(errmsg, MAX_ERR_LENGTH,
+               "EXODUS: ERROR: EX_MPIIO 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_NETCDF4) {
+      pariomode = NC_MPIIO;
+      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) {
+      pariomode = NC_PNETCDF;
+      /* See if client specified 64-bit or not... */
+      if ((my_mode & EX_64BIT_DATA) || (int64_status & EX_ALL_INT64_DB)) {
+        tmp_mode = EX_64BIT_DATA;
+      }
+      else {
+        if (my_mode & EX_64BIT_DATA) {
+          tmp_mode = EX_64BIT_DATA;
+        }
+        else {
+          tmp_mode = EX_64BIT_OFFSET;
+        }
+      }
+#if !NC_HAS_PNETCDF
+      snprintf(errmsg, MAX_ERR_LENGTH,
+               "EXODUS: ERROR: EX_PNETCDF parallel output requested "
+               "which requires PNetCDF support, but the library does "
+               "not have that option enabled.\n");
+      ex_err(__func__, errmsg, EX_BADPARAM);
+      EX_FUNC_LEAVE(EX_FATAL);
+#endif
+    }
+
+    /* If tmp_mode was set here, then need to clear any other mode that
+       was potentially already set in my_mode... */
+    my_mode &= ~all_modes;
+    my_mode |= tmp_mode;
+  }
+#endif /* PARALLEL_AWARE_EXODUS */
+
+  if (my_mode & EX_NETCDF4) {
+    nc_mode |= NC_NETCDF4;
+  }
+  else {
+    if (netcdf4_mode == -1) {
+      char *option = getenv("EXODUS_NETCDF4");
+      if (option != NULL) {
+        netcdf4_mode = NC_NETCDF4;
+        if (option[0] != 'q') {
+          fprintf(stderr, "EXODUS: Using netcdf version 4 selected via "
+                          "EXODUS_NETCDF4 environment variable\n");
+        }
+      }
+      else {
+        netcdf4_mode = 0;
+      }
+    }
+    nc_mode |= netcdf4_mode;
+  }
+
+  if (!(my_mode & EX_NOCLASSIC)) {
+    nc_mode |= NC_CLASSIC_MODEL;
+  }
+
+#if NC_HAS_CDF5
+  if (my_mode & EX_64BIT_DATA) {
+    nc_mode |= (NC_64BIT_DATA);
+  }
+  else {
+    if (netcdf5_mode == -1) {
+      char *option = getenv("EXODUS_NETCDF5");
+      if (option != NULL) {
+        netcdf5_mode = NC_64BIT_DATA;
+        if (option[0] != 'q') {
+          fprintf(stderr, "EXODUS: Using netcdf version 5 (CDF5) selected via "
+                          "EXODUS_NETCDF5 environment variable\n");
+        }
+      }
+      else {
+        netcdf5_mode = 0;
+      }
+    }
+    nc_mode |= netcdf5_mode;
+  }
+#endif
+
+  /*
+   * Hardwire filesiz to 1 for all created files. Reduce complexity in nodal output routines.
+   * has been default for a decade or so, but still support it on read...
+   */
+  if (
+#if NC_HAS_HDF5
+      !(nc_mode & NC_NETCDF4) &&
+#endif
+#if NC_HAS_CDF5
+      !(nc_mode & NC_64BIT_DATA) &&
+#endif
+      filesiz == 1) {
+    nc_mode |= NC_64BIT_OFFSET;
+  }
+
+  if (my_mode & EX_SHARE) {
+    nc_mode |= NC_SHARE;
+  }
+
+  /*
+   * set error handling mode to no messages, non-fatal errors
+   * unless specified differently via environment.
+   */
+  {
+    char *option = getenv("EXODUS_VERBOSE");
+    if (option != NULL) {
+      exoptval = EX_VERBOSE;
+    }
+    ex_opts(exoptval); /* call required to set ncopts first time through */
+  }
+
+  if (my_mode & EX_CLOBBER) {
+    nc_mode |= NC_CLOBBER;
+  }
+  else {
+    nc_mode |= NC_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;
+#if defined NC_PERSIST
+    nc_mode |= NC_PERSIST;
+#endif
+  }
+#endif
+  return nc_mode | pariomode;
+}
+
+int ex_int_populate_header(int exoid, const char *path, int my_mode, int is_parallel, int *comp_ws,
+                           int *io_ws)
+{
+  int status;
+  int old_fill;
+  int lio_ws;
+  int filesiz    = 1;
+  int is_hdf5    = 0;
+  int is_pnetcdf = 0;
+
+  float vers;
+  char  errmsg[MAX_ERR_LENGTH];
+  int   int64_status = my_mode & (EX_ALL_INT64_DB | EX_ALL_INT64_API);
+
+  /* turn off automatic filling of netCDF variables */
+  if ((status = nc_set_fill(exoid, NC_NOFILL, &old_fill)) != NC_NOERR) {
+    snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to set nofill mode in file id %d", exoid);
+    ex_err_fn(exoid, __func__, errmsg, status);
+    return (EX_FATAL);
+  }
+
+  /* Verify that there is not an existing file_item struct for this
+     exoid This could happen (and has) when application calls
+     ex_open(), but then closes file using nc_close() and then reopens
+     file.  NetCDF will possibly reuse the exoid which results in
+     internal corruption in exodus data structures since exodus does
+     not know that file was closed and possibly new file opened for
+     this exoid
+  */
+  if (ex_find_file_item(exoid) != NULL) {
+    snprintf(errmsg, MAX_ERR_LENGTH,
+             "ERROR: There is an existing file already using the file "
+             "id %d which was also assigned to file %s.\n\tWas "
+             "nc_close() called instead of ex_close() on an open Exodus "
+             "file?\n",
+             exoid, path);
+    ex_err_fn(exoid, __func__, errmsg, EX_BADFILEID);
+    nc_close(exoid);
+    return (EX_FATAL);
+  }
+
+  /* initialize floating point size conversion.  since creating new file,
+   * i/o wordsize attribute from file is zero.
+   */
+  if (my_mode & EX_PNETCDF) {
+    is_pnetcdf = 1;
+  }
+
+  if (my_mode & EX_NETCDF4) {
+    is_hdf5 = 1;
+  }
+
+  /*
+   * NetCDF has deprecated use of MPIIO and MPIPOSIX and instead rely
+   * on explicitly specifying either NetCDF-4 of PNetCDF output. For
+   * backward-compatibility, we map the MPIIO and MPIPOSIX over to
+   * NetCDF4 which is hdf5-based...
+   */
+  if (is_parallel && ((my_mode & EX_MPIIO) || (my_mode & EX_MPIPOSIX))) {
+    is_hdf5 = 1;
+  }
+
+  if (ex_conv_ini(exoid, comp_ws, io_ws, 0, int64_status, is_parallel, is_hdf5, is_pnetcdf) !=
+      EX_NOERR) {
+    snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to init conversion routines in file id %d",
+             exoid);
+    ex_err_fn(exoid, __func__, errmsg, EX_LASTERR);
+    return (EX_FATAL);
+  }
+
+  /* put the EXODUS version number, and i/o floating point word size as
+   * netcdf global attributes
+   */
+
+  /* store Exodus API version # as an attribute */
+  vers = EX_API_VERS;
+  if ((status = nc_put_att_float(exoid, NC_GLOBAL, ATT_API_VERSION, NC_FLOAT, 1, &vers)) !=
+      NC_NOERR) {
+    snprintf(errmsg, MAX_ERR_LENGTH,
+             "ERROR: failed to store Exodus II API version attribute in file id %d", exoid);
+    ex_err_fn(exoid, __func__, errmsg, status);
+    return (EX_FATAL);
+  }
+
+  /* store Exodus file version # as an attribute */
+  vers = EX_VERS;
+  if ((status = nc_put_att_float(exoid, NC_GLOBAL, ATT_VERSION, NC_FLOAT, 1, &vers)) != NC_NOERR) {
+    snprintf(errmsg, MAX_ERR_LENGTH,
+             "ERROR: failed to store Exodus II file version attribute in file id %d", exoid);
+    ex_err_fn(exoid, __func__, errmsg, status);
+    return (EX_FATAL);
+  }
+
+  /* store Exodus file float word size  as an attribute */
+  lio_ws = (*io_ws);
+  if ((status = nc_put_att_int(exoid, NC_GLOBAL, ATT_FLT_WORDSIZE, NC_INT, 1, &lio_ws)) !=
+      NC_NOERR) {
+    snprintf(errmsg, MAX_ERR_LENGTH,
+             "ERROR: failed to store Exodus II file float word size "
+             "attribute in file id %d",
+             exoid);
+    ex_err_fn(exoid, __func__, errmsg, status);
+    return (EX_FATAL);
+  }
+
+  /* store Exodus file size (1=large, 0=normal) as an attribute */
+  if ((status = nc_put_att_int(exoid, NC_GLOBAL, ATT_FILESIZE, NC_INT, 1, &filesiz)) != NC_NOERR) {
+    snprintf(errmsg, MAX_ERR_LENGTH,
+             "ERROR: failed to store Exodus II file size attribute in file id %d", exoid);
+    ex_err_fn(exoid, __func__, errmsg, status);
+    return (EX_FATAL);
+  }
+
+  {
+    int max_so_far = 32;
+    if ((status = nc_put_att_int(exoid, NC_GLOBAL, ATT_MAX_NAME_LENGTH, NC_INT, 1, &max_so_far)) !=
+        NC_NOERR) {
+      snprintf(errmsg, MAX_ERR_LENGTH,
+               "ERROR: failed to add maximum_name_length attribute in file id %d", exoid);
+      ex_err_fn(exoid, __func__, errmsg, status);
+      return (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,
+                                 &int64_db_status)) != NC_NOERR) {
+      snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to add int64_status attribute in file id %d",
+               exoid);
+      ex_err_fn(exoid, __func__, errmsg, status);
+      return (EX_FATAL);
+    }
+  }
+
+#if 0
+  /* Testing to see if can eliminate some nc_enddef movement of vars/recs */
+  if ((status = nc__enddef(exoid, 10000, 4, 10000, 4)) != NC_NOERR) {
+#else
+  if ((status = nc_enddef(exoid)) != NC_NOERR) {
+#endif
+  snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to complete definition for file id %d", exoid);
+  ex_err_fn(exoid, __func__, errmsg, status);
+  return (EX_FATAL);
+}
+return EX_NOERR;
+}
+
+/* Safer than strncpy -- guarantees null termination */
+char *ex_copy_string(char *dest, char const *source, size_t elements)
+{
+  char *d;
+  for (d = dest; d + 1 < dest + elements && *source; d++, source++) {
+    *d = *source;
+  }
+  *d = '\0';
+  return d;
+}
-- 
GitLab