Debian Codegraph @

packages/seacas/libraries/exodus/src/ex_put_eb_info_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_put_eb_info_global()
13 *****************************************************************************
14 * This function outputs the global element block IDs of all the element
15 * blocks associated with a geometry.
16 *****************************************************************************
17 * Variable Index:
18 * exoid - The NetCDF ID of an already open NemesisI file.
19 * el_blk_ids - Pointer to vector of global element block IDs.
20 * el_blk_cnts - Pointer to vector of global element block counts.
21 */
22 /*****************************************************************************/
23 /*****************************************************************************/
24 /*****************************************************************************/
25
26 #include <exodusII.h>
27 #include <exodusII_int.h>
28
29 int ex_put_eb_info_global(int exoid, const void_int *el_blk_ids, const void_int *el_blk_cnts)
30 {
31 int varid, status;
32 char errmsg[MAX_ERR_LENGTH];
33
34 EX_FUNC_ENTER();
35 if (exi_check_valid_file_id(exoid, __func__) == EX_FATAL) {
36 EX_FUNC_LEAVE(EX_FATAL);
37 }
38
39 /* Find the variable ID for the element block IDs */
40 if ((status = nc_inq_varid(exoid, VAR_ELBLK_IDS_GLOBAL, &varid)) != NC_NOERR) {
41 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
42 VAR_ELBLK_IDS_GLOBAL, exoid);
43 ex_err_fn(exoid, __func__, errmsg, status);
44
45 EX_FUNC_LEAVE(EX_FATAL);
46 }
47
48 /* Output the global element block IDs */
49 if (ex_int64_status(exoid) & EX_IDS_INT64_API) {
50 status = nc_put_var_longlong(exoid, varid, el_blk_ids);
51 }
52 else {
53 status = nc_put_var_int(exoid, varid, el_blk_ids);
54 }
55 if (status != NC_NOERR) {
56 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to output variable \"%s\" in file ID %d",
57 VAR_ELBLK_IDS_GLOBAL, exoid);
58 ex_err_fn(exoid, __func__, errmsg, status);
59
60 EX_FUNC_LEAVE(EX_FATAL);
61 }
62
63 /* Find the variable ID for the element block counts */
64 if ((status = nc_inq_varid(exoid, VAR_ELBLK_CNT_GLOBAL, &varid)) != NC_NOERR) {
65 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find variable ID for \"%s\" in file ID %d",
66 VAR_ELBLK_CNT_GLOBAL, exoid);
67 ex_err_fn(exoid, __func__, errmsg, status);
68
69 EX_FUNC_LEAVE(EX_FATAL);
70 }
71
72 /* Output the global element block counts */
73 if (ex_int64_status(exoid) & EX_BULK_INT64_API) {
74 status = nc_put_var_longlong(exoid, varid, el_blk_cnts);
75 }
76 else {
77 status = nc_put_var_int(exoid, varid, el_blk_cnts);
78 }
79 if (status != NC_NOERR) {
80 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to output variable \"%s\" in file ID %d",
81 VAR_ELBLK_CNT_GLOBAL, exoid);
82 ex_err_fn(exoid, __func__, errmsg, status);
83
84 EX_FUNC_LEAVE(EX_FATAL);
85 }
86
87 EX_FUNC_LEAVE(EX_NOERR);
88 }