Commit 4e3afa0d authored by LDalby's avatar LDalby
Browse files

Add rotations and the filedister for the maize scenario

parent 7c230b4d
1
0
0
100
SpringBarleyCloverGrass
CloverGrassGrazed1
CloverGrassGrazed2
SpringBarleyCloverGrass
SeedGrass1
SpringBarley
WinterWheat
MaizeSilage
SpringBarleyCloverGrass
CloverGrassGrazed1
CloverGrassGrazed2
SpringBarleyCloverGrass
CloverGrassGrazed1
CloverGrassGrazed2
MaizeSilage
SpringBarleyCloverGrass
CloverGrassGrazed1
CloverGrassGrazed2
WinterWheat
WinterRye
SpringBarleyCloverGrass
CloverGrassGrazed1
CloverGrassGrazed2
SpringBarleyCloverGrass
CloverGrassGrazed1
CloverGrassGrazed2
MaizeSilage
SpringBarley
WinterWheat
MaizeSilage
SpringBarley
WinterWheat
MaizeSilage
SpringBarley
WinterWheat
WinterBarley
WinterRape
MaizeSilage
SpringBarley
Oats
WinterWheat
MaizeSilage
SpringBarleyCloverGrass
CloverGrassGrazed1
CloverGrassGrazed2
SpringBarleyCloverGrass
CloverGrassGrazed1
CloverGrassGrazed2
MaizeSilage
SpringBarleyCloverGrass
CloverGrassGrazed1
CloverGrassGrazed2
SpringBarleySilage
SpringBarleyCloverGrass
CloverGrassGrazed1
CloverGrassGrazed2
WinterWheat
SpringBarleyCloverGrass
CloverGrassGrazed1
CloverGrassGrazed2
MaizeSilage
SpringBarleyCloverGrass
CloverGrassGrazed1
CloverGrassGrazed2
MaizeSilage
SpringBarleyCloverGrass
CloverGrassGrazed1
CloverGrassGrazed2
SpringBarleySilage
SpringBarleyCloverGrass
CloverGrassGrazed1
CloverGrassGrazed2
WinterWheat
MaizeSilage
SpringBarleyCloverGrass
CloverGrassGrazed1
CloverGrassGrazed2
MaizeSilage
SpringBarleyCloverGrass
CloverGrassGrazed1
CloverGrassGrazed2
SpringBarleySilage
MaizeSilage
SpringBarleyCloverGrass
CloverGrassGrazed1
CloverGrassGrazed2
MaizeSilage
SpringBarleySilage
WinterBarley
WinterRape
MaizeSilage
SpringBarleySilage
WinterWheat
WinterRye
SpringBarleySilage
MaizeSilage
SpringBarleyCloverGrass
CloverGrassGrazed1
CloverGrassGrazed2
CloverGrassGrazed2
1
0
0
100
MaizeSilage
CloverGrassGrazed1
CloverGrassGrazed2
SpringBarleyCloverGrass
SeedGrass1
SpringBarley
WinterWheat
MaizeSilage
SpringBarleyCloverGrass
MaizeSilage
CloverGrassGrazed2
MaizeSilage
CloverGrassGrazed1
MaizeSilage
MaizeSilage
SpringBarleyCloverGrass
CloverGrassGrazed1
CloverGrassGrazed2
WinterWheat
WinterRye
SpringBarleyCloverGrass
MaizeSilage
CloverGrassGrazed2
SpringBarleyCloverGrass
CloverGrassGrazed1
MaizeSilage
MaizeSilage
SpringBarley
WinterWheat
MaizeSilage
SpringBarley
WinterWheat
MaizeSilage
SpringBarley
WinterWheat
WinterBarley
WinterRape
MaizeSilage
SpringBarley
Oats
WinterWheat
MaizeSilage
SpringBarleyCloverGrass
CloverGrassGrazed1
CloverGrassGrazed2
SpringBarleyCloverGrass
CloverGrassGrazed1
CloverGrassGrazed2
MaizeSilage
MaizeSilage
CloverGrassGrazed1
MaizeSilage
SpringBarleySilage
SpringBarleyCloverGrass
CloverGrassGrazed1
CloverGrassGrazed2
WinterWheat
SpringBarleyCloverGrass
MaizeSilage
CloverGrassGrazed2
MaizeSilage
MaizeSilage
CloverGrassGrazed1
MaizeSilage
MaizeSilage
SpringBarleyCloverGrass
CloverGrassGrazed1
CloverGrassGrazed2
SpringBarleySilage
SpringBarleyCloverGrass
MaizeSilage
CloverGrassGrazed2
WinterWheat
MaizeSilage
MaizeSilage
CloverGrassGrazed1
MaizeSilage
MaizeSilage
SpringBarleyCloverGrass
CloverGrassGrazed1
CloverGrassGrazed2
SpringBarleySilage
MaizeSilage
SpringBarleyCloverGrass
MaizeSilage
CloverGrassGrazed2
MaizeSilage
SpringBarleySilage
WinterBarley
WinterRape
MaizeSilage
SpringBarleySilage
WinterWheat
WinterRye
SpringBarleySilage
MaizeSilage
SpringBarleyCloverGrass
CloverGrassGrazed1
MaizeSilage
CloverGrassGrazed2
1
0
0
100
MaizeSilage
CloverGrassGrazed1
CloverGrassGrazed2
MaizeSilage
SeedGrass1
SpringBarley
WinterWheat
MaizeSilage
SpringBarleyCloverGrass
MaizeSilage
CloverGrassGrazed2
MaizeSilage
MaizeSilage
MaizeSilage
MaizeSilage
MaizeSilage
CloverGrassGrazed1
MaizeSilage
WinterWheat
WinterRye
SpringBarleyCloverGrass
MaizeSilage
CloverGrassGrazed2
SpringBarleyCloverGrass
MaizeSilage
MaizeSilage
MaizeSilage
SpringBarley
WinterWheat
MaizeSilage
SpringBarley
WinterWheat
MaizeSilage
SpringBarley
WinterWheat
WinterBarley
WinterRape
MaizeSilage
SpringBarley
Oats
WinterWheat
MaizeSilage
MaizeSilage
CloverGrassGrazed1
MaizeSilage
SpringBarleyCloverGrass
MaizeSilage
CloverGrassGrazed2
MaizeSilage
MaizeSilage
MaizeSilage
MaizeSilage
SpringBarleySilage
MaizeSilage
CloverGrassGrazed1
MaizeSilage
WinterWheat
SpringBarleyCloverGrass
MaizeSilage
CloverGrassGrazed2
MaizeSilage
MaizeSilage
MaizeSilage
MaizeSilage
MaizeSilage
MaizeSilage
CloverGrassGrazed1
MaizeSilage
SpringBarleySilage
SpringBarleyCloverGrass
MaizeSilage
CloverGrassGrazed2
WinterWheat
MaizeSilage
MaizeSilage
MaizeSilage
CloverGrassGrazed2
MaizeSilage
MaizeSilage
CloverGrassGrazed1
MaizeSilage
SpringBarleySilage
MaizeSilage
SpringBarleyCloverGrass
CloverGrassGrazed1
CloverGrassGrazed2
MaizeSilage
SpringBarleySilage
WinterBarley
WinterRape
MaizeSilage
SpringBarleySilage
WinterWheat
WinterRye
SpringBarleySilage
MaizeSilage
SpringBarleyCloverGrass
MaizeSilage
MaizeSilage
CloverGrassGrazed2
1
0
0
100
SpringBarleyCloverGrass
MaizeSilage
MaizeSilage
MaizeSilage
SeedGrass1
SpringBarley
WinterWheat
MaizeSilage
MaizeSilage
CloverGrassGrazed1
MaizeSilage
MaizeSilage
MaizeSilage
MaizeSilage
MaizeSilage
MaizeSilage
MaizeSilage
CloverGrassGrazed2
WinterWheat
WinterRye
MaizeSilage
MaizeSilage
MaizeSilage
MaizeSilage
MaizeSilage
MaizeSilage
MaizeSilage
SpringBarley
WinterWheat
MaizeSilage
SpringBarley
WinterWheat
MaizeSilage
SpringBarley
WinterWheat
WinterBarley
WinterRape
MaizeSilage
SpringBarley
Oats
WinterWheat
MaizeSilage
MaizeSilage
MaizeSilage
CloverGrassGrazed2
MaizeSilage
MaizeSilage
MaizeSilage
MaizeSilage
MaizeSilage
MaizeSilage
MaizeSilage
SpringBarleySilage
MaizeSilage
MaizeSilage
MaizeSilage
WinterWheat
MaizeSilage
CloverGrassGrazed1
MaizeSilage
MaizeSilage
MaizeSilage
MaizeSilage
MaizeSilage
MaizeSilage
MaizeSilage
MaizeSilage
MaizeSilage
SpringBarleySilage
MaizeSilage
MaizeSilage
MaizeSilage
WinterWheat
MaizeSilage
MaizeSilage
MaizeSilage
MaizeSilage
MaizeSilage
SpringBarleyCloverGrass
MaizeSilage
MaizeSilage
SpringBarleySilage
MaizeSilage
MaizeSilage
CloverGrassGrazed1
MaizeSilage
MaizeSilage
SpringBarleySilage
WinterBarley
WinterRape
MaizeSilage
SpringBarleySilage
WinterWheat
WinterRye
SpringBarleySilage
MaizeSilage
MaizeSilage
MaizeSilage
CloverGrassGrazed2
MaizeSilage
#!/usr/local/bin/r
# Copy run directories and setup parameters
# Author: Lars Dalby
# Set the local R package library (if not done already)
if(!"/home/ldalby/R/packages" %in% .libPaths()) {
.libPaths("/home/ldalby/R/packages")
}
suppressWarnings(library(ralmass))
suppressMessages(library(tidyverse))
library(fs)
# Get the slurm job-id (is being passed in from the shell script calling this R script)
args <- commandArgs(trailingOnly=TRUE)
# Make sure we don"t write any e"s in extreme numbers.
options(scipen = 99)
# The base directory with all input files except ParameterValues.txt (ParameterValues.txt file is written further down):
basedir <- "/home/ldalby/workspace/Goose/RunDirectory"
# The parent directory of all the work directories
pathtodirs <- path("/scratch", args)
# Setup the directories
npar <- 4 # Specifies the number of run directories
years <- 3 # the number of seasons to run (goose sims run over the year boundary)
basename <- "WD" # The prefix to the directories
# Make the directories and copy the files:
for (i in 1:npar) {
index <- stringr::str_pad(as.character(1:npar), width = 2, pad = "0")
dir_create(path(pathtodirs, paste0(basename,index[i])))
file_copy(path = path(basedir, dir(basedir)),
new_path = path(pathtodirs, paste0(basename,index[i])),
overwrite = TRUE)
}
dirs <- dir(pathtodirs)
# Edit the scripts to reflect the correct paths:
for (i in seq_along(dirs)) {
wd <- path(pathtodirs, dirs[i])
AppendWorkDir(WorkDir = wd, InScript = path(wd, "scenario_01_goose-numbers.R"), OutScript = "batchr.r")
AppendWorkDir(WorkDir = wd, InScript = path(wd, "PreRunSetup.r"), OutScript = "PreRunSetup.r")
}
# Read in the config so we can get the default values:
cfg <- readLines("/home/ldalby/workspace/Goose/RunDirectory/TIALMaSSConfig.cfg")
# Ditribute the different parameters ----
nsteps <- 10 # the number of intervals to split the parameter in
replace_rotation <- function(new_rot, old_rot, wd_path) {
rot_paths <- "/home/ldalby/ALMaSS_all/almass/Grendel/rotations/"
focal_rot <- path(rot_paths, new_rot)
file_copy(focal_rot,
new_path = path(wd_path, old_rot),
overwrite = TRUE)
}
old_rot <- "UserDefinedFarm19.rot"
rot_path <- "/home/ldalby/ALMaSS_all/almass/Grendel/rotations"
# Startno scaler - maize rotation 191 ----
wdpath <- path(pathtodirs, dirs[1])
seq(1, 10, length.out = nsteps) %>%
round() %>%
GenerateParams("GOOSE_STARTNO_SCALER" = ., write = TRUE, path = wdpath)
replace_rotation(new_rot = path(rot_path, "UserDefinedFarm191.rot"),
old_rot = old_rot,
wd_path <- wdpath)
# Startno scaler - maize rotation 192 ----
wdpath <- path(pathtodirs, dirs[1])
seq(1, 10, length.out = nsteps) %>%
round() %>%
GenerateParams("GOOSE_STARTNO_SCALER" = ., write = TRUE, path = wdpath)
replace_rotation(new_rot = path(rot_path, "UserDefinedFarm192.rot"),
old_rot = old_rot,
wd_path <- wdpath)
# Startno scaler - maize rotation 193 ----
wdpath <- path(pathtodirs, dirs[1])
seq(1, 10, length.out = nsteps) %>%
round() %>%
GenerateParams("GOOSE_STARTNO_SCALER" = ., write = TRUE, path = wdpath)
replace_rotation(new_rot = path(rot_path, "UserDefinedFarm193.rot"),
old_rot = old_rot,
wd_path <- wdpath)
# Edit the bat, ini and cfg files to match the parameters set above:
for (i in seq_along(dirs)) {
wd <- path(pathtodirs, dirs[i])
edit_bat(wd, "_01_BatchLoop.sh")
EditIni(WorkDir = wd, Model = "goose", NYear = years + 1)
EditConfig(file = path(wd, "TIALMaSSConfig.cfg"), config = "GOOSE_MODELEXITDAY", value = 31 + years*365)
EditConfig(file = path(wd, "TIALMaSSConfig.cfg"), config = "MAP_WEATHER_FILE", value = "Vejlerne2011-2014.pre")
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment