knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

       atlantisfmsy is designed to evaluate Fmsy value in the ecoysytem model Atlantis for a specific functional group. This package is seperated into 4 steps. First, it performs several tests to verify if the package could be applied to your model (physics, biology and fishery modules on ; functional group on, fished and impacted ; fleets on and use fishing mortality). Then, it copies/pastes all the files required to run Atlantis from your calibrated model directory to a working directory the package will create on your computer (to avoid overwriting parameters in your model). During the third step, a series of F values are tested from F = 0 to F~collapse~ (when biomass lower than 0.1 tons) with a step length of 0.4 y^-1^. Once the collapse is reached, the package will look for the tested F with the highest catches (F~max~), then it explores the value of F around that F~max~ to find F~msy~ (with a precision of two decimal places).

Package requirements

      Atlantis is started from R by opening a shell and the packages is looking for the names of your parameters files in the batch/shell (windows/unix) file you use to run your model (so DO NOT store more than one batch/shell file in the calibrated model directory). Because this package is running Atlantis, you will need to previously have Atlantis installed on your computer (https://research.csiro.au/atlantis/, 02/07/2018). The package is handling files and folder directly from a system shell and unfortunately only working on Windows and Unix OS. WARNING: depending on the size of your model and how many output you decide to save from Atlantis this package will run for several days for one functional groups and several Go will be used.

Package dependencies

library("stringr")
library("qdapRegex")
library("ncdf4")
library("utils")
library("ggplot2")
library("grid")

Run the Fmsy simulation

library(atlantisfmsy)

folder_path <- getwd() # where you want to store output of the test (here your current working directory)
model_path <- system.file("extdata", "setas-model-new-trunk", package = "atlantisfmsy") # here SETas model from Atlantis wiki usind trunk code, to run the example for bec-dev code of Atlantis replace "setas-model-new-trunk" by "setas-model-new" or you can replace it by the directory of your calibrated model

If you're using this package on UNIX OS (change SETas model windows files into linux one): This is also done when the package copy/paste the model's files into your working directory.

if(Sys.info()['sysname'] == "Linux"){
      convert <- paste("cd ", model_path, "/", "\n", "flip -uv *", sep = "") #convert Windows text files into Linux text files.
    system(convert)
}

Choose the functional groups you want to evaluate:

exe_name <- "atlantismain" #executable name might be different on Linux "atlantismainNew"
group_csv_file <- atlantis_paraselect(model_path, exe_name, "-s") # functional groups csv file from SETas model
group_csv_data <- read.table(file.path(model_path, group_csv_file), sep = ",", dec = ".", header = T) # load data from parameters file

# list of functional groups that are turn on, fished and impacted
group_list <- as.character(group_csv_data$Code[group_csv_data$IsTurnedOn == 1 & group_csv_data$IsFished == 1 & group_csv_data$IsImpacted == 1])
group_list

func_grp <- group_list[2]

Select the burning period of your model and the max value of F you want to test;

burnin_time <- 7300 # in days 
fmax <- 4 # per year

If using the SETas model example from this package, copy/paste your executable (manually or using the folowing script). Be aware that parameters files in this example are built to run with Atlantis trunk rev 6265 so please compile the model rev 6265 on your computer and then copy/paste the executable. If you are using the example from the old Bec-dev Atlantis code ("setas-model-new") the last version of this code on the wiki will work.

exe_path <- "C:/Atlantis/code/trunk_rev6261/atlantismain/Debug/atlantismain.exe" #"<your own path>"

if(Sys.info()['sysname'] == "Windows") {
  copy <- paste("xcopy ", shortPathName(exe_path), " ", shortPathName(model_path), sep = "") #copy executable.
  shell(copy)
} else {
  copy <- paste("cp -a ", exe_path, " ", model_path, "/", sep = "") #copy executable on UNIX.
  system(copy)
}

Then run the simulation:

atlantisfmsy_simu(func_grp, folder_path, model_path, exe_name, burnin_time, fmax)

If your simulation was interrupted (computer shut down, crash...) you can restart the simulations where it stoped. It will rerun the last simulation and keep going with the process of evaluating the F~msy~ value:

atlantisfmsy_restart(func_grp, folder_path, model_path, exe_name, fmax)


rgirardi/atlantisfmsy documentation built on Aug. 30, 2022, 9:11 a.m.