Template:CMI Example set grid values C: Difference between revisions
From CSDMS
Automated import of articles *** existing text overwritten *** |
Automated import of articles *** existing text overwritten *** |
||
Line 1: | Line 1: | ||
<syntaxhighlight lang=c> | |||
struct edu_csdms_models_Sedflux3D__data *this = | |||
edu_csdms_models_Sedflux3D__get_data (self); | |||
fprintf (stderr, "%s: Setting %s. | |||
", CMI_COMPONENT_NAME, | |||
long_var_name); | |||
{ | |||
int n_dim; | |||
int * shape = BMI_Get_grid_shape (this->state, long_var_name, | |||
&n_dim); | |||
double * vals_ptr = sidl_double__array_first (vals); | |||
fprintf (stderr, "%s: Calling BMI_Set_double. | |||
", CMI_COMPONENT_NAME); | |||
{ | |||
int i; | |||
for (i=0; i<shape[0]*shape[1]; i++) | |||
fprintf (stderr, "%d: %f | |||
", i, vals_ptr[i]); | |||
fflush (stderr); | |||
} | |||
BMI_Set_double (this->state, long_var_name, vals_ptr, n_dim, shape); | |||
g_free (shape); | |||
} | |||
//g_free (vals); | |||
fprintf (stderr, "%s: Values are set. | |||
", CMI_COMPONENT_NAME); | |||
return; | |||
</syntaxhighlight> |
Revision as of 18:33, 1 February 2012
struct edu_csdms_models_Sedflux3D__data *this =
edu_csdms_models_Sedflux3D__get_data (self);
fprintf (stderr, "%s: Setting %s.
", CMI_COMPONENT_NAME,
long_var_name);
{
int n_dim;
int * shape = BMI_Get_grid_shape (this->state, long_var_name,
&n_dim);
double * vals_ptr = sidl_double__array_first (vals);
fprintf (stderr, "%s: Calling BMI_Set_double.
", CMI_COMPONENT_NAME);
{
int i;
for (i=0; i<shape[0]*shape[1]; i++)
fprintf (stderr, "%d: %f
", i, vals_ptr[i]);
fflush (stderr);
}
BMI_Set_double (this->state, long_var_name, vals_ptr, n_dim, shape);
g_free (shape);
}
//g_free (vals);
fprintf (stderr, "%s: Values are set.
", CMI_COMPONENT_NAME);
return;