| 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 |
* expgv - ex_put_glo_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 |
* float* glob_var_vals array of global variable values |
| 18 |
* |
| 19 |
* exit conditions - |
| 20 |
* |
| 21 |
* revision history - |
| 22 |
* |
| 23 |
* |
| 24 |
*****************************************************************************/ |
| 25 |
|
| 26 |
#include "exodusII.h" // for ex_put_var, etc |
| 27 |
|
| 28 |
/*! |
| 29 |
\deprecated Use ex_put_var()(exoid, time_step, EX_GLOBAL, 1, 0, num_glob_vars, |
| 30 |
glob_var_vals) |
| 31 |
|
| 32 |
The function ex_put_glob_vars() writes the values of all the global |
| 33 |
variables for a single time step. The function ex_put_variable_param() |
| 34 |
must be invoked before this call is made. |
| 35 |
|
| 36 |
Because global variables are floating point values, the application |
| 37 |
code must declare the array passed to be the appropriate type |
| 38 |
(float or double) to match the compute word size passed in |
| 39 |
ex_create() or ex_open(). |
| 40 |
|
| 41 |
\return In case of an error, ex_put_glob_vars() returns a negative |
| 42 |
number; a warning will return a positive number. Possible causes of |
| 43 |
errors include: |
| 44 |
- data file not properly opened with call to ex_create() or ex_open() |
| 45 |
- data file opened for read only. |
| 46 |
- ex_put_variable_param() not called previously specifying |
| 47 |
the number of global variables. |
| 48 |
|
| 49 |
\param[in] exoid exodus file ID returned from a previous call to |
| 50 |
ex_create() or ex_open(). |
| 51 |
\param[in] time_step The time step number, as described under |
| 52 |
ex_put_time(). |
| 53 |
This is essentially a counter that is incremented |
| 54 |
when results |
| 55 |
variables are output. The first time step is 1. |
| 56 |
\param[in] num_glob_vars The number of global variables to be written to the |
| 57 |
database. |
| 58 |
\param[in] glob_var_vals Array of num_glob_vars global variable values for |
| 59 |
the time_step-th time step. |
| 60 |
|
| 61 |
As an example, the following coding will write the values of all the |
| 62 |
global variables at one time step to an open exodus II file: |
| 63 |
|
| 64 |
~~~{.c} |
| 65 |
int num_glo_vars, error, exoid, time_step; |
| 66 |
|
| 67 |
float *glob_var_vals |
| 68 |
|
| 69 |
\comment{write global variables} |
| 70 |
for (j=0; j < num_glo_vars; j++) { |
| 71 |
\comment{application code fills this array} |
| 72 |
glob_var_vals[j] = 10.0; |
| 73 |
} |
| 74 |
error = ex_put_glob_vars (exoid, time_step, num_glo_vars, glob_var_vals); |
| 75 |
|
| 76 |
\comment{Using non-deprecated functions:} |
| 77 |
error = ex_put_var (exoid, time_step, EX_GLOBAL, 1, 0, num_glo_vars, |
| 78 |
glob_var_vals); |
| 79 |
|
| 80 |
~~~ |
| 81 |
|
| 82 |
*/ |
| 83 |
|
| 84 |
int ex_put_glob_vars(int exoid, int time_step, int num_glob_vars, const void *glob_var_vals) |
| 85 |
{ |
| 86 |
return ex_put_var(exoid, time_step, EX_GLOBAL, 1, 0 /*N/A*/, num_glob_vars, glob_var_vals); |
| 87 |
} |