Skip to content

Commit

Permalink
ED: Add binary_args setting
Browse files Browse the repository at this point in the history
Allows passing arbitrary flags to ED executable.

Closes PecanProject#2146.
  • Loading branch information
ashiklom committed Nov 6, 2018
1 parent abcd695 commit aa46385
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ For more information about this file see also [Keep a Changelog](http://keepacha
- Fixed error in `read_web_config` which would filter out all variables.
- Docker:
- Make sure web interface posts RabbitMQ messages even after editing files (fixes #2151)
- ED2:
- Add ability to pass arbitrary arguments to the ED binary through the `pecan.xml` (#2183; fixes #2146).

### Added
- Lots of new documentation for running PEcAn using Docker
Expand Down
5 changes: 4 additions & 1 deletion book_source/06_reference/02_models/ed.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 12 additions & 1 deletion models/ed/R/write.configs.ed.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"))
Expand Down
2 changes: 1 addition & 1 deletion models/ed/inst/template.job
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion models/ed/man/write.config.jobsh.ED2.Rd

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

0 comments on commit aa46385

Please sign in to comment.