Debian Codegraph @

packages/seacas/libraries/exodus/src/ex_put_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 /*****************************************************************************/
12 /* Function(s) contained in this file:
13 * ex_put_ns_param_global()
14 *****************************************************************************
15 * This function outputs the global node-set parameters.
16 *****************************************************************************
17 * Variable Index:
18 * exoid - The NetCDF ID of an already open NemesisI file.
19 * global_ids - Pointer to a vector of global node-set IDs.
20 * node_cnts - Pointer to a vector of global node counts in
21 * each global node set.
22 * df_cnts - Pointer to a vector of global distribution
23 * factors in each global node set.
24 */
25 /*****************************************************************************/
26 /*****************************************************************************/
27 /*****************************************************************************/
28
29 #include <exodusII.h>
30 #include <exodusII_int.h>
31
32 int ex_put_ns_param_global(int exoid, const void_int *global_ids, const void_int *node_cnts,
33 const void_int *df_cnts)
34 {
35 int varid, status;
36
37 char errmsg[MAX_ERR_LENGTH];
38 /*-----------------------------Execution begins-----------------------------*/
39
40 EX_FUNC_ENTER();
41 if (exi_check_valid_file_id(exoid, __func__) == EX_FATAL) {
42 EX_FUNC_LEAVE(EX_FATAL);
43 }
44
45 /* Get the variable ID for the vector of global node set IDs */
46 if ((status = nc_inq_varid(exoid, VAR_NS_IDS_GLOBAL, &varid)) != NC_NOERR) {
47 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
48 VAR_NS_IDS_GLOBAL, exoid);
49 ex_err_fn(exoid, __func__, errmsg, status);
50
51 EX_FUNC_LEAVE(EX_FATAL);
52 }
53
54 /* Output the vector of global node set IDs */
55 if (ex_int64_status(exoid) & EX_IDS_INT64_API) {
56 status = nc_put_var_longlong(exoid, varid, global_ids);
57 }
58 else {
59 status = nc_put_var_int(exoid, varid, global_ids);
60 }
61 if (status != NC_NOERR) {
62 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to output variable \"%s\" to file ID %d",
63 VAR_NS_IDS_GLOBAL, exoid);
64 ex_err_fn(exoid, __func__, errmsg, status);
65
66 EX_FUNC_LEAVE(EX_FATAL);
67 }
68
69 /* Get the variable ID for the vector of global node-set node counts */
70 if ((status = nc_inq_varid(exoid, VAR_NS_NODE_CNT_GLOBAL, &varid)) != NC_NOERR) {
71 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
72 VAR_NS_NODE_CNT_GLOBAL, exoid);
73 ex_err_fn(exoid, __func__, errmsg, status);
74
75 EX_FUNC_LEAVE(EX_FATAL);
76 }
77
78 /* Output the vector of global node counts in each global node set */
79 if (ex_int64_status(exoid) & EX_BULK_INT64_API) {
80 status = nc_put_var_longlong(exoid, varid, node_cnts);
81 }
82 else {
83 status = nc_put_var_int(exoid, varid, node_cnts);
84 }
85 if (status != NC_NOERR) {
86 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to put variable \"%s\" in file ID %d",
87 VAR_NS_NODE_CNT_GLOBAL, exoid);
88 ex_err_fn(exoid, __func__, errmsg, status);
89
90 EX_FUNC_LEAVE(EX_FATAL);
91 }
92
93 /* Get the variable ID for the number of dist. factors in each node set */
94 if ((status = nc_inq_varid(exoid, VAR_NS_DF_CNT_GLOBAL, &varid)) != NC_NOERR) {
95 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
96 VAR_NS_DF_CNT_GLOBAL, exoid);
97 ex_err_fn(exoid, __func__, errmsg, status);
98
99 EX_FUNC_LEAVE(EX_FATAL);
100 }
101
102 /* Output the vector of dist. factor counts */
103 if (ex_int64_status(exoid) & EX_BULK_INT64_API) {
104 status = nc_put_var_longlong(exoid, varid, df_cnts);
105 }
106 else {
107 status = nc_put_var_int(exoid, varid, df_cnts);
108 }
109 if (status != NC_NOERR) {
110 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to output variable \"%s\" in file ID %d",
111 VAR_NS_DF_CNT_GLOBAL, exoid);
112 ex_err_fn(exoid, __func__, errmsg, status);
113
114 EX_FUNC_LEAVE(EX_FATAL);
115 }
116
117 EX_FUNC_LEAVE(EX_NOERR);
118 }