kingaa / pomp

R package for statistical inference using partially observed Markov processes
https://kingaa.github.io/pomp
GNU General Public License v3.0
110 stars 26 forks source link

An error associated with the installation and C snippets #184

Closed Ananthu89 closed 1 year ago

Ananthu89 commented 1 year ago

Describe the bug A clear and concise description of what the bug is.

While trying to reproduce some results from my group using 'pomp', I realized 'pomp' was not installed correctly on my system. (I got an error involving C snippets.) I followed the instructions (https://kingaa.github.io/pomp/install.html, https://mac.r-project.org/tools/, https://www.youtube.com/watch?v=ikvJcN3Zi2w&t=35s) and installed pomp. However, the very initial error of my original script is persisting.

The command source("https://kingaa.github.io/scripts/pompTest.R") showed me the following (error) message:

Checking whether dependencies are installed....
Testing ‘pomp’ ....
Trying to compile C snippets,....
Error: pomp installation failure! Consult the instructions!
could not find function "%>%"

Nevertheless, the command source("https://kingaa.github.io/scripts/hello.R",echo=TRUE) leads to following the (expected?) result:

> try({
+     cat("#include <R.h>
+      void hello (void) {
+      Rprintf(\"\\\n\\n\\nHello from native C!\\n\\n\\n\");
+      }",file="helloC.c")
+ .... [TRUNCATED] 
clang -arch arm64 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/opt/R/arm64/include   -fPIC  -falign-functions=64 -Wall -g -O2  -c helloC.c -o helloC.o
clang -arch arm64 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/opt/R/arm64/lib -o helloC.so helloC.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: warning: -undefined dynamic_lookup may not work with chained fixups

Hello from native C!

[1] TRUE TRUE TRUE

> try({
+     cat("
+       subroutine hello
+       external dblepr
+       call dblepr(\" \",-1,0,0)
+       call dblepr(\" \",-1,0,0)
+       call  ..." ... [TRUNCATED] 
/opt/R/arm64/bin/gfortran -mtune=native -fno-optimize-sibling-calls  -fPIC  -Wall -g -O2  -c helloF.f -o helloF.o
clang -arch arm64 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/opt/R/arm64/lib -o helloF.so helloF.o -L/opt/R/arm64/gfortran/lib/gcc/aarch64-apple-darwin20.6.0/12.0.1 -L/opt/R/arm64/gfortran/lib -lgfortran -lemutls_w -lquadmath -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: object file (helloF.o) was built for newer macOS version (13.1) than being linked (13.0)
ld: warning: could not create compact unwind for ___emutls_get_address: registers 23 and 24 not saved contiguously in frame

Hello from native FORTRAN!

[1] TRUE TRUE TRUE

To reproduce

  1. R code that produces the problem.
model_stoch <- pomp(
  data = data.frame(time = time_seq_stoch), 
  times = "time",
  t0 = 0,
  skeleton = vectorfield(Csnippet(vl_code_stoch)),
  rinit = Csnippet(vl_stoch_init),
  statenames = statenames_stoch,
  paramnames = paramnames
)

(Note that "vl_code_stoch", "vl_stoch_init" were called from another file; I can share the details if more info on this is required, and the error is not a basic installation issue.)

  1. Transcript of the R session that gave the errors.
    The error/warning message:

    Error: error in building shared-object library from C snippets: in ‘Cbuilder’: compilation error: cannot compile shared-object library ‘/var/folders/pj/zrptgg2s7yddyrfkzysxxf4w0000gn/T//RtmpB5vk1v/27035/pomp_1e5832c87bbc0192fd451e0d84ddee8e.so’: status = 1
    compiler messages:
    clang -arch arm64 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I'/Users/ananthujames/Library/R/arm64/4.2/library/pomp/include' -I'/Users/ananthujames/Downloads/WORK/Erasmus MC work/VL/Latest' -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -c /var/folders/pj/zrptgg2s7yddyrfkzysxxf4w0000gn/T//RtmpB5vk1v/27035/pomp_1e5832c87bbc0192fd451e0d84ddee8e.c -o /var/folders/pj/zrptgg2s7yddyrfkzysxxf4w0000gn/T//RtmpB5vk1v/27035/pomp_1e5832c87bbc0192fd451e0d84ddee8e.o
    /var/folders/pj/zrptgg2s7yddyrfkzysxxf4w0000gn/T//RtmpB5vk1v/27035/pomp_1e5832c87bbc0192fd451e0d84ddee8e.c:310:34: error: passing 'double (double, double, int)' to parameter of incompatible type 'double'
    reulermulti
  2. Any graphics that show the problematic results.

Expected behavior A clear and concise description of what you expected to happen.

Session information Output of the command

source("https://kingaa.github.io/scripts/diagnostics.R")

sessionInfo

R version 4.2.2 (2022-10-31)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Ventura 13.1

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] rstudioapi_0.14   ggplot2_3.4.0     data.table_1.14.6 pomp_4.6.2.0     

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.9        mvtnorm_1.1-3     lattice_0.20-45   prettyunits_1.1.1 ps_1.7.2          rprojroot_2.0.3  
 [7] digest_0.6.31     utf8_1.2.2        mime_0.12         R6_2.5.1          plyr_1.8.8        evaluate_0.19    
[13] coda_0.19-4       pillar_1.8.1      rlang_1.0.6       curl_5.0.0        miniUI_0.1.1.1    callr_3.7.3      
[19] urlchecker_1.0.1  rmarkdown_2.19    desc_1.4.2        devtools_2.4.5    stringr_1.5.0     htmlwidgets_1.6.1
[25] munsell_0.5.0     shiny_1.7.4       compiler_4.2.2    httpuv_1.6.8      xfun_0.36         pkgconfig_2.0.3  
[31] pkgbuild_1.4.0    htmltools_0.5.4   tibble_3.1.8      fansi_1.0.3       crayon_1.5.2      withr_2.5.0      
[37] later_1.3.0       grid_4.2.2        xtable_1.8-4      gtable_0.3.1      lifecycle_1.0.3   magrittr_2.0.3   
[43] scales_1.2.1      cli_3.6.0         stringi_1.7.12    cachem_1.0.6      fs_1.5.2          promises_1.2.0.1 
[49] remotes_2.4.2     ellipsis_0.3.2    vctrs_0.5.1       deSolve_1.34      tools_4.2.2       glue_1.6.2       
[55] purrr_1.0.1       processx_3.8.0    pkgload_1.3.2     fastmap_1.1.0     yaml_2.3.6        colorspace_2.0-3 
[61] sessioninfo_1.2.2 memoise_2.0.1     knitr_1.41        profvis_0.3.7     usethis_2.1.6    
kingaa commented 1 year ago

Thanks for the very detailed and perfectly clear bug report, @Ananthu89! This is my fault. I failed to update the pompTest script at the same time that I released pomp 4.6. I have now done so.

Please try source("https://kingaa.github.io/scripts/pompTest.R") again and let me know what happens.

kingaa commented 1 year ago

@Ananthu89: from your transcript, it looks also like there are problems also in the Csnippets. Can you also include those when you reply?

kingaa commented 1 year ago

Not having heard from you @Ananthu89 , I am assuming that you have resolved the issue yourself. If more discussion is needed, please re-open this issue.

Ananthu89 commented 1 year ago

Thank you very much for your response! And, sorry for the delay! (I was caught up with some other work before getting time to focus on this.)

Yes, I the command source("https://kingaa.github.io/scripts/pompTest.R") is now working without any error.

Further, as you pointed out, it seems there were some issues in the CSnippets. I therefore started working with the script https://kingaa.github.io/sbied/stochsim/index.html (given online) and adapted it for my purpose, which is now working without errors. I still need to make further modifications in the script, and in case there is some issue that I can't resolve I will comment here.