diff --git a/book_source/06_reference/02_models/ed.Rmd b/book_source/06_reference/02_models/ed.Rmd index 2f96d68805d..a8ccd0b00f0 100644 --- a/book_source/06_reference/02_models/ed.Rmd +++ b/book_source/06_reference/02_models/ed.Rmd @@ -30,7 +30,10 @@ The following sections of the PEcAn XML are relevant to the ED model: - `jobtemplate` - `prerun` - `postrun` - - `binary` + - `binary` -- The full path to the ED2 binary on the target machine. + - `binary_args` -- Additional arguments to be passed to the ED2 binary. Some common arguments are: + - `-s` -- Delay OpenMPI initialization until the last possible moment. This is needed when running ED2 in a Docker container. It is included by default when the host is `rabbitmq`. + - `-f /path/to/ED2IN` -- Full path to a specific ED2IN namelist file. Typically, this is not needed because, by default, ED searches for the ED2IN in the current directory and the PEcAn workflow places the ED2IN file and a symbolic link to the ED executable in the same (run) directory for you. - `run/site` - `lat` -- Latitude coordinate of site - `lon` -- Longitude coordinate of site diff --git a/models/ed/R/write.configs.ed.R b/models/ed/R/write.configs.ed.R index 2fdd8d3d6e2..5381fc8c27c 100644 --- a/models/ed/R/write.configs.ed.R +++ b/models/ed/R/write.configs.ed.R @@ -477,7 +477,7 @@ write.config.xml.ED2 <- function(settings, trait.values, defaults = settings$con #' run$host$rundir, run$host$outdir, run$host$scratchdir, #' run$host$clearscratch, model$jobtemplate, model$job.sh, run$host$job.sh, #' run$site$lat, run$site$lon, run$inputs$met$path, run$start.date, -#' run$end.date, model$binary +#' run$end.date, model$binary, model$binary_args #' @param run.id PEcAn run ID #' @return Character vector containing job.sh file #' @author David LeBauer, Shawn Serbin, Carl Davidson, Alexey Shiklomanov @@ -547,6 +547,17 @@ write.config.jobsh.ED2 <- function(settings, run.id) { jobsh <- gsub("@OUTDIR@", outdir, jobsh) jobsh <- gsub("@RUNDIR@", rundir, jobsh) + if (is.null(settings$model$binary_args)) { + # If argument is missing but running on RabbitMQ, assume you need + # -s flag. If you want to force run ED without -s, use a blank + # binary_args tag. + if (!is.null(settings$host$rabbitmq)) { + settings$model$binary_args <- "-s" + } else { + settings$model$binary_args <- "" + } + } + jobsh <- gsub("@BINARY_ARGS@", settings$model$binary_args, jobsh) jobsh <- gsub("@BINARY@", settings$model$binary, jobsh) pft_names <- unlist(sapply(settings$pfts, `[[`, "name")) diff --git a/models/ed/inst/template.job b/models/ed/inst/template.job index 07a89da0df0..afe1bc5aec5 100644 --- a/models/ed/inst/template.job +++ b/models/ed/inst/template.job @@ -24,7 +24,7 @@ export GFORTRAN_UNBUFFERED_PRECONNECTED=yes if [ ! -e "@OUTDIR@/history.xml" ]; then cd "@RUNDIR@" - "@BINARY@" + "@BINARY@" "@BINARY_ARGS@" STATUS=$? if [ $STATUS == 0 ]; then if grep -Fq '=== Time integration ends; Total elapsed time=' "@OUTDIR@/logfile.txt"; then diff --git a/models/ed/man/write.config.jobsh.ED2.Rd b/models/ed/man/write.config.jobsh.ED2.Rd index 4046bb2385c..4217d37b08c 100644 --- a/models/ed/man/write.config.jobsh.ED2.Rd +++ b/models/ed/man/write.config.jobsh.ED2.Rd @@ -11,7 +11,7 @@ write.config.jobsh.ED2(settings, run.id) run$host$rundir, run$host$outdir, run$host$scratchdir, run$host$clearscratch, model$jobtemplate, model$job.sh, run$host$job.sh, run$site$lat, run$site$lon, run$inputs$met$path, run$start.date, -run$end.date, model$binary} +run$end.date, model$binary, model$binary_args} \item{run.id}{PEcAn run ID} }