Skip to content

Bug parsing with intermediate variables #289

@CGMossa

Description

@CGMossa

While working on this example, I experienced this error:


Unused equation: foi_mat
	foi_mat <- user() # (line 8)
Generating model in c
ℹ Re-compiling odineec1549a (debug build)
── R CMD INSTALL ───────────────────────────────────────────────────────────────────────────────────────
─  installing *source* package 'odineec1549a' ...
   ** using staged installation
   ** libs
   using C compiler: 'gcc.exe (GCC) 12.2.0'
   gcc  -I"C:/Users/minin/scoop/apps/r/current/include" -DNDEBUG     -I"c:/rtools43/x86_64-w64-mingw32.static.posix/include"     -O2 -Wall -gdwarf-2 -mfpmath=sse -msse2 -mstackrealign  -UNDEBUG -Wall -pedantic -g -O0 -fdiagnostics-color=always -c odin.c -o odin.o
   odin.c:n function 'odin_rhs
   odin.c:204:63:error: ieclared (first use in this function)
     204 |   double delta_transmission = internal->transmission_rate * S[i * I[i - 1];
         |                                                               ^
   odin.c:204:63:note: each undeclared identifier is reported only once for each function it appears in
   make: *** [C:/Users/minin/scoop/apps/r/current/etc/x64/Makeconf:265: odin.o] Error 1
   ERROR: compilation failed for package 'odineec1549a'
─  removing 'C:/Users/minin/AppData/Local/Temp/RtmpQJ1XDn/devtools_install_19e06cbf1fb0/odineec1549a'
Error in `(function (command = NULL, args = character(), error_on_status = TRUE, …`:
! System command 'Rcmd.exe' failed
---
Exit status: 1
stdout & stderr: <printed>
---
Type .Last.error to see the more details.
> .Last.error

This occurs when running this:

odin::odin({
  delta_transmission <- transmission_rate * S[i] * I[i]
  deriv(S[]) <- delta_transmission
  deriv(I[]) <- +transmission_rate * S[i] * I[i] - recovery_rate * I[i]

  transmission_rate <- user(0.005)
  recovery_rate <- user(0.01)
  S0[] <- user()
  I0[] <- user()
  foi_mat <- user()
  initial(S[]) <- S0[i]
  initial(I[]) <- I0[i]
  dim(S0) <- user()
  dim(S) <- N
  dim(I) <- N
  dim(I0) <- N
  N <- length(S0)
},
verbose = TRUE,
# verbose = TRUE, validate = TRUE, target = "c", pretty = TRUE,
skip_cache = FALSE) ->
  model_generator

Backtrace:

Details

Backtrace:
 1. odin::odin({ …
 2. odin::odin_(xx, verbose, target, workdir, validate, pretty, skip_cache, …
 3. odin:::odin_generate(ir, options)
 4. odin:::odin_c_wrapper(ir, options)
 5. odin:::compile_dll(dest, compile_attributes = FALSE, quiet = quiet)
 6. withr::with_envvar(c(R_MAKEVARS_USER = makevars), pkgbuild::compile_dll(...))
 7. base::force(code)
 8. pkgbuild::compile_dll(...)
 9. pkgbuild:::install_min(path, dest = install_dir, components = "libs", args = if (needs_clean(path)) "--precle…
10. pkgbuild::rcmd_build_tools("INSTALL", c(path, paste("--library=", dest, …
11. pkgbuild::with_build_tools({ …
12. withr::with_path(rtools_path(), code)
13. base::force(code)
14. base::withCallingHandlers(callr::rcmd_safe(..., env = env, spinner = FALSE, …
15. callr::rcmd_safe(..., env = env, spinner = FALSE, show = FALSE, …
16. callr:::run_r(options)
17. base::with(options, with_envvar(env, do.call(processx::run, c(list(bin, …
18. base::with.default(options, with_envvar(env, do.call(processx::run, …
19. base::eval(substitute(expr), data, enclos = parent.frame())
20. base::eval(substitute(expr), data, enclos = parent.frame())
21. callr:::with_envvar(env, do.call(processx::run, c(list(bin, args = real_cmdargs, …
22. base::force(code)
23. base::do.call(processx::run, c(list(bin, args = real_cmdargs, stdout_line_callback = real_callback(stdou…
24. (function (command = NULL, args = character(), error_on_status = TRUE, …
25. base::throw(new_process_error(res, call = sys.call(), echo = echo, …
26. | base::signalCondition(cond)
27. (function (e) …
28. asNamespace("callr")$err$throw(e)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions