Template:CMI Example set grid values CXX

From CSDMS
Revision as of 00:54, 1 February 2012 by CSDMSBot (talk | contribs) (Automated import of articles)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
    fprintf (stderr, "%s: Setting %s.
", CMI_COMPONENT_NAME,
        long_var_name.c_str ());

    { // 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 ();

      fprintf (stderr, "%s: Calling BMI_Set_double.
", CMI_COMPONENT_NAME);
      shape[0] =  len;
      this->state.set_double (long_var_name, vals_ptr, n_dim, shape);
      /*
      {
        double * y = this->state.get_grid_y (long_var_name, len);
        for (int i=0; i<len; i++)
          fprintf (stderr, "%f, %f: %f
", x[i], y[i], vals_ptr[i]);
        fflush (stderr);
      }
      */

      delete [] x;
    }

    fprintf (stderr, "%s: Values are set.
", CMI_COMPONENT_NAME);
    return;