Debian Codegraph @

packages/seacas/libraries/exodus/src/ex_get_map_param.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 * exgmp - ex_get_map_param
11 *
12 * entry conditions -
13 * input parameters:
14 * int exoid exodus file id
15 *
16 * exit conditions -
17 * int* num_node_maps number of node maps
18 * int* num_elem_maps number of element maps
19 *
20 * revision history -
21 *
22 *****************************************************************************/
23
24 #include "exodusII.h" // for ex_err, etc
25 #include "exodusII_int.h" // for EX_FATAL, DIM_NUM_EM, etc
26
27 /*
28 * reads the number of node and element maps
29 */
30
31 int ex_get_map_param(int exoid, int *num_node_maps, int *num_elem_maps)
32 {
33 int status;
34 int dimid;
35 size_t lnum_node_maps, lnum_elem_maps;
36 char errmsg[MAX_ERR_LENGTH];
37
38 EX_FUNC_ENTER();
39 if (exi_check_valid_file_id(exoid, __func__) == EX_FATAL) {
40 EX_FUNC_LEAVE(EX_FATAL);
41 }
42
43 /* node maps are optional */
44 if (nc_inq_dimid(exoid, DIM_NUM_NM, &dimid) != NC_NOERR) {
45 *num_node_maps = 0;
46 }
47 else {
48 if ((status = nc_inq_dimlen(exoid, dimid, &lnum_node_maps)) != NC_NOERR) {
49 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get number of node maps in file id %d",
50 exoid);
51 ex_err_fn(exoid, __func__, errmsg, status);
52 EX_FUNC_LEAVE(EX_FATAL);
53 }
54 *num_node_maps = lnum_node_maps;
55 }
56
57 /* element maps are optional */
58 if (nc_inq_dimid(exoid, DIM_NUM_EM, &dimid) != NC_NOERR) {
59 *num_elem_maps = 0;
60 }
61 else {
62 if ((status = nc_inq_dimlen(exoid, dimid, &lnum_elem_maps)) != NC_NOERR) {
63 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get number of element maps in file id %d",
64 exoid);
65 ex_err_fn(exoid, __func__, errmsg, status);
66 EX_FUNC_LEAVE(EX_FATAL);
67 }
68 *num_elem_maps = lnum_elem_maps;
69 }
70 EX_FUNC_LEAVE(EX_NOERR);
71 }