title: Two forcings in compiled code - R package deSolve
body: <p>I am using package deSolve to run some models that include an external forcing. To gain speed, I produced compiled code following the vignette of the package (see 6.2 in <a href="https://cran.r-project.org/web/packages/deSolve/vignettes/compiledCode.pdf" rel="nofollow noreferrer">https://cran.r-project.org/web/packages/deSolve/vignettes/compiledCode.pdf</a>). My problem is that now I want to introduce two external forcings in the compiled code. Does anyone have a working example/knows how to do it?</p>
  <pre><code>#include &lt;R.h&gt;
  
  static double parms[6];
  static double forc[1]; 
  
  /* A trick to keep up with the parameters and forcings */
  #define b parms[0]
  #define c parms[1]
  #define d parms[2]
  #define e parms[3]
  #define f parms[4]
  #define g parms[5]
  #define import forc[0] 
  
  /* initializers: */
  void odec(void (* odeparms)(int *, double *))
  {
  int N=6;
  odeparms(&amp;N, parms);
  }
  
  void forcc(void (* odeforcs)(int *, double *))
  {
  int N=1;
  odeforcs(&amp;N, forc);
  }
  
  /* derivative function */
  void derivsc(int *neq, double *t, double *y, double *ydot,double *yout, int*ip)
  {
  if (ip[0] &lt;2) error(&quot;nout should be at least 2&quot;);
  ydot[0] = import - b*y[0]*y[1] + g*y[2];
  ydot[1] =          c*y[0]*y[1] - d*y[2]*y[1];
  ydot[2] =          e*y[1]*y[2] - f*y[2];
  yout[0] = y[0] + y[1] + y[2];
  yout[1] = import;
  }
  </code></pre>
  <p>Thanks</p>