Skip to content

Commit

Permalink
Release/devel v6.0.3 (#242)
Browse files Browse the repository at this point in the history
* This version produces the same output as the previous version.
* Update `SOILWAT2` to v7.2.0 which improves error handling and fixes memory leaks on error (close #239; @dschlaep, @N1ckP3rsl3y).
* Code no longer requires (unused) `pcg` header (@dschlaep).
  • Loading branch information
dschlaep authored Oct 27, 2023
2 parents e436a76 + e94589b commit 249477c
Show file tree
Hide file tree
Showing 37 changed files with 865 additions and 350 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,5 @@ doc
vignettes/*.pdf
vignettes/*.html
vignettes/*.log
/doc/
/Meta/
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: rSOILWAT2
Version: 6.0.2
Version: 6.0.3
Title: An Ecohydrological Ecosystem-Scale Water Balance Simulation Model
Description: Access to the C-based SOILWAT2 v7.1.0 and functionality for
Description: Access to the C-based SOILWAT2 v7.2.0 and functionality for
SQLite-database of weather data.
Authors@R: c(
person(
Expand Down
11 changes: 10 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
# rSOILWAT2 v6.0.3
* This version produces the same output as the previous version.
* Update `SOILWAT2` to v7.2.0 which improves error handling and fixes
memory leaks on error (#239; @dschlaep, @N1ckP3rsl3y).
* Code no longer requires (unused) `pcg` header (@dschlaep).


# rSOILWAT2 v6.0.2
* This version produces the same output as the previous version.
* Update `SOILWAT2` to v7.1.0 which prepares for thread-safety and reentrancy
(@N1ckP3rsl3y, @dschlaep).
* C-side of `rSOILWAT2` gains new globals of the four main abstract types in
`SOILWAT2` - SW_ALL, SW_OUTPUT_POINTERS, LOG_INFO, and PATH_INFO -
to interact with `SOILWAT2`.
to interact with `SOILWAT2`(@N1ckP3rsl3y, @dschlaep).


# rSOILWAT2 v6.0.1

Expand Down
35 changes: 8 additions & 27 deletions R/Rsw.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ sw_args <- function(dir, files.in, echo, quiet) {
#'
#' @export
sw_verbosity <- function(verbose = TRUE) {
invisible(!.Call(C_sw_quiet, !as.logical(verbose)))
invisible(.Call(C_sw_verbose, as.logical(verbose)))
}


Expand Down Expand Up @@ -243,6 +243,8 @@ sw_exec <- function(
on.exit(setwd(dir_prev), add = TRUE)

quiet <- as.logical(quiet)
prev_verbosity <- sw_verbosity(!quiet)
on.exit(sw_verbosity(prev_verbosity), add = TRUE)

input <- sw_args(dir, files.in, echo, quiet)

Expand Down Expand Up @@ -310,7 +312,7 @@ sw_exec <- function(


# Run SOILWAT2
res <- .Call(C_start, input, inputData, weatherList, quiet)
res <- .Call(C_sw_start, input, inputData, weatherList)

slot(res, "version") <- rSW2_version()
slot(res, "timestamp") <- rSW2_timestamp()
Expand Down Expand Up @@ -380,30 +382,12 @@ sw_inputDataFromFiles <- function(
on.exit(setwd(dir_prev), add = TRUE)

quiet <- as.logical(quiet)
prev_verbosity <- sw_verbosity(!quiet)
on.exit(sw_verbosity(prev_verbosity), add = TRUE)

input <- sw_args(dir, files.in, echo = FALSE, quiet = quiet)

res <- .Call(C_onGetInputDataFromFiles, input, quiet)

slot(res, "version") <- rSW2_version()
slot(res, "timestamp") <- rSW2_timestamp()

res
}


#' Return output data
#'
#' @inheritParams sw_exec
#'
#' @return An object of class \code{\linkS4class{swOutput}}.
#' @export
sw_outputData <- function(inputData) {

dir_prev <- getwd()
on.exit(setwd(dir_prev), add = TRUE)

res <- .Call(C_onGetOutput, inputData)
res <- .Call(C_onGetInputDataFromFiles, input)

slot(res, "version") <- rSW2_version()
slot(res, "timestamp") <- rSW2_timestamp()
Expand Down Expand Up @@ -439,9 +423,6 @@ sw_outputData <- function(inputData) {
#'
#' @export
sw_inputData <- function() {
dir_prev <- getwd()
on.exit(setwd(dir_prev), add = TRUE)

tmp <- swInputData() # default values (minus some deleted slots)
utils::data(package = "rSOILWAT2", "weatherData", envir = environment())
slot(tmp, "weatherHistory") <- get("weatherData", envir = environment())
Expand All @@ -455,7 +436,7 @@ sw_inputData <- function() {
#' @return A logical value
#' @export
has_soilTemp_failed <- function() {
.Call(C_tempError)
isTRUE(.Call(C_tempError))
}


Expand Down
3 changes: 2 additions & 1 deletion R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
#' utils::data(sw_exampleData)
#' path_demo <- system.file("extdata", "example1", package = "rSOILWAT2")
#' x <- sw_inputDataFromFiles(dir = path_demo, files.in = "files.in")
#' identical(x, sw_exampleData) ## TRUE
#' ## expect differences in slots "timestamp" and possibly "version"
#' all.equal(x, sw_exampleData)
"sw_exampleData"


Expand Down
25 changes: 25 additions & 0 deletions R/rSOILWAT2_deprecated.R
Original file line number Diff line number Diff line change
Expand Up @@ -1255,3 +1255,28 @@ readNumerics <- function(text,expectedArgs,showWarnings=FALSE) {
}
return(tmp)
}



#------ Other deprecated functions ------


#' Return output data
#'
#' @inheritParams sw_exec
#'
#' @return An object of class \code{\linkS4class{swOutput}}.
#' @export
sw_outputData <- function(inputData) {
.Deprecated("Store return value of `rSOILWAT2::sw_exec()`.")

dir_prev <- getwd()
on.exit(setwd(dir_prev), add = TRUE)

res <- .Call(C_onGetOutputDeprecated, inputData)

slot(res, "version") <- rSW2_version()
slot(res, "timestamp") <- rSW2_timestamp()

res
}
3 changes: 2 additions & 1 deletion man/sw_exampleData.Rd

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

2 changes: 1 addition & 1 deletion man/sw_outputData.Rd

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

4 changes: 2 additions & 2 deletions src/Makevars
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
target = SOILWAT2
lib_target = lib$(target).a
lib_target = libr$(target).a
path_target = SOILWAT2
path_lib = $(path_target)/bin
sw_sources = src/SW_Output_outarray.c
Expand All @@ -21,7 +21,7 @@ $(path_lib)/$(lib_target):
# Note: `-I..` is required for rSOILWAT2 headers that are included by
# SOILWAT2 headers (such as `#include "rSW_SoilWater.h"`)
# -@(cd $(path_target) && $(MAKE) compiler_version)
cd $(path_target) && $(MAKE) lib \
cd $(path_target) && $(MAKE) libr \
CC="$(CC)" CPPFLAGS="$(ALL_CPPFLAGS) -I.." CFLAGS="$(ALL_CFLAGS)" \
AR="$(AR)" sw_sources="$(sw_sources)"

Expand Down
2 changes: 1 addition & 1 deletion src/SOILWAT2
Submodule SOILWAT2 updated 70 files
+3 −3 .github/workflows/main_nix.yml
+22 −1 NEWS.md
+33 −27 README.md
+9 −11 doc/additional_pages/A_SOILWAT2_user_guide.md
+1 −4 include/SW_Control.h
+22 −0 include/SW_Defines.h
+2 −5 include/SW_Files.h
+4 −2 include/SW_Main_lib.h
+1 −4 include/SW_Markov.h
+3 −7 include/SW_Output.h
+1 −5 include/SW_Site.h
+1 −4 include/SW_SoilWater.h
+2 −1 include/SW_VegEstab.h
+3 −3 include/SW_VegProd.h
+9 −7 include/SW_Weather.h
+11 −19 include/SW_datastructs.h
+1 −2 include/filefuncs.h
+2 −9 include/generic.h
+0 −53 include/memblock.h
+0 −3 include/myMemory.h
+7 −8 include/rands.h
+61 −18 makefile
+34 −54 src/SW_Carbon.c
+123 −37 src/SW_Control.c
+71 −39 src/SW_Files.c
+37 −0 src/SW_Flow.c
+40 −16 src/SW_Flow_lib.c
+9 −5 src/SW_Flow_lib_PET.c
+37 −17 src/SW_Main.c
+143 −27 src/SW_Main_lib.c
+121 −147 src/SW_Markov.c
+16 −8 src/SW_Model.c
+238 −66 src/SW_Output.c
+15 −55 src/SW_Output_mock.c
+7 −1 src/SW_Output_outarray.c
+76 −13 src/SW_Output_outtext.c
+237 −189 src/SW_Site.c
+8 −4 src/SW_Sky.c
+224 −132 src/SW_SoilWater.c
+102 −25 src/SW_VegEstab.c
+210 −114 src/SW_VegProd.c
+349 −119 src/SW_Weather.c
+104 −111 src/filefuncs.c
+64 −29 src/generic.c
+30 −465 src/mymemory.c
+28 −17 src/rands.c
+14 −1 tests/gtests/sw_maintest.cc
+4 −55 tests/gtests/sw_testhelpers.cc
+37 −51 tests/gtests/sw_testhelpers.h
+5 −0 tests/gtests/test_SW_Carbon.cc
+28 −9 tests/gtests/test_SW_Flow_Lib.cc
+36 −10 tests/gtests/test_SW_Flow_Lib_PET.cc
+55 −35 tests/gtests/test_SW_Flow_lib_temp.cc
+58 −0 tests/gtests/test_SW_Main_lib.cc
+33 −15 tests/gtests/test_SW_Markov.cc
+111 −57 tests/gtests/test_SW_Site.cc
+97 −37 tests/gtests/test_SW_SoilWater.cc
+2 −0 tests/gtests/test_SW_VegEstab.cc
+87 −54 tests/gtests/test_SW_VegProd.cc
+123 −94 tests/gtests/test_SW_Weather.cc
+57 −14 tests/gtests/test_WaterBalance.cc
+92 −0 tests/gtests/test_generic.cc
+69 −0 tests/gtests/test_mymemory.cc
+51 −21 tests/gtests/test_rands.cc
+29 −29 tools/check_SOILWAT2.sh
+1 −30 tools/run_bin_leaks.sh
+38 −0 tools/run_bin_sanitizer.sh
+2 −2 tools/run_gcov.sh
+5 −33 tools/run_test_leaks.sh
+37 −0 tools/run_test_sanitizer.sh
16 changes: 8 additions & 8 deletions src/SW_R_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@


/* .Call calls */
extern SEXP start(SEXP, SEXP, SEXP, SEXP);
extern SEXP sw_start(SEXP, SEXP, SEXP);
extern SEXP tempError(void);
extern SEXP onGetInputDataFromFiles(SEXP, SEXP);
extern SEXP onGetOutput(SEXP);
extern SEXP onGetInputDataFromFiles(SEXP);
extern SEXP onGetOutputDeprecated(SEXP);
extern SEXP rSW2_processAllWeather(SEXP, SEXP);
extern SEXP rSW2_readAllWeatherFromDisk(SEXP, SEXP, SEXP, SEXP, SEXP);
extern SEXP sw_consts(void);
extern SEXP sw_quiet(SEXP);
extern SEXP sw_verbose(SEXP);
extern SEXP rSW2_SWRC_PTF_estimate_parameters(SEXP, SEXP, SEXP, SEXP, SEXP);
extern SEXP sw_check_SWRC_vs_PTF(SEXP, SEXP);
extern SEXP rSW2_SWRC_check_parameters(SEXP, SEXP);
Expand All @@ -23,14 +23,14 @@ extern SEXP rSW2_estimate_PotNatVeg_composition(SEXP, SEXP, SEXP, SEXP,SEXP, SEX
extern SEXP rSW2_calc_SiteClimate(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);

static const R_CallMethodDef CallEntries[] = {
{"start", (DL_FUNC) &start, 4},
{"sw_start", (DL_FUNC) &sw_start, 3},
{"tempError", (DL_FUNC) &tempError, 0},
{"onGetInputDataFromFiles", (DL_FUNC) &onGetInputDataFromFiles, 2},
{"onGetOutput", (DL_FUNC) &onGetOutput, 1},
{"onGetInputDataFromFiles", (DL_FUNC) &onGetInputDataFromFiles, 1},
{"onGetOutputDeprecated", (DL_FUNC) &onGetOutputDeprecated, 1},
{"rSW2_processAllWeather", (DL_FUNC) &rSW2_processAllWeather, 2},
{"rSW2_readAllWeatherFromDisk",(DL_FUNC) &rSW2_readAllWeatherFromDisk,5},
{"sw_consts", (DL_FUNC) &sw_consts, 0},
{"sw_quiet", (DL_FUNC) &sw_quiet, 1},
{"sw_verbose", (DL_FUNC) &sw_verbose, 1},
{"rSW2_SWRC_PTF_estimate_parameters", (DL_FUNC) &rSW2_SWRC_PTF_estimate_parameters, 5},
{"sw_check_SWRC_vs_PTF", (DL_FUNC) &sw_check_SWRC_vs_PTF, 2},
{"rSW2_SWRC_check_parameters", (DL_FUNC) &rSW2_SWRC_check_parameters, 2},
Expand Down
Loading

0 comments on commit 249477c

Please sign in to comment.