From b0b710ee9f9bb9bbe9708676d0c5822465e02203 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Sat, 15 Apr 2023 15:35:06 +0200 Subject: Make predefined symbols safer We still need to create a parallel processing cluster _after_ creating a compiled model that is moved to a user defined location, at least I did not find another way to make it work. This is not a problem with parallel processing without a cluster, which is not available on Windows. --- R/mkinfit.R | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'R/mkinfit.R') diff --git a/R/mkinfit.R b/R/mkinfit.R index b97bc7e2..c851fddb 100644 --- a/R/mkinfit.R +++ b/R/mkinfit.R @@ -501,10 +501,15 @@ mkinfit <- function(mkinmod, observed, } # Get native symbol before iterations info for speed + use_symbols = FALSE if (solution_type == "deSolve" & use_compiled[1] != FALSE) { - mkinmod[["symbols"]] <- deSolve::checkDLL(dllname = mkinmod$dll_info[["name"]], - func = "diffs", initfunc = "initpar", - jacfunc = NULL, nout = 0, outnames = NULL) + mkinmod[["symbols"]] <- try( + deSolve::checkDLL(dllname = mkinmod$dll_info[["name"]], + func = "diffs", initfunc = "initpar", + jacfunc = NULL, nout = 0, outnames = NULL)) + if (!inherits(mkinmod[["symbols"]], "try-error")) { + use_symbols = TRUE + } } # Get the error model and the algorithm for fitting @@ -616,8 +621,9 @@ mkinfit <- function(mkinmod, observed, odeini, outtimes, solution_type = solution_type, use_compiled = use_compiled, + use_symbols = use_symbols, method.ode = method.ode, - atol = atol, rtol = rtol, + atol = atol, rtol = rtol, ...) observed_index <- cbind(as.character(observed$time), as.character(observed$name)) -- cgit v1.2.1