stan-dev / posteriordb

Database with posteriors of interest for Bayesian inference
163 stars 26 forks source link

soil carbon model build error #209

Closed bbbales2 closed 3 years ago

bbbales2 commented 3 years ago

I got this error trying to build the soil_carbon-soil_incubation model with the latest cmdstanpy:

Semantic error in '/home/bbales2/stan_benchmarks/jobs/tmpp2qwdsid/soil_carbon-soil_incubationg6r2v7mp.stan', line 93, column 13 to line 94, column 57:
   -------------------------------------------------
    91:      theta[4] <- alpha12;
    92:  
    93:      C_hat <- integrate_ode(two_pool_feedback,
                      ^
    94:                             C_t0, t0, ts, theta, x_r, x_i);
    95:  
   -------------------------------------------------

Ill-typed arguments supplied to function 'integrate_ode'. Available signatures: 
((real, real[], real[], data real[], data int[]) => real[], real[], real, real[], real[], data real[], data int[]) => real[,]
Instead supplied arguments of incompatible type: (real, real[], real[], real[], int[]) => real[], real[], real, real[], real[], real[], int[].
MansMeg commented 3 years ago

Alright. I can't really see what is the problem. Do you know what might be wrong?

I suspect it is a dimensionality issue from the JSON data format. We are currently discussing this in another thread.

bbbales2 commented 3 years ago

Lemme check real quick (I just ignored the error for what I was doing)

bbbales2 commented 3 years ago

Uh oh it just compiled for me in cmdstanr. cmdstanpy should be the same thing so let me check that too.

bbbales2 commented 3 years ago

Oh no no it gave an error good

bbbales2 commented 3 years ago

Here's the model or I can make a pull. (Edit: woops, I did have the model and then deleted it to just show the diff)

The issue was that data-ness of arguments needs to be explicit in the new compiler I guess.

So

real[] evolved_CO2(int N_t, real t0, real[] ts,
                             real gamma, real totalC_t0,
                             real k1, real k2,
                             real alpha21, real alpha12,
                             real[] x_r, int[] x_i)

changes to:

real[] evolved_CO2(int N_t, real t0, real[] ts,
                             real gamma, real totalC_t0,
                             real k1, real k2,
                             real alpha21, real alpha12,
                             data real[] x_r, data int[] x_i)

Also if you're messing with this go ahead and do a search replace for <- with = for this model so the warnings go away.

MansMeg commented 3 years ago

If you have time to fix it with a PR that would be great!

MansMeg commented 3 years ago

Sorry! Im just totally bogged down in teaching right now.

bbbales2 commented 3 years ago

Here yah go: https://github.com/MansMeg/posteriordb/pull/211

MansMeg commented 3 years ago

Thanks!