From 89634143acbdef573fd4d85a6fa352f11b13f352 Mon Sep 17 00:00:00 2001 From: aho Date: Wed, 26 May 2021 18:04:17 +0200 Subject: [PATCH] Add '-L' option in cdo command. It prevents potential segmentation fault in the underlying hdf5 library. --- R/Utils.R | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/R/Utils.R b/R/Utils.R index 6dc558a..11bebc5 100644 --- a/R/Utils.R +++ b/R/Utils.R @@ -420,7 +420,9 @@ filecopy <- tempfile(pattern = "load", fileext = ".nc") file.copy(filein, filecopy) filein <- tempfile(pattern = "loadRegridded", fileext = ".nc") - system(paste0("cdo -s remap", work_piece[['remap']], ",", + # "-L" is to serialize I/O accesses. It prevents potential segmentation fault in the + # underlying hdf5 library. + system(paste0("cdo -L -s remap", work_piece[['remap']], ",", common_grid_name, " -selname,", namevar, " ", filecopy, " ", filein, " 2>/dev/null", sep = "")) @@ -752,7 +754,7 @@ ncatt_put(fnc2, ncdf_var, 'scale_factor', scale_factor) } nc_close(fnc2) - system(paste0("cdo -s -sellonlatbox,", if (lonmin > lonmax) { + system(paste0("cdo -L -s -sellonlatbox,", if (lonmin > lonmax) { "0,360," } else { paste0(lonmin, ",", lonmax, ",") @@ -794,7 +796,7 @@ fnc_mask <- nc_create(mask_file, list(ncdf_var)) ncvar_put(fnc_mask, ncdf_var, array(rep(0, 4), dim = c(2, 2))) nc_close(fnc_mask) - system(paste0("cdo -s remap", work_piece[['remap']], ",", common_grid_name, + system(paste0("cdo -L -s remap", work_piece[['remap']], ",", common_grid_name, " ", mask_file, " ", mask_file_remap, " 2>/dev/null", sep = "")) fnc_mask <- nc_open(mask_file_remap) mask_lons <- ncvar_get(fnc_mask, 'lon') -- GitLab