From 09d2c380b0f5690f488ed14cb9146715083b56c1 Mon Sep 17 00:00:00 2001 From: jorritmesman Date: Fri, 9 Oct 2020 12:28:29 +0200 Subject: [PATCH 1/8] Replaced par_file by nml_file --- R/run_flake.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/run_flake.R b/R/run_flake.R index c4c2c4c..df1c6a5 100644 --- a/R/run_flake.R +++ b/R/run_flake.R @@ -131,7 +131,7 @@ run_flakeOSx <- function(sim_folder, nml_file = 'flake.nml', verbose=FALSE){ tryCatch({ if (verbose){ out <- system2(flake_path, wait = TRUE, stdout = TRUE, - stderr = "", args=par_file) + stderr = "", args=nml_file) } else { out <- system2(flake_path, args=nml_file) } @@ -155,7 +155,7 @@ run_flakeNIX <- function(sim_folder, nml_file = 'flake.nml', verbose=FALSE){ tryCatch({ if (verbose){ out <- system2(flake_path, wait = TRUE, stdout = TRUE, - stderr = "", args=par_file) + stderr = "", args=nml_file) } else { out <- system2(flake_path, args=nml_file) } From 47a1d900846ef1fde9d4e61012a2a5936bb44794 Mon Sep 17 00:00:00 2001 From: Johannes Feldbauer Date: Tue, 1 Jun 2021 10:38:59 +0200 Subject: [PATCH 2/8] fixed wrong argument name and arguments for verbose = FALSE --- R/run_flake.R | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/R/run_flake.R b/R/run_flake.R index 9df34c1..26c19dd 100644 --- a/R/run_flake.R +++ b/R/run_flake.R @@ -72,7 +72,8 @@ run_flakeWin <- function(sim_folder, nml_file, verbose = FALSE){ out <- system2(flake_path, wait = TRUE, stdout = TRUE, stderr = "", args=nml_file) } else { - out <- system2(flake_path, args=nml_file) + out <- system2(flake_path, args=nml_file, wait = TRUE, stdout = NULL, + stderr = NULL) } setwd(origin) return(out) @@ -133,9 +134,10 @@ run_flakeOSx <- function(sim_folder, nml_file = 'flake.nml', verbose=FALSE){ tryCatch({ if (verbose){ out <- system2(flake_path, wait = TRUE, stdout = TRUE, - stderr = "", args=par_file) + stderr = "", args=nml_file) } else { - out <- system2(flake_path, args=nml_file) + out <- system2(flake_path, args=nml_file, wait = TRUE, stdout = NULL, + stderr = NULL) } setwd(origin) return(out) @@ -159,9 +161,10 @@ run_flakeNIX <- function(sim_folder, nml_file = 'flake.nml', verbose=FALSE){ tryCatch({ if (verbose){ out <- system2(flake_path, wait = TRUE, stdout = TRUE, - stderr = "", args=par_file) + stderr = "", args=nml_file) } else { - out <- system2(flake_path, args=nml_file) + out <- system2(flake_path, args=nml_file, wait = TRUE, stdout = NULL, + stderr = NULL) } setwd(origin) return(out) From 4377244ae21566b5a43f734632b90222d9e15697 Mon Sep 17 00:00:00 2001 From: Jorrit Mesman Date: Wed, 2 Feb 2022 13:28:03 +0100 Subject: [PATCH 3/8] Change template file to "flake.nml" --- DESCRIPTION | 2 +- R/run_flake.R | 54 +++++++++++++++++++------------------- inst/extdata/feeagh.nml | 58 ----------------------------------------- man/run_flake.Rd | 8 +++--- 4 files changed, 32 insertions(+), 90 deletions(-) delete mode 100644 inst/extdata/feeagh.nml diff --git a/DESCRIPTION b/DESCRIPTION index a2bc549..8a0211e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -8,4 +8,4 @@ Description: Run the FLake model within R. Comes with a compiled version of FLak License: GPL3 Encoding: UTF-8 LazyData: true -RoxygenNote: 6.1.1 +RoxygenNote: 7.1.2 diff --git a/R/run_flake.R b/R/run_flake.R index f30136f..7af4e5f 100644 --- a/R/run_flake.R +++ b/R/run_flake.R @@ -5,21 +5,21 @@ #'The specified \code{sim_folder} must contain valid NML files. #' #'@param sim_folder the directory where simulation files are contained -#'@param nml_file filepath; to file with FLake setup. Defaults to 'flake.nml' +#'@param nml_file filepath; to file with FLake setup. Defaults to "flake.nml" #'@param verbose Save output as character vector. Defaults to FALSE #' #'@keywords methods #'@author #'Tadhg Moore #'@examples -#'sim_folder <- system.file('extdata', package = 'FLakeR') -#'run_flake(sim_folder, nml_file = 'Heiligensee80-96.nml') +#'sim_folder <- system.file("extdata", package = "FLakeR") +#'run_flake(sim_folder, nml_file = "flake.nml") #'@export #'@importFrom utils packageName -run_flake <- function (sim_folder = ".", nml_file = NULL, verbose = FALSE) +run_flake <- function (sim_folder = ".", nml_file = "flake.nml", verbose = FALSE) { if (is.null(nml_file)) { - files <- list.files(sim_folder)[grep('nml', list.files(sim_folder))] + files <- list.files(sim_folder)[grep("nml", list.files(sim_folder))] if(length(files) > 1){ stop("You must select one FLake namelist file in your sim_folder: ", sim_folder) @@ -27,23 +27,23 @@ run_flake <- function (sim_folder = ".", nml_file = NULL, verbose = FALSE) stop("You must have a valid FLake namelist file in your sim_folder: ", sim_folder) }else{ - nml = files + nml <- files } }else{ - nml = nml_file + nml <- nml_file } if (.Platform$pkgType == "win.binary") { return(run_flakeWin(sim_folder, nml_file = nml, verbose = verbose)) } ### macOS ### - if (grepl('mac.binary',.Platform$pkgType)) { - # stop('No FLake executable available for your machine yet...') + if (grepl("mac.binary",.Platform$pkgType)) { + # stop("No FLake executable available for your machine yet...") maj_v_number <- as.numeric(strsplit( - Sys.info()["release"][[1]],'.', fixed = TRUE)[[1]][1]) + Sys.info()["release"][[1]],".", fixed = TRUE)[[1]][1]) if (maj_v_number < 13.0) { - stop('pre-mavericks mac OSX is not supported. Consider upgrading') + stop("pre-mavericks mac OSX is not supported. Consider upgrading") } return(run_flakeOSx(sim_folder, nml_file = nml, verbose = verbose)) @@ -51,17 +51,17 @@ run_flake <- function (sim_folder = ".", nml_file = NULL, verbose = FALSE) } if (.Platform$pkgType == "source") { - #stop('No FLake executable available for your machine yet...') + #stop("No FLake executable available for your machine yet...") return(run_flakeNIX(sim_folder, nml_file = nml, verbose = verbose)) } } run_flakeWin <- function(sim_folder, nml_file, verbose = FALSE){ - if(.Platform$r_arch == 'x64'){ - flake_path <- system.file('extbin/win/flake.exe', package = packageName()) + if(.Platform$r_arch == "x64"){ + flake_path <- system.file("extbin/win/flake.exe", package = packageName()) }else{ - stop('No FLake executable available for your machine yet...') + stop("No FLake executable available for your machine yet...") } origin <- getwd() @@ -85,10 +85,10 @@ run_flakeWin <- function(sim_folder, nml_file, verbose = FALSE){ -# run_flakeOSx <- function(sim_folder, nml = TRUE, nml_file = 'flake.nml', verbose = TRUE, args){ -# #lib_path <- system.file('extbin/macFLake/bin', package=packageName()) #Not sure if libraries needed for FLake +# run_flakeOSx <- function(sim_folder, nml = TRUE, nml_file = "flake.nml", verbose = TRUE, args){ +# #lib_path <- system.file("extbin/macFLake/bin", package=packageName()) #Not sure if libraries needed for FLake # -# flake_path <- system.file('exec/macflake', package=packageName()) +# flake_path <- system.file("exec/macflake", package=packageName()) # # # ship flake and libs to sim_folder # #Sys.setenv(DYLD_FALLBACK_LIBRARY_PATH=lib_path) #Libraries? @@ -96,7 +96,7 @@ run_flakeWin <- function(sim_folder, nml_file, verbose = FALSE){ # if(nml){ # args <- c(args, nml_file) # }else{ -# args <- c(args,'--read_nml') +# args <- c(args,"--read_nml") # } # # origin <- getwd() @@ -121,15 +121,15 @@ run_flakeWin <- function(sim_folder, nml_file, verbose = FALSE){ # }) # } -run_flakeOSx <- function(sim_folder, nml_file = 'flake.nml', verbose=FALSE){ - flake_path <- system.file('exec/macflake', package='FLakeR') +run_flakeOSx <- function(sim_folder, nml_file = "flake.nml", verbose=FALSE){ + flake_path <- system.file("exec/macflake", package="FLakeR") origin <- getwd() setwd(sim_folder) - Sys.setenv(LD_LIBRARY_PATH = paste(system.file('extbin/nix', + Sys.setenv(LD_LIBRARY_PATH = paste(system.file("extbin/nix", package = packageName()), - Sys.getenv('LD_LIBRARY_PATH'), + Sys.getenv("LD_LIBRARY_PATH"), sep = ":")) tryCatch({ if (verbose){ @@ -148,15 +148,15 @@ run_flakeOSx <- function(sim_folder, nml_file = 'flake.nml', verbose=FALSE){ } -run_flakeNIX <- function(sim_folder, nml_file = 'flake.nml', verbose=FALSE){ - flake_path <- system.file('exec/nixflake', package=packageName()) +run_flakeNIX <- function(sim_folder, nml_file = "flake.nml", verbose=FALSE){ + flake_path <- system.file("exec/nixflake", package=packageName()) origin <- getwd() setwd(sim_folder) - Sys.setenv(LD_LIBRARY_PATH = paste(system.file('extbin/nix', + Sys.setenv(LD_LIBRARY_PATH = paste(system.file("extbin/nix", package = packageName()), - Sys.getenv('LD_LIBRARY_PATH'), + Sys.getenv("LD_LIBRARY_PATH"), sep = ":")) tryCatch({ if (verbose){ diff --git a/inst/extdata/feeagh.nml b/inst/extdata/feeagh.nml deleted file mode 100644 index 6a06b70..0000000 --- a/inst/extdata/feeagh.nml +++ /dev/null @@ -1,58 +0,0 @@ -!Namelist configuraltion file for FLAKE (Code /LER/ means that this is overwritten by settings in the LakeEnsemblR master config file) - -!------------------------------------------------------------------------------ -! Length of the simulation period, time step, saving interval -!------------------------------------------------------------------------------ - -&SIMULATION_PARAMS -del_time_lk = 86400,! Time step [s] -time_step_number = 210,! /LER/ The total number of time steps (17 years 1980-1996) -save_interval_n = 1 ! Saving interval in time steps -T_wML_in = 6.128,! /LER/ initial temperature of the upper mixed layer -T_bot_in = 6.255,! /LER/ initial temperature at the bottom -h_ML_in = 16.05,! /LER/ initial mixed layer thickness -/ - - -!------------------------------------------------------------------------------ -! Measurement heights/depths [m], names of input and output files -!------------------------------------------------------------------------------ -&METEO -z_wind_m(1) = 10.00, -z_Taqa_m(1) = 2.00, -z_Tw_m(1) = 0.00, -meteofile = 'all_meteo_file.dat', -outputfile = 'output/output.dat', -/ - - -!------------------------------------------------------------------------------ -! Lake-specific parameters -!------------------------------------------------------------------------------ -&LAKE_PARAMS -depth_w_lk = 16.05,! /LER/ Lake depth [m] -fetch_lk = 2.0E+03, ! Typical wind fetch [m] -depth_bs_lk = 5.0, ! Depth of the thermally active layer of the bottom sediments [m] -T_bs_lk = 4.0, ! Temperature at the outer edge of the thermally active layer of the bottom sediments [C] -latitude_lk = 53.9,! /LER/ Geographical latitude [dgr] -/ - - -!------------------------------------------------------------------------------ -! water transparency -!------------------------------------------------------------------------------ -! Mueggelsee (Opaque Water, gamma = 1.5) -&TRANSPARENCY -nband_optic = 1 ! Number of wave-length bands -frac_optic = 1 ! Fractions of total radiation flux -extincoef_optic = 0.98,! /LER/ Extinction coefficients -/ - -&inflow -DTinflow = 0.0, ! not relevant if Qfromfile = .true. -DTfixed = .true., ! not relevant if Qfromfile = .true. -QS = 0.0, ! inflow rate per lake area [m/s], not relevant if Qfromfile = .true. -Qfromfile = .true., -Qfile='Tinflow', ! a filename with inflow data should be subsituted for 'Tinflow' -time_step_number = 209 ! number of the model time steps, should be less than or equal to the number of rows in Qfile -/ diff --git a/man/run_flake.Rd b/man/run_flake.Rd index c3bff6c..7595e67 100644 --- a/man/run_flake.Rd +++ b/man/run_flake.Rd @@ -4,12 +4,12 @@ \alias{run_flake} \title{Run the FLake model} \usage{ -run_flake(sim_folder = ".", nml_file = NULL, verbose = FALSE) +run_flake(sim_folder = ".", nml_file = "flake.nml", verbose = FALSE) } \arguments{ \item{sim_folder}{the directory where simulation files are contained} -\item{nml_file}{filepath; to file with FLake setup. Defaults to 'flake.nml'} +\item{nml_file}{filepath; to file with FLake setup. Defaults to "flake.nml"} \item{verbose}{Save output as character vector. Defaults to FALSE} } @@ -18,8 +18,8 @@ This runs the FLake model on the specific simulation stored in \code{sim_folder} The specified \code{sim_folder} must contain valid NML files. } \examples{ -sim_folder <- system.file('extdata', package = 'FLakeR') -run_flake(sim_folder, nml_file = 'Heiligensee80-96.nml') +sim_folder <- system.file("extdata", package = "FLakeR") +run_flake(sim_folder, nml_file = "flake.nml") } \author{ Tadhg Moore From 92584781f5f262f40d0351a63aaa19df881179e5 Mon Sep 17 00:00:00 2001 From: Jorrit Mesman Date: Wed, 2 Feb 2022 13:40:27 +0100 Subject: [PATCH 4/8] Renaming template file to flake.nml --- README.md | 7 ++--- inst/extdata/flake.nml | 58 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 5 deletions(-) create mode 100644 inst/extdata/flake.nml diff --git a/README.md b/README.md index f0e15e9..03ebf2a 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,6 @@ devtools::install_github("aemon-j/FLakeR") ```{r example, eval=FALSE} library(FLakeR) -sim_folder <- system.file('extdata', package = 'FLakeR') -run_flake(sim_folder, nml_file = 'Heiligensee80-96.nml') +sim_folder <- system.file("extdata", package = "FLakeR") +run_flake(sim_folder, nml_file = "flake.nml") ``` - -### Output -Suite of tools for working with FLake output coming soon... diff --git a/inst/extdata/flake.nml b/inst/extdata/flake.nml new file mode 100644 index 0000000..6a06b70 --- /dev/null +++ b/inst/extdata/flake.nml @@ -0,0 +1,58 @@ +!Namelist configuraltion file for FLAKE (Code /LER/ means that this is overwritten by settings in the LakeEnsemblR master config file) + +!------------------------------------------------------------------------------ +! Length of the simulation period, time step, saving interval +!------------------------------------------------------------------------------ + +&SIMULATION_PARAMS +del_time_lk = 86400,! Time step [s] +time_step_number = 210,! /LER/ The total number of time steps (17 years 1980-1996) +save_interval_n = 1 ! Saving interval in time steps +T_wML_in = 6.128,! /LER/ initial temperature of the upper mixed layer +T_bot_in = 6.255,! /LER/ initial temperature at the bottom +h_ML_in = 16.05,! /LER/ initial mixed layer thickness +/ + + +!------------------------------------------------------------------------------ +! Measurement heights/depths [m], names of input and output files +!------------------------------------------------------------------------------ +&METEO +z_wind_m(1) = 10.00, +z_Taqa_m(1) = 2.00, +z_Tw_m(1) = 0.00, +meteofile = 'all_meteo_file.dat', +outputfile = 'output/output.dat', +/ + + +!------------------------------------------------------------------------------ +! Lake-specific parameters +!------------------------------------------------------------------------------ +&LAKE_PARAMS +depth_w_lk = 16.05,! /LER/ Lake depth [m] +fetch_lk = 2.0E+03, ! Typical wind fetch [m] +depth_bs_lk = 5.0, ! Depth of the thermally active layer of the bottom sediments [m] +T_bs_lk = 4.0, ! Temperature at the outer edge of the thermally active layer of the bottom sediments [C] +latitude_lk = 53.9,! /LER/ Geographical latitude [dgr] +/ + + +!------------------------------------------------------------------------------ +! water transparency +!------------------------------------------------------------------------------ +! Mueggelsee (Opaque Water, gamma = 1.5) +&TRANSPARENCY +nband_optic = 1 ! Number of wave-length bands +frac_optic = 1 ! Fractions of total radiation flux +extincoef_optic = 0.98,! /LER/ Extinction coefficients +/ + +&inflow +DTinflow = 0.0, ! not relevant if Qfromfile = .true. +DTfixed = .true., ! not relevant if Qfromfile = .true. +QS = 0.0, ! inflow rate per lake area [m/s], not relevant if Qfromfile = .true. +Qfromfile = .true., +Qfile='Tinflow', ! a filename with inflow data should be subsituted for 'Tinflow' +time_step_number = 209 ! number of the model time steps, should be less than or equal to the number of rows in Qfile +/ From 3c97e7a8230eaebdda30685e6d62e593b32d0bfc Mon Sep 17 00:00:00 2001 From: Jorrit Mesman Date: Thu, 3 Feb 2022 13:46:09 +0100 Subject: [PATCH 5/8] Removed comments that repeated keywords, to ease file reading --- inst/extdata/flake.nml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/inst/extdata/flake.nml b/inst/extdata/flake.nml index 6a06b70..6511850 100644 --- a/inst/extdata/flake.nml +++ b/inst/extdata/flake.nml @@ -49,10 +49,10 @@ extincoef_optic = 0.98,! /LER/ Extinction coefficients / &inflow -DTinflow = 0.0, ! not relevant if Qfromfile = .true. -DTfixed = .true., ! not relevant if Qfromfile = .true. -QS = 0.0, ! inflow rate per lake area [m/s], not relevant if Qfromfile = .true. -Qfromfile = .true., -Qfile='Tinflow', ! a filename with inflow data should be subsituted for 'Tinflow' +DTinflow = 0.0, ! not relevant if inflos are not used +DTfixed = .true., ! not relevant if inflos are not used +QS = 0.0, ! inflow rate per lake area [m/s], not relevant if inflos are not used +Qfromfile = .true.,! /LER/ +Qfile='Tinflow', ! a filename with inflow data should be substituted for 'Tinflow' time_step_number = 209 ! number of the model time steps, should be less than or equal to the number of rows in Qfile / From aafaf4371f9e118a4e7cff7d762a9412680b7407 Mon Sep 17 00:00:00 2001 From: Jorrit Mesman Date: Wed, 16 Feb 2022 13:35:13 +0100 Subject: [PATCH 6/8] c_relax_C added to template nml file --- inst/extdata/flake.nml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/inst/extdata/flake.nml b/inst/extdata/flake.nml index 6511850..33fd91e 100644 --- a/inst/extdata/flake.nml +++ b/inst/extdata/flake.nml @@ -6,7 +6,7 @@ &SIMULATION_PARAMS del_time_lk = 86400,! Time step [s] -time_step_number = 210,! /LER/ The total number of time steps (17 years 1980-1996) +time_step_number = 366,! /LER/ The total number of time steps (17 years 1980-1996) save_interval_n = 1 ! Saving interval in time steps T_wML_in = 6.128,! /LER/ initial temperature of the upper mixed layer T_bot_in = 6.255,! /LER/ initial temperature at the bottom @@ -31,10 +31,11 @@ outputfile = 'output/output.dat', !------------------------------------------------------------------------------ &LAKE_PARAMS depth_w_lk = 16.05,! /LER/ Lake depth [m] -fetch_lk = 2.0E+03, ! Typical wind fetch [m] +fetch_lk = 2000, ! Typical wind fetch [m] depth_bs_lk = 5.0, ! Depth of the thermally active layer of the bottom sediments [m] T_bs_lk = 4.0, ! Temperature at the outer edge of the thermally active layer of the bottom sediments [C] latitude_lk = 53.9,! /LER/ Geographical latitude [dgr] +c_relax_C = 0.0030, ! Adjustable constant in the relaxation equation for the shape factor / @@ -49,10 +50,10 @@ extincoef_optic = 0.98,! /LER/ Extinction coefficients / &inflow -DTinflow = 0.0, ! not relevant if inflos are not used -DTfixed = .true., ! not relevant if inflos are not used -QS = 0.0, ! inflow rate per lake area [m/s], not relevant if inflos are not used +DTinflow = 0.0, ! not relevant if inflows are not used +DTfixed = .true., ! not relevant if inflows are not used +QS = 0.0, ! inflow rate per lake area [m/s], not relevant if inflows are not used Qfromfile = .true.,! /LER/ Qfile='Tinflow', ! a filename with inflow data should be substituted for 'Tinflow' -time_step_number = 209 ! number of the model time steps, should be less than or equal to the number of rows in Qfile +time_step_number = 366 ! number of the model time steps, should be less than or equal to the number of rows in Qfile / From 36b67f7dd840b3ffec05cf13d28341e14303fbeb Mon Sep 17 00:00:00 2001 From: Jorrit Mesman Date: Mon, 14 Mar 2022 12:46:44 +0100 Subject: [PATCH 7/8] Match time_step_number in example nml to input files --- inst/extdata/flake.nml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inst/extdata/flake.nml b/inst/extdata/flake.nml index 33fd91e..1614e3c 100644 --- a/inst/extdata/flake.nml +++ b/inst/extdata/flake.nml @@ -6,7 +6,7 @@ &SIMULATION_PARAMS del_time_lk = 86400,! Time step [s] -time_step_number = 366,! /LER/ The total number of time steps (17 years 1980-1996) +time_step_number = 200,! /LER/ The total number of time steps (17 years 1980-1996) save_interval_n = 1 ! Saving interval in time steps T_wML_in = 6.128,! /LER/ initial temperature of the upper mixed layer T_bot_in = 6.255,! /LER/ initial temperature at the bottom @@ -55,5 +55,5 @@ DTfixed = .true., ! not relevant if inflows are not used QS = 0.0, ! inflow rate per lake area [m/s], not relevant if inflows are not used Qfromfile = .true.,! /LER/ Qfile='Tinflow', ! a filename with inflow data should be substituted for 'Tinflow' -time_step_number = 366 ! number of the model time steps, should be less than or equal to the number of rows in Qfile +time_step_number = 200 ! number of the model time steps, should be less than or equal to the number of rows in Qfile / From 29e3d5167eeb47146aad2a346dfc7c59b5b3829b Mon Sep 17 00:00:00 2001 From: Johannes Feldbauer Date: Fri, 3 Feb 2023 13:50:51 +0100 Subject: [PATCH 8/8] fixed bug with LD_LIBRARY_PATH that could lead to crash after repeaded calls to run_flake --- DESCRIPTION | 2 +- R/run_flake.R | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index a2bc549..c93d695 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: FLakeR Type: Package Title: Work with FLake in R -Version: 0.0.9 +Version: 0.0.10 Authors@R: person("Tadhg", "Moore", email = "tadhg.moore@dkit.ie", role = c("aut", "cre")) Maintainer: The package maintainer Description: Run the FLake model within R. Comes with a compiled version of FLake and example files. diff --git a/R/run_flake.R b/R/run_flake.R index 26c19dd..f2d1790 100644 --- a/R/run_flake.R +++ b/R/run_flake.R @@ -127,6 +127,8 @@ run_flakeOSx <- function(sim_folder, nml_file = 'flake.nml', verbose=FALSE){ origin <- getwd() setwd(sim_folder) + old_ld_path <- Sys.getenv('LD_LIBRARY_PATH') + on.exit(expr = {Sys.setenv(LD_LIBRARY_PATH = old_ld_path)}) Sys.setenv(LD_LIBRARY_PATH = paste(system.file('extbin/nix', package = packageName()), Sys.getenv('LD_LIBRARY_PATH'), @@ -145,7 +147,6 @@ run_flakeOSx <- function(sim_folder, nml_file = 'flake.nml', verbose=FALSE){ print(paste("FLake_ERROR: ",err)) setwd(origin) }) - } run_flakeNIX <- function(sim_folder, nml_file = 'flake.nml', verbose=FALSE){ @@ -154,6 +155,8 @@ run_flakeNIX <- function(sim_folder, nml_file = 'flake.nml', verbose=FALSE){ origin <- getwd() setwd(sim_folder) + old_ld_path <- Sys.getenv('LD_LIBRARY_PATH') + on.exit(expr = {Sys.setenv(LD_LIBRARY_PATH = old_ld_path)}) Sys.setenv(LD_LIBRARY_PATH = paste(system.file('extbin/nix', package = packageName()), Sys.getenv('LD_LIBRARY_PATH'), @@ -172,5 +175,4 @@ run_flakeNIX <- function(sim_folder, nml_file = 'flake.nml', verbose=FALSE){ print(paste("FLake_ERROR: ",err)) setwd(origin) }) - }