Creates and optionally submits a SLURM job to run a TMB model on a computing cluster.

run_tmb_on_slurm(
  data,
  params,
  random = NULL,
  map_words = NULL,
  dll = "model",
  n_cores = NULL,
  job_name = "TMBjob",
  partition = "fuchs",
  time = "8:00:00",
  ntasks = 1,
  nodes = 1,
  conda_env = "kinh",
  rscript = "run_tmb.r",
  work_dir = ".",
  submit = FALSE,
  submit_cmd = "sbatch",
  data_path = "tmb_data.RData",
  param_path = "tmb_params.RData",
  map_path = "tmb_param_map.RData"
)

Arguments

data

Data list for TMB model

params

Parameter list for TMB model

random

Character vector of random effect parameter names

map_words

Named list of parameter mapping specifications

dll

Character name of compiled TMB model (without extension)

n_cores

Number of cores for OpenMP parallelization

job_name

Character name for SLURM job

partition

Character name of SLURM partition

time

Character time limit for job ("HH:MM:SS")

ntasks

Number of tasks for SLURM

nodes

Number of nodes for SLURM

conda_env

Character name of conda environment

rscript

Character name for generated R script

work_dir

Character path to working directory

submit

Logical whether to submit job immediately

submit_cmd

Character command to submit SLURM job

data_path

Character path to save data

param_path

Character path to save parameters

map_path

Character path to save parameter map

Value

Invisibly returns a list with:

submitted

Logical indicating if job was submitted

output

System output from job submission if applicable

rscript

Path to generated R script

slurm

Path to generated SLURM script

data

Path to saved data

param

Path to saved parameters

map

Path to saved parameter map if applicable

Details

This function generates necessary R and SLURM scripts to run a TMB model on a SLURM-based computing cluster. It saves model data and parameters to files, creates an R script to fit the model, and a SLURM submission script. The job can be submitted immediately or the scripts can be saved for later submission.