MakeADFun: Overloaded definition of MakeADFun to allow debugging on...

Usage Arguments Examples

Usage

1
MakeADFun(..., DLL = TMB:::getUserDLL())

Arguments

...
DLL

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (..., DLL = TMB:::getUserDLL()) 
{
    orig_dir <- getwd()
    setwd(tempdir())
    on.exit(setwd(orig_dir))
    All_inputs <- list(..., DLL = DLL)
    save(All_inputs, file = "All_inputs.RData")
    DLL <- All_inputs$DLL
    DLLfull <- paste0(orig_dir, "/", DLL)
    txt <- c("library( TMB )", paste0("dyn.load(dynlib('", DLLfull, 
        "'))"), "load( 'All_inputs.RData' )", "Obj <- do.call(TMB::MakeADFun, All_inputs)")
    writeLines(txt, paste0(DLL, ".R"))
    Bdg_output <- gdbsource(paste0(DLL, ".R"))
    if (length(grep("#0", Bdg_output)) > 0) {
        message("Model has errors")
        print(Bdg_output)
        stop()
    }
    TMB::MakeADFun(..., DLL = DLL)
  }

John-R-Wallace/TMB-debug documentation built on May 7, 2019, 11:16 a.m.