diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..6160f65 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +configure.ac text eol=lf \ No newline at end of file diff --git a/.github/workflows/cran-check.yml b/.github/workflows/cran-check.yml index ad27268..d15f38b 100644 --- a/.github/workflows/cran-check.yml +++ b/.github/workflows/cran-check.yml @@ -64,13 +64,8 @@ jobs: - name: Build and Check ToxicR if: runner.os != 'Windows' run: | - R CMD build . - file config.log - cat config.log r_output=$(R CMD build .) - echo "$r_output" - package_name=$(echo "$r_output" | sed -n "s/.*building ‘\([^’]*\.tar\.gz\)’.*/\1/p") - echo "$package_name" + package_name=$(echo "$r_output" | sed -n "s/.*building ‘\([^’]*\.tar\.gz\)’.*/\1/p") R CMD check --as-cran --no-manual $package_name shell: bash working-directory: "." @@ -78,13 +73,7 @@ jobs: if: runner.os == 'Windows' run: | r_output=$(R CMD build .) - echo "$r_output" package_name=$(echo "$r_output" | sed -n "s/.*building '\([^']*\.tar\.gz\)'.*/\1/p") - echo "$package_name" R CMD check --as-cran --no-manual $package_name - file ToxicR.Rcheck/00install.log - file ToxicR/ToxicR.Rcheck/00install.log - cat ToxicR.Rcheck/00install.log - cat ToxicR.Rcheck/00check.log shell: bash working-directory: "." \ No newline at end of file diff --git a/.gitignore b/.gitignore index 7b0abf5..a84e173 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,10 @@ *.o *.so +*.Rproj .Rproj.user .Rhistory .vscode/* .RData *.tar.gz -*.dll \ No newline at end of file +*.dll +install.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c153f4..1c1aeca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changes -## Version 23.10.1.2.3 -## The following cumulative fixes are in version 23.10.1.2.3 +## Version 23.10.1.2.4 +## The following cumulative fixes are in version 23.10.1.2.4 - Add the ability to set a seed for nlopt and GSL to allow for consistent results - Set additional checks and guards for openMP ## New Features diff --git a/DESCRIPTION b/DESCRIPTION index 5ec22d8..461a01b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -77,7 +77,7 @@ Imports: Rcpp (>= 1.0.0), ggplot2 (>= 3.3.2), shiny (>= 1.5.0), coda (>= 0.19-4), scales (>= 1.1.1), forcats, ggridges (>= 0.5.3), doBy (>= 4.6.11), multcomp (>= 1.4), dplyr (>= 1.0.7), remotes LinkingTo: Rcpp, RcppEigen, RcppGSL -RoxygenNote: 7.3.1 +RoxygenNote: 7.3.2 Encoding: UTF-8 VignetteBuilder: knitr Suggests: plotly (>= 4.9.2.1), rmarkdown, actuar (>= 3.2-0),ggpubr (>= diff --git a/R/RcppExports.R b/R/RcppExports.R index bae3eee..d329a95 100644 --- a/R/RcppExports.R +++ b/R/RcppExports.R @@ -42,6 +42,6 @@ } .set_threads <- function(num_threads) { - invisible(.Call(`_ToxicR_set_threads`, num_threads)) + .Call(`_ToxicR_set_threads`, num_threads) } diff --git a/R/opening_messages.R b/R/opening_messages.R index 296e991..2c6a8e2 100644 --- a/R/opening_messages.R +++ b/R/opening_messages.R @@ -17,7 +17,8 @@ # CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE # OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. .onAttach <- function(libname, pkgname) { - msg <- " + version <- as.character(utils::packageVersion("ToxicR")) + msg <- paste0(" _______ _____ |__ __| \U1F913 | __ \\ @@ -25,7 +26,7 @@ | |/ _ \\ \\/ / |/ __| _ / | | (_) > <| | (__| | \\ \\ |_|\\___/_/\\_\\_|\\___|_| \\_\\ - 24.1.1.2.4 + ",version," ___ | | / \\ ____()() @@ -39,7 +40,7 @@ PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIG HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -" +") # notify the option to update? (5 possible cases) # 1. error in getting the current package version -> yes @@ -50,7 +51,7 @@ OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # in short, notify the option to update unless the version numbers match # get version of the currently installed package current_pkg_version <- tryCatch( - as.character(utils::packageVersion("ToxicR")), + version, error = function(e) "unknown") # github url github_url <- paste0( @@ -81,7 +82,7 @@ OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. compare_version_result == 0) { startup_message <- paste0( "Package attached: ToxicR v", current_pkg_version, - " (same as the most recent version available through GitHub).") + " (the most recent version available through GitHub).") } else if ( # skip update for case 4 current_pkg_version != "unknown" & @@ -103,7 +104,13 @@ OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } packageStartupMessage(msg) packageStartupMessage(startup_message) - .set_threads(2); - open_mp_message <- "OpenMP threads set to 2.\n" + status <- .set_threads(2) + if (status == 1) { + open_mp_message <- "OpenMP threads set to 2.\n" + } else if (status == 0) { + open_mp_message <- "OpenMP will not be used for parallelization.\n" + } else { + open_mp_message <- "OpenMP is not supported on this architecture.\n" + } packageStartupMessage(open_mp_message) } diff --git a/src/RcppExports.cpp b/src/RcppExports.cpp index 36c7526..1eefa35 100644 --- a/src/RcppExports.cpp +++ b/src/RcppExports.cpp @@ -167,13 +167,14 @@ BEGIN_RCPP END_RCPP } // set_threads -void set_threads(int num_threads); +int set_threads(int num_threads); RcppExport SEXP _ToxicR_set_threads(SEXP num_threadsSEXP) { BEGIN_RCPP + Rcpp::RObject rcpp_result_gen; Rcpp::RNGScope rcpp_rngScope_gen; Rcpp::traits::input_parameter< int >::type num_threads(num_threadsSEXP); - set_threads(num_threads); - return R_NilValue; + rcpp_result_gen = Rcpp::wrap(set_threads(num_threads)); + return rcpp_result_gen; END_RCPP } diff --git a/src/polyK/polyK_setup.cpp b/src/polyK/polyK_setup.cpp index 32c6cd8..0aa21db 100644 --- a/src/polyK/polyK_setup.cpp +++ b/src/polyK/polyK_setup.cpp @@ -1,10 +1,10 @@ // necessary things to run in R -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wignored-attributes" +// #pragma GCC diagnostic push +// #pragma GCC diagnostic ignored "-Wignored-attributes" #include -#pragma GCC diagnostic pop +// #pragma GCC diagnostic pop #include "polyK_animal.h" #include "polyK_setup.h" diff --git a/src/polyK/polyK_setup.h b/src/polyK/polyK_setup.h index 250a01f..0b48de6 100644 --- a/src/polyK/polyK_setup.h +++ b/src/polyK/polyK_setup.h @@ -2,10 +2,10 @@ #include #include #include -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wignored-attributes" +// #pragma GCC diagnostic push +// #pragma GCC diagnostic ignored "-Wignored-attributes" #include -#pragma GCC diagnostic pop +// #pragma GCC diagnostic pop #include #include "polyK_animal.h" diff --git a/src/set_omp_threads.cpp b/src/set_omp_threads.cpp index c76fef7..69a6aa4 100644 --- a/src/set_omp_threads.cpp +++ b/src/set_omp_threads.cpp @@ -11,20 +11,25 @@ using namespace Rcpp; // function: set_threads // purpose: takes an integer value and set the number of // openmp threads to that value -// output: none +// output: integer representing if openMP is supported and set correctely // [[Rcpp::export(".set_threads")]] -void set_threads(int num_threads) { +int set_threads(int num_threads) { #ifndef NO_OMP if(omp_get_max_threads() > 1){ if (num_threads > omp_get_num_threads()) { Seeder* s = Seeder::getInstance(); omp_set_num_threads(num_threads); s->reset_max_threads(num_threads); + // Rcpp::Rcout << "OpenMP threads set to " << num_threads << std::endl; + return 1; } }else{ - Rcout << "OMP will not be used for parallelization."; + return 0; + // Rcpp::Rcout << "OMP will not be used for parallelization."; } #else - Rcpp::Rcout << "OpenMP not supported on this architecure." << std::endl; + return -1; + // Rcpp::Rcout << "OpenMP not supported on this architecure." << std::endl; #endif + return -1; }