@@ -533,17 +533,23 @@ NULL
533533# '
534534# ' @examples
535535# ' \dontrun{
536- # ' file <- file.path(cmdstan_path(), "examples/bernoulli/bernoulli.stan")
536+ # ' stan_file <- file.path(cmdstan_path(), "examples/bernoulli/bernoulli.stan")
537537# '
538538# ' # by default compilation happens when cmdstan_model() is called.
539539# ' # to delay compilation until calling the $compile() method set compile=FALSE
540- # ' mod <- cmdstan_model(file , compile = FALSE)
540+ # ' mod <- cmdstan_model(stan_file , compile = FALSE)
541541# ' mod$compile()
542542# ' mod$exe_file()
543543# '
544- # ' # turn on threading support (for using functions that support within-chain parallelization)
545- # ' mod$compile(force_recompile = TRUE, cpp_options = list(stan_threads = TRUE))
546- # ' mod$exe_file()
544+ # ' # turn on threading support for using functions that support within-chain
545+ # ' # parallelization or running multiple pathfinder paths in parallel
546+ # ' # (here we compile a copy of the model in a temporary directory so that the
547+ # ' # executable compiled without threading above is not overwritten)
548+ # ' stan_file_threads <- file.path(tempdir(), "bernoulli.stan")
549+ # ' file.copy(stan_file, stan_file_threads)
550+ # ' mod_threads <- cmdstan_model(stan_file_threads, compile = FALSE)
551+ # ' mod_threads$compile(cpp_options = list(stan_threads = TRUE))
552+ # ' mod_threads$cpp_options()
547553# '
548554# ' # turn on pedantic mode
549555# ' file_pedantic <- write_stan_file("
554560# ' sigma ~ exponential(1);
555561# ' }
556562# ' ")
557- # ' mod <- cmdstan_model(file_pedantic, pedantic = TRUE)
558- # '
563+ # ' mod <- cmdstan_model(file_pedantic, compile = FALSE)
564+ # ' mod$compile(pedantic = TRUE)
565+ # ' # same as mod <- cmdstan_model(file_pedantic, pedantic = TRUE)
559566# ' }
560567# '
561568compile <- function (quiet = TRUE ,
0 commit comments