Template:CMI Example get grid values CXX: Difference between revisions

From CSDMS
Automated import of articles
 
Automated import of articles *** existing text overwritten ***
Line 1: Line 1:
<syntaxhighlight lang=cpp>
  sidl::array<double> vals;


  std::cout << "val_string = " + long_var_name << std::endl;
  {
    int len = 0;
    double * data;
    int lower[1] = {0};
    int upper[1];
    int stride[1] = {1};
    fprintf (stderr, "%s: Call BMI_Get_double.
", CMI_COMPONENT_NAME);
    data = this->state.get_double (long_var_name, len);
    fprintf (stderr, "%s: n_vals=%d.
", CMI_COMPONENT_NAME, len);
    fprintf (stderr, "%s: vals[0]=%f.
", CMI_COMPONENT_NAME, data[0]);
    fprintf (stderr, "%s: vals[1]=%f.
", CMI_COMPONENT_NAME, data[0]);
    fprintf (stderr, "%s: vals[2]=%f.
", CMI_COMPONENT_NAME, data[0]);
    fprintf (stderr, "%s: vals[len-1]=%f.
", CMI_COMPONENT_NAME, data[len-1]);
    upper[0] = len-1;
    vals.borrow (data, 1, lower, upper, stride);
  }
  return vals;
</syntaxhighlight>

Revision as of 17:12, 1 February 2012