diff --git a/R/CDORemap.R b/R/CDORemap.R index 4ea14fd5864883da1f5db9a597b62da10d158747..b4f15455cd1b713dac95f06c9cf627e88473ee7d 100644 --- a/R/CDORemap.R +++ b/R/CDORemap.R @@ -76,6 +76,8 @@ #'@param write_dir Path to the directory where to create the intermediate #' files for CDO to work. By default, the R session temporary directory is #' used (\code{tempdir()}). +#'@param print_sys_msg A logical value indicating to print the messages from +#' system CDO commands. The default is FALSE to keep function using clean. #'@param ncores An integer indicating the number of theads used for #' interpolation (i.e., \code{-P} in cdo command.) The default value is NULL #' and \code{-P} is not used. @@ -227,6 +229,7 @@ CDORemap <- function(data_array = NULL, lons, lats, grid, method, avoid_writes = TRUE, crop = TRUE, force_remap = FALSE, write_dir = tempdir(), + print_sys_msg = FALSE, ncores = NULL) { #, mask = NULL) { .isRegularVector <- function(x, tol = 0.1) { if (length(x) < 2) { @@ -828,17 +831,17 @@ CDORemap <- function(data_array = NULL, lons, lats, grid, method, if (is.null(ncores)) { err <- try({ system(paste0("cdo -s ", sellonlatbox, "remap", method, ",", grid, " ", - tmp_file, " ", tmp_file2), ignore.stdout = T, ignore.stderr = T) + tmp_file, " ", tmp_file2), ignore.stdout = !print_sys_msg, ignore.stderr = !print_sys_msg) }) } else { err <- try({ system(paste0("cdo -P ", ncores," -s ", sellonlatbox, "remap", method, ",", - grid, " ", tmp_file, " ", tmp_file2), ignore.stdout = T, ignore.stderr = T) + grid, " ", tmp_file, " ", tmp_file2), ignore.stdout = !print_sys_msg, ignore.stderr = !print_sys_msg) }) } file.remove(tmp_file) if (is(err, 'try-error') || err > 0) { - stop("CDO remap failed. Possible problem: parameter 'grid'.") + stop("CDO remap failed. Set 'print_sys_msg' to TRUE to see CDO system message..") } ncdf_remapped <- nc_open(tmp_file2) if (!lons_lats_taken) { diff --git a/man/CDORemap.Rd b/man/CDORemap.Rd index d7eee21405d3ac4822e88d67a19266b040a2f464..9bfeaa557bfce79400e4b1959e1e0c555157c0b3 100644 --- a/man/CDORemap.Rd +++ b/man/CDORemap.Rd @@ -14,6 +14,7 @@ CDORemap( crop = TRUE, force_remap = FALSE, write_dir = tempdir(), + print_sys_msg = FALSE, ncores = NULL ) } @@ -87,6 +88,9 @@ is already on the target grid.} files for CDO to work. By default, the R session temporary directory is used (\code{tempdir()}).} +\item{print_sys_msg}{A logical value indicating to print the messages from +system CDO commands. The default is FALSE to keep function using clean.} + \item{ncores}{An integer indicating the number of theads used for interpolation (i.e., \code{-P} in cdo command.) The default value is NULL and \code{-P} is not used.}