Debian Codegraph @

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