Skip to content

Commit

Permalink
Merge branch 'master' into JOSS
Browse files Browse the repository at this point in the history
  • Loading branch information
Jannes Breier authored and Jannes Breier committed Sep 13, 2023
2 parents 6db17b7 + 0d0259f commit 308286f
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '2287233'
ValidationKey: '2307608'
AutocreateReadme: yes
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
Expand Down
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ cff-version: 1.2.0
message: If you use this software, please cite it using the metadata from this file.
type: software
title: 'lpjmlkit: Toolkit for Basic LPJmL Handling'
version: 1.1.7
date-released: '2023-07-11'
version: 1.1.8
date-released: '2023-07-18'
abstract: A collection of basic functions to facilitate the work with the Dynamic
Global Vegetation Model (DGVM) Lund-Potsdam-Jena managed Land (LPJmL) hosted at
the Potsdam Institute for Climate Impact Research (PIK). It provides functions for
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: lpjmlkit
Type: Package
Title: Toolkit for Basic LPJmL Handling
Version: 1.1.7
Version: 1.1.8
Authors@R: c(
person("Jannes", "Breier", , "[email protected]", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-9055-6904")),
person("Sebastian","Ostberg", , "[email protected]", role = "aut", comment = c(ORCID = "0000-0002-2368-7015")),
Expand Down Expand Up @@ -54,4 +54,4 @@ Suggests:
sf
Config/testthat/edition: 3
VignetteBuilder: knitr
Date: 2023-07-11
Date: 2023-07-18
13 changes: 6 additions & 7 deletions R/run_lpjml.R
Original file line number Diff line number Diff line change
Expand Up @@ -312,19 +312,18 @@ do_sequential <- function(sim_names,

# Check if slurm is available
if (is_slurm_available() && Sys.getenv("SLURM_JOB_ID") == "") {
Sys.setenv(I_MPI_DAPL_UD = "disable", # nolint:undesirable_function_linter.
I_MPI_FABRICS = "shm:shm",
I_MPI_DAPL_FABRIC = "shm:sh")
mpi_var <- Sys.getenv("I_MPI_DAPL_UD_PROVIDER")
Sys.unsetenv("I_MPI_DAPL_UD_PROVIDER")# nolint:undesirable_function_linter.
} else {
mpi_var <- NULL
}
for (sim_name in sim_names) {
do_run(sim_name, model_path, sim_path, write_stdout, raise_error)
}
}, finally = {
# Check if slurm is available
if (is_slurm_available() && Sys.getenv("SLURM_JOB_ID") == "") {
Sys.setenv(I_MPI_DAPL_UD = "enable", # nolint:undesirable_function_linter.
I_MPI_FABRICS = "shm:dapl")
Sys.unsetenv("I_MPI_DAPL_FABRIC")
if (!is.null(mpi_var)) {
Sys.setenv(I_MPI_DAPL_UD_PROVIDER = mpi_var) # nolint:undesirable_function_linter.
}
})
}
Expand Down
61 changes: 49 additions & 12 deletions R/submit_lpjml.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,32 @@
#' More information at <https://www.pik-potsdam.de/en>. Defaults to `"short"`.
#'
#' @param ntasks Integer defining the number of tasks/threads. More information
#' at <https://www.pik-potsdam.de/en> and <https://slurm.schedmd.com>.
#' Defaults to `256`.
#' at <https://www.pik-potsdam.de/en> and
#' <https://slurm.schedmd.com/sbatch.html>. Defaults to `256`.
#'
#' @param wtime Character string defining the time limit. Setting a lower time
#' limit than the maximum runtime for `sclass` can reduce the wait time in the
#' SLURM job queue. More information at <https://www.pik-potsdam.de/en> and
#' <https://slurm.schedmd.com>.
#' <https://slurm.schedmd.com/sbatch.html>.
#'
#' @param blocking Integer defining the number of cores to be blocked. More
#' information at <https://www.pik-potsdam.de/en> and
#' <https://slurm.schedmd.com>.
#' <https://slurm.schedmd.com/sbatch.html>.
#'
#' @param constraint Character string defining constraints for node selection.
#' Use `constraint = "haswell"` to request nodes of the type haswell with 16
#' cores per node, `constraint = "broadwell"` to request nodes of the type
#' broadwell CPUs with 32 cores per node or `constraint = "exclusive"` to
#' reserve all CPUs of assigned nodes even if less are requested by `ntasks`.
#' Using `exclusive` should prevent interference of other batch jobs with
#' LPJmL. More information at <https://www.pik-potsdam.de> and
#' <https://slurm.schedmd.com/sbatch.html>.

#'
#' @param slurm_options A named list of further arguments to be passed to sbatch.
#' E.g. list(`mail-user` = "[email protected]")
#' More information at <https://www.pik-potsdam.de> and
#' <https://slurm.schedmd.com/sbatch.html>
#'
#' @param no_submit Logical. Set to `TRUE` to test if `x` set correctly or
#' `FALSE` to actually submit job to SLURM.
Expand Down Expand Up @@ -67,11 +82,11 @@
#' | scen2_transient | scen1 _spinup |
#'
#' To use different SLURM settings for each run the optional SLURM options
#' `"sclass"`, `"ntask"`, `"wtime"` or `"blocking"` can also be supplied to the
#' initial \link[tibble]{tibble} supplied as `param` to
#' `"sclass"`, `"ntasks"`, `"wtime"`, "blocking"` or `constraint` can also be
#' supplied to the initial \link[tibble]{tibble} supplied as `param` to
#' [`write_config()`]. These overwrite the (default) SLURM
#' arguments (`sclass`, `ntask`, `wtime` or `blocking`) supplied to
#' `submit_lpjml`.
#' arguments (`sclass`, `ntasks`, `wtime`, `blocking` or ` `constraint`)
#' supplied to `submit_lpjml`.
#'
#' | **sim_name** | **dependency** | **wtime** |
#' |:--------------- |:-------------- |----------:|
Expand Down Expand Up @@ -175,6 +190,8 @@ submit_lpjml <- function(x, # nolint:cyclocomp_linter.
ntasks = 256,
wtime = "",
blocking = "",
constraint = "",
slurm_options = list(),
no_submit = FALSE,
output_path = NULL) {

Expand Down Expand Up @@ -213,7 +230,9 @@ submit_lpjml <- function(x, # nolint:cyclocomp_linter.
x$type <- "simulation"
x$job_id <- NA
x$status <- "failed"
slurm_args <- c("sclass", "ntask", "wtime", "blocking")
slurm_args <- c(
"sclass", "ntasks", "wtime", "blocking", "constraint", "slurm_options"
)

if ("order" %in% colnames(x)) {

Expand Down Expand Up @@ -258,7 +277,9 @@ submit_lpjml <- function(x, # nolint:cyclocomp_linter.
ntasks,
wtime,
blocking,
dependency)
constraint,
dependency,
slurm_options)

if (job$status == 0) {
x$job_id[sim_idx] <- strsplit(
Expand Down Expand Up @@ -307,7 +328,9 @@ submit_lpjml <- function(x, # nolint:cyclocomp_linter.
ntasks,
wtime,
blocking,
dependency = NA)
constraint,
dependency = NA,
slurm_options)

if (job$status == 0) {
x$job_id[sim_idx] <- strsplit(
Expand Down Expand Up @@ -341,7 +364,9 @@ submit_run <- function(sim_name,
ntasks,
wtime,
blocking,
dependency) {
constraint,
dependency,
slurm_options) {

config_file <- paste0("config_",
sim_name,
Expand Down Expand Up @@ -373,6 +398,14 @@ submit_run <- function(sim_name,
timestamp,
".json")

if (is.list(slurm_options) && length(slurm_options) > 0) {
further_slurm_options <- paste0(
" -option ", names(slurm_options), "=", slurm_options, collapse = " "
)
} else {
further_slurm_options <- ""
}

inner_command <- paste0(model_path, "/bin/lpjsubmit", # nolint:absolute_path_linter.
" -nocheck",
" -class ", sclass,
Expand All @@ -383,9 +416,13 @@ submit_run <- function(sim_name,
ifelse(blocking != "",
paste0(" -blocking ", blocking),
""),
ifelse(constraint != "",
paste0(" -constraint ", constraint),
""),
ifelse(!is.na(dependency),
paste0(" -dependency ", dependency),
""),
further_slurm_options,
" -o ", stdout,
" -e ", stderr,
" ",
Expand Down
7 changes: 5 additions & 2 deletions R/write_config.R
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@
#' (`wtime`) for the transient run than the spin-up run to get a higher priority
#' in the SLURM queue. This can be achieved by supplying this option as a
#' parameter to `param`. \cr
#' 4 options are available, namely `sclass`, `ntask`, `wtime`, `blocking`. \cr
#' 6 options are available, namely `sclass`, `ntasks`, `wtime`, `blocking`,
#' `constraint` and `slurm_options`. Use as arguments for [submit_lpjml()`].\cr
#' If specified in `param`, they overwrite the corresponding function arguments
#' in [`submit_lpjml()`].
#'
Expand Down Expand Up @@ -313,7 +314,9 @@ write_config <- function(x,
order = NA,
dependency = NA)

slurm_args <- c("sclass", "ntask", "wtime", "blocking")
slurm_args <- c(
"sclass", "ntasks", "wtime", "blocking", "constraint", "slurm_options"
)

config_tmp[slurm_args] <- NA

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Toolkit for Basic LPJmL Handling <a href=''><img src='inst/img/logo.png' align='right' height='139' /></a>

R package **lpjmlkit**, version **1.1.7**
R package **lpjmlkit**, version **1.1.8**

[![CRAN status](https://www.r-pkg.org/badges/version/lpjmlkit)](https://cran.r-project.org/package=lpjmlkit) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.7773134.svg)](https://doi.org/10.5281/zenodo.7773134) [![R build status](https://github.com/PIK-LPJmL/lpjmlkit/workflows/check/badge.svg)](https://github.com/PIK-LPJmL/lpjmlkit/actions) [![codecov](https://codecov.io/gh/PIK-LPJmL/lpjmlkit/branch/master/graph/badge.svg)](https://app.codecov.io/gh/PIK-LPJmL/lpjmlkit) [![r-universe](https://pik-piam.r-universe.dev/badges/lpjmlkit)](https://pik-piam.r-universe.dev/builds)

Expand Down Expand Up @@ -76,7 +76,7 @@ In case of questions / problems please contact Jannes Breier <jannesbr@pik-potsd

To cite package **lpjmlkit** in publications use:

Breier J, Ostberg S, Wirth S, Minoli S, Stenzel F, Müller C (2023). _lpjmlkit: Toolkit for Basic LPJmL Handling_. doi: 10.5281/zenodo.7773134 (URL: https://doi.org/10.5281/zenodo.7773134), R package version 1.1.7, <URL: https://github.com/PIK-LPJmL/lpjmlkit>.
Breier J, Ostberg S, Wirth S, Minoli S, Stenzel F, Müller C (2023). _lpjmlkit: Toolkit for Basic LPJmL Handling_. doi: 10.5281/zenodo.7773134 (URL: https://doi.org/10.5281/zenodo.7773134), R package version 1.1.8, <URL: https://github.com/PIK-LPJmL/lpjmlkit>.

A BibTeX entry for LaTeX users is

Expand All @@ -85,7 +85,7 @@ A BibTeX entry for LaTeX users is
title = {lpjmlkit: Toolkit for Basic LPJmL Handling},
author = {Jannes Breier and Sebastian Ostberg and Stephen Björn Wirth and Sara Minoli and Fabian Stenzel and Christoph Müller},
year = {2023},
note = {R package version 1.1.7},
note = {R package version 1.1.8},
doi = {10.5281/zenodo.7773134},
url = {https://github.com/PIK-LPJmL/lpjmlkit},
}
Expand Down
31 changes: 22 additions & 9 deletions man/submit_lpjml.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions man/write_config.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vignettes/lpjml-runner.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ params <- tibble(
dependency = c(NA, "spinup", "spinup"),
# slurm option wtime: analogous to sbatch -wtime defines slurm option
# individually per config, overwrites submit_lpjml argument
# (same for sclass, ntasks, blocking)
# (same for sclass, ntasks, blocking or constraint)
wtime = c("15:00:00", "3:00:00", "3:00:00")
)
Expand Down

0 comments on commit 308286f

Please sign in to comment.