Debian Codegraph @

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

raw
1 /*
2 * Copyright(C) 2023 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 * exggv - ex_get_glob_vars
11 *
12 * entry conditions -
13 * input parameters:
14 * int exoid exodus file id
15 * int time_step time step number
16 * int num_glob_vars number of global vars in file
17 *
18 * exit conditions -
19 * float* glob_var_vals array of global variable values
20 *
21 * revision history -
22 *
23 *
24 *****************************************************************************/
25
26 #include "exodusII.h" // for ex_err, etc
27 #include "exodusII_int.h" // for exi_comp_ws, EX_FATAL, etc
28
29 /*!
30 Internal function. Do not use in client code.
31 */
32
33 int exi_get_glob_vars_multi_time(int exoid, int num_glob_vars, int beg_time_step, int end_time_step,
34 void *glob_var_vals)
35 {
36 EX_FUNC_ENTER();
37 if (exi_check_valid_file_id(exoid, __func__) == EX_FATAL) {
38 EX_FUNC_LEAVE(EX_FATAL);
39 }
40
41 /* inquire previously defined variable */
42 int varid;
43 int status;
44 if ((status = nc_inq_varid(exoid, VAR_GLO_VAR, &varid)) != NC_NOERR) {
45 char errmsg[MAX_ERR_LENGTH];
46 snprintf(errmsg, MAX_ERR_LENGTH, "Warning: failed to locate global variables in file id %d",
47 exoid);
48 ex_err_fn(exoid, __func__, errmsg, status);
49 EX_FUNC_LEAVE(EX_WARN);
50 }
51
52 /* read values of global variables */
53 size_t start[] = {--beg_time_step, 0};
54 size_t count[] = {end_time_step - beg_time_step, num_glob_vars};
55
56 if (exi_comp_ws(exoid) == 4) {
57 status = nc_get_vara_float(exoid, varid, start, count, glob_var_vals);
58 }
59 else {
60 status = nc_get_vara_double(exoid, varid, start, count, glob_var_vals);
61 }
62
63 if (status != NC_NOERR) {
64 char errmsg[MAX_ERR_LENGTH];
65 snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to get global variable values from file id %d",
66 exoid);
67 ex_err_fn(exoid, __func__, errmsg, status);
68 EX_FUNC_LEAVE(EX_FATAL);
69 }
70 EX_FUNC_LEAVE(EX_NOERR);
71 }