Commit e15317c1 authored by LDalby's avatar LDalby
Browse files

Add starter and collector scripts. Adjust sbatch script

parent 9800a993
......@@ -4,7 +4,7 @@
#SBATCH --ntasks=1
#SBATCH --mem=240G
#SBATCH --ntasks-per-node=1
#SBATCH --cpus-per-task=4
#SBATCH --cpus-per-task=8
#SBATCH --time=06:00:00
#SBATCH --exclusive
#SBATCH --mem-per-cpu=60G
......@@ -12,6 +12,6 @@
echo "========= Job started at `date` =========="
sh /home/ldalby/ALMaSS/almass/Grendel/
sh /home/ldalby/ALMaSS/almass/Grendel/
echo "========= Job finished at `date` =========="
\ No newline at end of file
# Collect results from parameter fitting
# Author: Lars Dalby
# Date: 12 Aug 2018
# Short script to combine the results form mulitple runs into one file and
# write that to a safe place on Grendel.
# Set the local R package library (if not done already)
if (!"/home/ldalby/R/packages" %in% .libPaths()) {
# Get the slurm job-id (is being passed in from the shell script calling this R script)
args <- commandArgs(trailingOnly = TRUE)
# The parent directory of all the work directories
path_to_dirs <- path("/scratch", args)
file_name <- "scenario-results.txt"
npar = 4 # Specifies the number of run directories that was being used
plan(multiprocess) # to run in parallel future_map in parallel.
suffix <- stringr::str_pad(as.character(1:npar), width = 2, pad = "0")
path(path_to_dirs, glue::glue("WD{suffix}"), "Results", file_name) %>%
future_map(data.table::fread) %>%
data.table::rbindlist() %>%
data.table::setnames(c("season", "day", "pinkfoot", "pinkfoot_dist",
"barnacle", "barnacle_dist", "greylag", "greylag_dist",
"grain", "maize", "polyref", "param", "value")) -> all_res
grain_file_name <- "scenario-grain-distributions.txt"
path(path_to_dirs, glue::glue("WD{suffix}"), "Results", grain_file_name) %>%
future_map(data.table::fread) %>%
data.table::rbindlist() %>%
data.table::setnames(c("season", "grain_dist", "param", "value")) -> all_grain
numbers_file_name <- "scenario-goose-numbers.txt"
path(path_to_dirs, glue::glue("WD{suffix}"), "Results", numbers_file_name) %>%
future_map(data.table::fread) %>%
data.table::rbindlist() %>%
data.table::setnames(c("season", "day", "pf_families", "pf_non_breeders", "bn_families",
"bn_non_breeders", "gl_families", "gl_non_breeders", "snow_depth",
"param", "value")) -> all_numbers
dest_dir <- "/home/ldalby/workspace/Goose/Scenarios/Results/"
res_file_name <- glue::glue("{args}_scenario-results_{Sys.Date()}.fst")
fst::write_fst(all_res, path = path(dest_dir, res_file_name))
grain_file_name <- glue::glue("{args}_scenario-grain-distributions_{Sys.Date()}.fst")
fst::write_fst(all_grain, path = path(dest_dir, grain_file_name))
numbers_file_name <- glue::glue("{args}_scenario-goose-numbers_{Sys.Date()}.fst")
fst::write_fst(all_numbers, path = path(dest_dir, numbers_file_name))
vers_path <- path("/scratch", args, "WD01", "almass-version.txt")
file_copy(vers_path, path(dest_dir, glue::glue("{args}_almass-version.txt")))
cd /home/ldalby/workspace/Goose/Scenarios
chmod +x scenario_01_goose-numbers_file-dist.R
/home/com/R/3.4.1/bin/Rscript scenario_01_goose-numbers_file-dist.R $SLURM_JOB_ID
for i in {01..4}; do
cd /scratch/$SLURM_JOB_ID/WD"$i"
chmod +x
./ > out &
sleep 5
cd /home/ldalby/workspace/Goose/Scenarios
chmod +x collect-results-scenario_01.R
/home/com/R/3.4.1/bin/Rscript collect-results-scenario_01.R $SLURM_JOB_ID
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