1 /*
2  * Copyright (c) 2005-2017 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  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met:
9  *
10  *     * Redistributions of source code must retain the above copyright
11  *       notice, this list of conditions and the following disclaimer.
12  *
13  *     * Redistributions in binary form must reproduce the above
14  *       copyright notice, this list of conditions and the following
15  *       disclaimer in the documentation and/or other materials provided
16  *       with the distribution.
17  *
18  *     * Neither the name of NTESS nor the names of its
19  *       contributors may be used to endorse or promote products derived
20  *       from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  *
34  */
35 /*****************************************************************************
36  *
37  * exggv - ex_get_glob_vars
38  *
39  * entry conditions -
40  *   input parameters:
41  *       int     exoid                   exodus file id
42  *       int     time_step               time step number
43  *       int     num_glob_vars           number of global vars in file
44  *
45  * exit conditions -
46  *       float*  glob_var_vals           array of global variable values
47  *
48  * revision history -
49  *
50  *
51  *****************************************************************************/
52 
53 #include "exodusII.h" // for ex_get_var, etc
54 
55 /*!
56 \deprecated Use ex_get_var()(exoid, time_step, EX_GLOBAL, 1, 1, num_glob_vars, global_var_vals)
57 \ingroup ResultsData
58 
59 The function ex_get_glob_vars() reads the values of all the
60 global variables for a single time step. Memory must be allocated for
61 the global variables values array before this function is invoked.
62 
63 Because global variables are floating point values, the application
64 code must declare the array passed to be the appropriate type
65 (float or double) to match the compute word size passed in
66 ex_create() or ex_open().
67 
68 In case of an error, ex_get_glob_vars() returns a negative
69 number; a warning will return a positive number. Possible causes of
70 errors include:
71 
72  - data file not properly opened with call to ex_create() or ex_open()
73  - no global variables stored in the file.
74  - a warning value is returned if no global variables are stored in the file.
75 
76 \param[in] exoid        exodus file ID returned from a previous call to
77 ex_create() or ex_open().
78 
79 \param[in] time_step    The time step, as described under ex_put_time(), at
80                         which the global variable values are desired. This is
81 essentially
82                         an index (in the time dimension) into the global
83 variable values
84                         array stored in the database. The first time step is 1.
85 
86 \param[in]  num_glob_vars The number of global variables stored in the database.
87 \param[out] glob_var_vals Returned array of num_glob_vars global variable values
88                           for the time_step'th time step.
89 
90 The following is an example code segment that reads all the global
91 variables at one time step:
92 
93 ~~~{.c}
94 int num_glo_vars, error, time_step;
95 float *var_values;
96 
97 error = ex_get_variable_param (idexo, EX_GLOBAL, &num_glo_vars);
98 var_values = (float *) calloc (num_glo_vars, sizeof(float));
99 error = ex_get_glob_vars (idexo, time_step, num_glo_vars,
100                           var_values);
101 ~~~
102 
103  */
104 
ex_get_glob_vars(int exoid,int time_step,int num_glob_vars,void * glob_var_vals)105 int ex_get_glob_vars(int exoid, int time_step, int num_glob_vars, void *glob_var_vals)
106 {
107   return ex_get_var(exoid, time_step, EX_GLOBAL, 1, 1, num_glob_vars, glob_var_vals);
108 }
109