diff --git a/DESCRIPTION b/DESCRIPTION index 7d662ae..d1075ee 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -14,6 +14,7 @@ Remotes: Collate: "FLSAM.control.R" "FLSAM.R" + "FLSAM.MSE.R" "FLSAM.out.R" "FLR2SAM.R" "SAM2FLR.R" diff --git a/R/FLSAM.MSE.R b/R/FLSAM.MSE.R new file mode 100644 index 0000000..1f588af --- /dev/null +++ b/R/FLSAM.MSE.R @@ -0,0 +1,74 @@ +FLSAM.MSE <-function(stcks,tun,ctrl,catch.vars=NULL,starting.sam=NULL,return.sam=F,...){ + + #--------------------------------------------------- + # Output FLR objects into a format for SAM to read + #--------------------------------------------------- + if(is(stcks, "FLStocks")) stop("Not implemented for multi-fleet yet") + if(is(stcks, "FLStock")) stcks <- FLStocks(residual=stcks) + if(any(unlist(lapply(stcks,function(x)dims(x)$iter))<=1) & any(unlist(lapply(tun,function(x)dims(x)$iter))<=1)) + stop("Running in MSE mode means supplying FLStock and FLIndices with more iters than 1. Use FLSAM() instead") + + #Count iters + iters <- unlist(lapply(stcks,function(x)dims(x)$iter)) + + #Turn residuals off + ctrl@residuals <- FALSE + + #get datasets ready + data <- conf <- par <- list() + + require(doParallel) + ncores <- detectCores()-1 + ncores <- ifelse(iters