Debian Codegraph @

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

raw
1 /*
2 * Copyright(C) 1999-2020 National Technology & Engineering Solutions
3 * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
4 * NTESS, the U.S. Government retains certain rights in this software.
5 *
6 * See packages/seacas/LICENSE for details
7 */
8 /*****************************************************************************/
9 /*****************************************************************************/
10 /*****************************************************************************/
11 /* Function(s) contained in this file:
12 * ex_get_ns_param_global()
13 *****************************************************************************
14 * This function retrieves the global node-set parameters.
15 *****************************************************************************
16 * Variable Index:
17 * exoid - The NetCDF ID of an already open NemesisI file.
18 * global_ids - Pointer to a vector of global node-set IDs.
19 * node_cnts - Pointer to a vector of global node counts in
20 * each global node set.
21 * df_cnts - Pointer to a vector of global distribution
22 * factors in each global node set.
23 */
24 /*****************************************************************************/
25 /*****************************************************************************/
26 /*****************************************************************************/
27 #include <exodusII.h> // for ex_err, etc
28 #include <exodusII_int.h> // for EX_FATAL, etc
29
30 int ex_get_ns_param_global(int exoid, void_int *global_ids, void_int *node_cnts, void_int *df_cnts)
31 {
32 int varid, status;
33
34 char errmsg[MAX_ERR_LENGTH];
35 /*-----------------------------Execution begins-----------------------------*/
36
37 EX_FUNC_ENTER();
38 if (exi_check_valid_file_id(exoid, __func__) == EX_FATAL) {
39 EX_FUNC_LEAVE(EX_FATAL);
40 }
41
42 /* Get the variable ID for the vector of global node set IDs */
43 if ((status = nc_inq_varid(exoid, VAR_NS_IDS_GLOBAL, &varid)) != NC_NOERR) {
44 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
45 VAR_NS_IDS_GLOBAL, exoid);
46 ex_err_fn(exoid, __func__, errmsg, status);
47
48 EX_FUNC_LEAVE(EX_FATAL);
49 }
50
51 /* Get the vector of node set IDs */
52 if (ex_int64_status(exoid) & EX_IDS_INT64_API) {
53 status = nc_get_var_longlong(exoid, varid, global_ids);
54 }
55 else {
56 status = nc_get_var_int(exoid, varid, global_ids);
57 }
58 if (status != NC_NOERR) {
59 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get variable \"%s\" from file ID %d",
60 VAR_NS_IDS_GLOBAL, exoid);
61 ex_err_fn(exoid, __func__, errmsg, status);
62
63 EX_FUNC_LEAVE(EX_FATAL);
64 }
65
66 /* Get the variable ID for the vector of global node set node count */
67 if (node_cnts != NULL) {
68 if ((status = nc_inq_varid(exoid, VAR_NS_NODE_CNT_GLOBAL, &varid)) != NC_NOERR) {
69 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
70 VAR_NS_NODE_CNT_GLOBAL, exoid);
71 ex_err_fn(exoid, __func__, errmsg, status);
72
73 EX_FUNC_LEAVE(EX_FATAL);
74 }
75
76 /* Get the vector of node set node counts */
77 if (ex_int64_status(exoid) & EX_BULK_INT64_API) {
78 status = nc_get_var_longlong(exoid, varid, node_cnts);
79 }
80 else {
81 status = nc_get_var_int(exoid, varid, node_cnts);
82 }
83 if (status != NC_NOERR) {
84 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get variable \"%s\" from file ID %d",
85 VAR_NS_NODE_CNT_GLOBAL, exoid);
86 ex_err_fn(exoid, __func__, errmsg, status);
87
88 EX_FUNC_LEAVE(EX_FATAL);
89 }
90
91 } /* End "if (node_cnts != NULL)" */
92
93 /* Get the variable ID for the vector of global node set dist. fact count */
94 if (df_cnts != NULL) {
95 if ((status = nc_inq_varid(exoid, VAR_NS_DF_CNT_GLOBAL, &varid)) != NC_NOERR) {
96 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
97 VAR_NS_DF_CNT_GLOBAL, exoid);
98 ex_err_fn(exoid, __func__, errmsg, status);
99
100 EX_FUNC_LEAVE(EX_FATAL);
101 }
102
103 /* Get the vector of node set dist. fact counts */
104 if (ex_int64_status(exoid) & EX_BULK_INT64_API) {
105 status = nc_get_var_longlong(exoid, varid, df_cnts);
106 }
107 else {
108 status = nc_get_var_int(exoid, varid, df_cnts);
109 }
110 if (status != NC_NOERR) {
111 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get variable \"%s\" from file ID %d",
112 VAR_NS_DF_CNT_GLOBAL, exoid);
113 ex_err_fn(exoid, __func__, errmsg, status);
114
115 EX_FUNC_LEAVE(EX_FATAL);
116 }
117 } /* End "if (df_cnts != NULL)" */
118 EX_FUNC_LEAVE(EX_NOERR);
119 }