Template:CMI Example set grid values CXX: Difference between revisions
From CSDMS
Automated import of articles *** existing text overwritten *** |
Automated import of articles *** existing text overwritten *** |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
<syntaxhighlight lang=cpp> | |||
this->log.info ("Setting values."); | |||
{ // Set values through the c-array | |||
const int n_dim = 1; | |||
int shape[1]; | |||
int len; | |||
double * x = this->state.get_grid_x (long_var_name, len); | |||
double * vals_ptr = vals.first (); | |||
shape[0] = len; | |||
this->state.set_double (long_var_name, vals_ptr, n_dim, shape); | |||
delete [] x; | |||
} | |||
this->log.info ("Set values."); | |||
return; | |||
</syntaxhighlight> |
Latest revision as of 12:02, 6 February 2012
this->log.info ("Setting values.");
{ // Set values through the c-array
const int n_dim = 1;
int shape[1];
int len;
double * x = this->state.get_grid_x (long_var_name, len);
double * vals_ptr = vals.first ();
shape[0] = len;
this->state.set_double (long_var_name, vals_ptr, n_dim, shape);
delete [] x;
}
this->log.info ("Set values.");
return;